Quick Start for Dynamixel Pro v1.00b
}
Similarly several types of write commands can be implemented according to the size of the corresponding address.
The following example combines several features of Dyanmixel PRO, such as Operating Mode (11) and its different type of operations; and
implementing their respective write function.
This example also illustrates how the user can easily turn Torque Enable on and off at will enabling easy manipulation of EEPROM
addresses.
/dxl_sdk-20/example/OperatingMode/main.cpp (partly shown)
...
// declare the following in preprocessor for illustrative purposes
#define OPERATING_MODE
#define TORQUE_ENABLE
#define GOAL_POSITION
#define GOAL_TORQUE
#define GOAL_VELOCITY
#define DEFAULT_BAUDNUM
#define CONTROL_PERIOD
...
using namespace
DXL_PRO;
Dynamixel DXL("/dev/ttyUSB0");
int
main()
{
int
GoalPos 250000;
// int GoalPos = 151875; // for 42-series
int
GoalVel = -3000l
int
GoalTorque = 120;
...
// open device and set baud rate here
if( DXL.Connect() == 0 )
...
// Torque Enable is off by default
// The following line is not necessary but it ensures
// Torque Enable is off regardless
DXL.WriteByte(1, TORQUE_ENABLE, 0,
...
While(1); {
switch(_getch()) {
case
0x1b:
DXL.WriteByte(1, TORQUE_ENABLE, 0, 0);
usleep(CONTROL_PERIOD*100);
DXL.WriteByte(1, OPERATING_MODE, 3, 0);
break;
case
0x30:
// "0" key to set in Torque Mode
DXL.WriteByte(1, OPERATING_MODE, 0, 0);
usleep(CONTROL_PERIOD*100);
DXL.WriteByte(1, TORQUE_ENABLE, 1, 0);
usleep(CONTROL_PERIOD*100);
// Goal Torque (604) size is 2 bytes (a
11
562
596
604
600
1
(10)
// must declare location of USB-to-Dynamixel
// for 54-series
// use simply switch loop to change between modes
// ESC key to set to default settings
// time period, arbitrary value
0);
word)/
Page 123 / 139
Need help?
Do you have a question about the Dynamixel Pro and is the answer not in the manual?
Questions and answers