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