21 void swap(int32_t *array);
23 int main(
int argc,
char *argv[])
25 const char* port_name =
"/dev/ttyUSB0";
26 int baud_rate = 57600;
28 uint16_t model_number = 0;
29 uint8_t dxl_id[2] = {0, 0};
33 printf(
"Please set '-port_name', '-baud_rate', '-dynamixel_id_1', '-dynamixel_id_2' arguments for connected Dynamixels\n");
39 baud_rate = atoi(argv[2]);
40 dxl_id[0] = atoi(argv[3]);
41 dxl_id[1] = atoi(argv[4]);
49 result = dxl_wb.
init(port_name, baud_rate, &log);
53 printf(
"Failed to init\n");
58 printf(
"Succeed to init(%d)\n", baud_rate);
60 for (
int cnt = 0; cnt < 2; cnt++)
62 result = dxl_wb.
ping(dxl_id[cnt], &model_number, &log);
66 printf(
"Failed to ping\n");
70 printf(
"Succeeded to ping\n");
71 printf(
"id : %d, model_number : %d\n", dxl_id[cnt], model_number);
74 result = dxl_wb.
jointMode(dxl_id[cnt], 0, 0, &log);
78 printf(
"Failed to change joint mode\n");
82 printf(
"Succeed to change joint mode\n");
90 printf(
"Failed to add sync write handler\n");
93 int32_t goal_position[2] = {0, 1023};
95 const uint8_t handler_index = 0;
99 result = dxl_wb.
syncWrite(handler_index, &goal_position[0], &log);
103 printf(
"Failed to sync write position\n");
116 int32_t tmp = array[0];
bool init(const char *device_name="/dev/ttyUSB0", uint32_t baud_rate=57600, const char **log=NULL)
DynamixelWorkbench dxl_wb
bool syncWrite(uint8_t index, int32_t *data, const char **log=NULL)
void swap(int32_t *array)
bool addSyncWriteHandler(uint16_t address, uint16_t length, const char **log=NULL)
int main(int argc, char *argv[])
bool ping(uint8_t id, uint16_t *get_model_number, const char **log=NULL)
bool jointMode(uint8_t id, int32_t velocity=0, int32_t acceleration=0, const char **log=NULL)