21 int main(
int argc,
char *argv[])
23 const char* port_name =
"/dev/ttyUSB0";
24 int baud_rate = 57600;
30 printf(
"Please set '-port_name', '-baud_rate', '-dynamixel id', '-new_dynamixel_id' arguments for connected Dynamixels\n");
36 baud_rate = atoi(argv[2]);
37 dxl_id = atoi(argv[3]);
38 new_dxl_id = atoi(argv[4]);
46 result = dxl_wb.
init(port_name, baud_rate, &log);
50 printf(
"Failed to init\n");
55 printf(
"Succeeded to init(%d)\n", baud_rate);
57 uint16_t model_number = 0;
58 result = dxl_wb.
ping(dxl_id, &model_number, &log);
62 printf(
"Failed to ping\n");
68 printf(
"Succeeded to ping\n");
69 printf(
"id : %d, model_number : %d\n", dxl_id, model_number);
72 result = dxl_wb.
changeID(dxl_id, new_dxl_id, &log);
83 uint8_t scanned_id[16];
87 printf(
"Wait for scan...\n");
88 result = dxl_wb.
scan(scanned_id, &dxl_cnt, range, &log);
92 printf(
"Failed to scan\n");
96 printf(
"Find %d Dynamixels\n", dxl_cnt);
98 for (
int cnt = 0; cnt < dxl_cnt; cnt++)
99 printf(
"id : %d, model name : %s\n", scanned_id[cnt], dxl_wb.
getModelName(scanned_id[cnt]));
bool changeID(uint8_t id, uint8_t new_id, const char **log=NULL)
bool init(const char *device_name="/dev/ttyUSB0", uint32_t baud_rate=57600, const char **log=NULL)
DynamixelWorkbench dxl_wb
const char * getModelName(uint8_t id, const char **log=NULL)
bool ping(uint8_t id, uint16_t *get_model_number, const char **log=NULL)
bool scan(uint8_t *get_id, uint8_t *get_the_number_of_id, uint8_t range=253, const char **log=NULL)
int main(int argc, char *argv[])