g_Reset.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 baud_rate = 57600;
25  int dxl_id = 1;
26 
27  if (argc < 4)
28  {
29  printf("Please set '-port_name', '-baud_rate', '-dynamixel id' arguments for connected Dynamixels\n");
30  return 0;
31  }
32  else
33  {
34  port_name = argv[1];
35  baud_rate = atoi(argv[2]);
36  dxl_id = atoi(argv[3]);
37  }
38 
40 
41  const char *log;
42  bool result = false;
43 
44  uint16_t model_number = 0;
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("Succeed to init(%d)\n", baud_rate);
56 
57  result = dxl_wb.ping(dxl_id, &model_number, &log);
58  if (result == false)
59  {
60  printf("%s\n", log);
61  printf("Failed to ping\n");
62  }
63  else
64  {
65  printf("Succeed to ping\n");
66  printf("id : %d, model_number : %d\n", dxl_id, model_number);
67  }
68 
69  result = dxl_wb.reset(dxl_id, &log);
70  if (result == false)
71  {
72  printf("%s\n", log);
73  printf("Failed to reset\n");
74  }
75  else
76  {
77  printf("Succeed to reset\n");
78  }
79 
80  return 0;
81 }
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 reset(uint8_t id, const char **log=NULL)
bool ping(uint8_t id, uint16_t *get_model_number, const char **log=NULL)
int main(int argc, char *argv[])
Definition: g_Reset.cpp:21


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