make file and Robot_arm good

This commit is contained in:
Loïc DELATTRE 2023-03-10 09:14:55 +01:00
parent cf03ec12a1
commit f8aba10c51
2 changed files with 14 additions and 13 deletions

View File

@ -3,7 +3,7 @@
#include <thread>
#include "DynamixelHandler.h"
using namespcae std
using namespace std;
// Global variables
DynamixelHandler _oDxlHandler;
@ -18,15 +18,15 @@ float _maxJointAngle = 180.0f;
int main()
{
cout << "===Initialization of the Dynamixel Motor communication====" << endl;
_ oDxlHandler.setDeviceName(_poppyDxlPortName);
_ oDxlHandler.setProtocolVersion(_poppyDxlProtocol);
_ oDxlHandler.openPort();
_ oDxlHandler.setBaudRate(_poppyDxlBaudRate);
_ oDxlHandler.enableTorque(true);
_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);
_oDxlHandler.readCurrentJointPosition(l_vCurrentJointPosition);
// display current joint position
cout << "vCurrentJointPosition= (" << endl;
for (int l_joint=0; l_joint < l_vCurrentJointPosition.size(); l_joint++)
@ -35,8 +35,8 @@ _ oDxlHandler.readCurrentJointPosition(l_vCurrentJointPosition);
// wait 1s
this_thread::sleep_for(chrono::milliseconds(1000));
cout << "===Closing the Dynamixel Motor communication====" << endl;
_ oDxlHandler.enableTorque(false);
_ oDxlHandler.closePort();
_oDxlHandler.enableTorque(false);
_oDxlHandler.closePort();
cout << endl;
return 0;
}

View File

@ -1,10 +1,11 @@
all: Robot_arm
g++ Robot_arm.o -o Robot_arm.exe L/usr/local/lib ldxl_x64_cpp -lrt
all: Robot_arm DynamixelHandler
g++ DynamixelHandler.o Robot_arm.o -o Robot_arm.exe -L/usr/local/lib -ldxl_x64_cpp -lrt
Robot_arm: Robot_arm.cpp
g++ -c Robot_arm.cpp
g++ -c Robot_arm.cpp -I/home/ros/SOFTWARE/toolkit-dynamixel/include
DynamixelHandler: /home/ros/SOFTWARE/toolkit-dynamixel/src/DynamixelHandler.cpp
g++ -c -I/home/ros/SOFTWARE/toolkit-dynamixel/include /home/ros/SOFTWARE/toolkit-dynamixel/src/DynamixelHandler.cpp
clean:
rm *.o