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

View File

@ -1,10 +1,11 @@
all: Robot_arm all: Robot_arm DynamixelHandler
g++ Robot_arm.o -o Robot_arm.exe L/usr/local/lib ldxl_x64_cpp -lrt g++ DynamixelHandler.o Robot_arm.o -o Robot_arm.exe -L/usr/local/lib -ldxl_x64_cpp -lrt
Robot_arm: Robot_arm.cpp 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: clean:
rm *.o rm *.o