new make file

This commit is contained in:
Loïc DELATTRE 2023-03-10 08:42:17 +01:00
parent 1c74652f32
commit 26cbf64107
2 changed files with 36 additions and 24 deletions

View File

@ -2,9 +2,12 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include "DynamixelHandler.h" #include "DynamixelHandler.h"
using namespcae std
// Global variables // Global variables
DynamixelHandler _oDxlHandler; DynamixelHandler _oDxlHandler;
std::string _poppyDxlPortName = "/dev/ttyUSB0"; string _poppyDxlPortName = "/dev/ttyUSB0";
float _poppyDxlProtocol = 2.0; float _poppyDxlProtocol = 2.0;
int _poppyDxlBaudRate = 1000000; int _poppyDxlBaudRate = 1000000;
int _nbJoints = 6; int _nbJoints = 6;
@ -13,27 +16,27 @@ float _maxJointCmd = 1023;
float _minJointAngle = -180.0f; float _minJointAngle = -180.0f;
float _maxJointAngle = 180.0f; float _maxJointAngle = 180.0f;
int main() int main()
{ std::cout << "===Initialization of the Dynamixel Motor communication====" << std::endl; {
_oDxlHandler.setDeviceName(_poppyDxlPortName); cout << "===Initialization of the Dynamixel Motor communication====" << endl;
_oDxlHandler.setProtocolVersion(_poppyDxlProtocol); _ oDxlHandler.setDeviceName(_poppyDxlPortName);
_oDxlHandler.openPort(); _ oDxlHandler.setProtocolVersion(_poppyDxlProtocol);
_oDxlHandler.setBaudRate(_poppyDxlBaudRate); _ oDxlHandler.openPort();
_oDxlHandler.enableTorque(true); _ oDxlHandler.setBaudRate(_poppyDxlBaudRate);
std::cout << std::endl; _ oDxlHandler.enableTorque(true);
// read current joint position cout << endl;
std::vector<uint16_t> l_vCurrentJointPosition; // read current joint position
_oDxlHandler.readCurrentJointPosition(l_vCurrentJointPosition); vector<uint16_t> l_vCurrentJointPosition;
// display current joint position _ oDxlHandler.readCurrentJointPosition(l_vCurrentJointPosition);
std::cout << "vCurrentJointPosition= (" << std::endl; // display current joint position
for (int l_joint=0; l_joint < l_vCurrentJointPosition.size(); l_joint++) cout << "vCurrentJointPosition= (" << endl;
std::cout << l_vCurrentJointPosition[l_joint] << ", "; for (int l_joint=0; l_joint < l_vCurrentJointPosition.size(); l_joint++)
std::cout << ")" << std::endl; cout << l_vCurrentJointPosition[l_joint] << ", ";
// wait 1s cout << ")" << endl;
5 // wait 1s
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); this_thread::sleep_for(chrono::milliseconds(1000));
std::cout << "===Closing the Dynamixel Motor communication====" << std::endl; cout << "===Closing the Dynamixel Motor communication====" << endl;
_oDxlHandler.enableTorque(false); _ oDxlHandler.enableTorque(false);
_oDxlHandler.closePort(); _ oDxlHandler.closePort();
std::cout << std::endl; cout << endl;
return 0; return 0;
} }

9
makefile Normal file
View File

@ -0,0 +1,9 @@
all: SignalLab1
g++ Robot_arm.o -o Robot_arm.exe
SignalLab1: Robot_arm.cpp
g++ -c Robot_arm.cpp -I./toolkit-dynamixel/include toolkit-dynamixel/src/DynamixelHandler.cpp -I./toolkit-dynamixel/include Robot_arm.cpp
clean:
rm *.o
rm *.exe