d_BPS_Change.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 ROBOTIS CO., LTD.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
17 /* Authors: Taehun Lim (Darby) */
18 
19 #include <DynamixelWorkbench.h>
20 
21 int main(int argc, char *argv[])
22 {
23  const char* port_name = "/dev/ttyUSB0";
24  int dxl_id = 1;
25  int baud_rate = 57600;
26  int new_baud_rate = 1000000;
27 
28  if (argc < 5)
29  {
30  printf("Please set '-port_name', '-baud_rate', '-dynamixel_id', '-new_baud_rate' arguments for connected Dynamixels\n");
31  return 0;
32  }
33  else
34  {
35  port_name = argv[1];
36  baud_rate = atoi(argv[2]);
37  dxl_id = atoi(argv[3]);
38  new_baud_rate = atoi(argv[4]);
39  }
40 
42 
43  const char *log;
44  bool result = false;
45 
46  result = dxl_wb.init(port_name, baud_rate, &log);
47  if (result == false)
48  {
49  printf("%s\n", log);
50  printf("Failed to init\n");
51 
52  return 0;
53  }
54  else
55  printf("Succeeded to init(%d)\n", baud_rate);
56 
57  uint16_t model_number = 0;
58  result = dxl_wb.ping(dxl_id, &model_number, &log);
59  if (result == false)
60  {
61  printf("%s\n", log);
62  printf("Failed to ping\n");
63 
64  return 0;
65  }
66  else
67  {
68  printf("Succeeded to ping\n");
69  printf("id : %d, model_number : %d\n", dxl_id, model_number);
70  }
71 
72  result = dxl_wb.changeBaudrate(dxl_id, new_baud_rate, &log);
73  if (result == false)
74  {
75  printf("%s\n", log);
76  return 0;
77  }
78  else
79  {
80  printf("%s\n", log);
81  }
82 
83  return 0;
84 }
bool init(const char *device_name="/dev/ttyUSB0", uint32_t baud_rate=57600, const char **log=NULL)
DynamixelWorkbench dxl_wb
Definition: p_Monitor.cpp:40
bool ping(uint8_t id, uint16_t *get_model_number, const char **log=NULL)
int main(int argc, char *argv[])
bool changeBaudrate(uint8_t id, uint32_t new_baudrate, const char **log=NULL)


dynamixel_workbench_toolbox
Author(s): Darby Lim , Ryan Shim
autogenerated on Mon Sep 28 2020 03:37:05