-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
46 lines (42 loc) · 1.91 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# libDynamixel
This is a C++ interface to control [ROBOTIS](http://www.robotis.com) [Dynamixel smart servos](http://www.robotis.com/xe/dynamixel_en). This library provides an API to perform basic low-level functionality of dynamixel servos, plus a higher-level convenience layer on the top of basic API.
# Usage
Each servo type has an abstraction defined in the library. The communication layer is completely isolated and supposed to be managed by libSerial. You will need to pass a reference to a `SerialStream` object for each servo when initializing it.
#include <SerialStream.h> /* It's libSerial's business to communicate */
#include <dynamixel/mx28.hpp> /* We want to control two MX-28 */
#include <dynamixel/ax12.hpp> /* And a AX-12 */
using namespace std;
using namespace Dynamixel;
using namespace LibSerial;
int main() {
SerialStream stream{"/dev/ttyUSB0", SerialStreamBuf::BAUD_57600,
SerialStreamBuf::CHAR_SIZE_8, SerialStreamBuf::PARITY_NONE, 1,
SerialStreamBuf::FLOW_CONTROL_NONE};
MX28 m1 { stream, 1 }; /* Initialize a MX-28 with id `2' */
MX28 m2 { stream, 2 };
AX12 m3 { stream, 3 }
// Rotate by 90 degree, and 10 RPM:
m1.rotate(90.0f,Dynamixel::AngleUnit::Degree,
20.0f, Dynamixel::VelocityUnit::RPM);
// Rotate by 1024 steps, and speed of 500 units:
m1.rotate(1024.0f, 500.0f);
// Or:
m1.rotate(1024.0f,Dynamixel::AngleUnit::Default,
500.0f, Dynamixel::VelocityUnit::Default);
// Sense information:
while(m1.moving()) {
cout << m1.presentLoad() << endl;
cout << m1.presentPosition() << endl;
cout << m1.presentSpeed() << endl;
cout << m1.presentTemperature() << endl;
cout << m1.presentVoltage() << endl;
}
// Set acceleration:
m1.setGoalAcceleration(100);
// Set ID:
m1.setID(4);
// Do whatever you want (:
return 0;
}
# Compile
Please refere to INSTALL.