File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
external/dynamixel-workbench/dynamixel_workbench_controllers/src Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 16
16
17
17
/* Authors: Taehun Lim (Darby) */
18
18
19
+ #include < stdexcept>
20
+ #include < string>
21
+
19
22
#include " dynamixel_workbench_controllers/position_control.h"
20
23
21
24
PositionControl::PositionControl ()
@@ -85,8 +88,28 @@ void PositionControl::initMsg()
85
88
// Setting some placeholder I-D gains now, there are default P gains
86
89
for (int index = 0 ; index < dxl_cnt_; index++)
87
90
{
88
- dxl_wb_->itemWrite (dxl_id_[index], " Position_I_Gain" , 5 );
89
- dxl_wb_->itemWrite (dxl_id_[index], " Position_D_Gain" , 50 );
91
+ bool write_pos_i_gain = dxl_wb_->itemWrite (dxl_id_[index], " Position_I_Gain" , 5 );
92
+ bool write_pos_d_gain = dxl_wb_->itemWrite (dxl_id_[index], " Position_D_Gain" , 50 );
93
+ bool write_drive_mode = dxl_wb_->itemWrite (dxl_id_[index], " Drive_Mode" , 0 );
94
+
95
+ // Assert the values have actually been written
96
+ if (!write_pos_i_gain)
97
+ {
98
+ throw std::runtime_error (std::string (" Could not write register \" Position_I_Gain\" for servo " +
99
+ std::to_string (index)).c_str ());
100
+ }
101
+
102
+ if (!write_pos_d_gain)
103
+ {
104
+ throw std::runtime_error (std::string (" Could not write register \" Position_D_Gain\" for servo " +
105
+ std::to_string (index)).c_str ());
106
+ }
107
+
108
+ if (!write_drive_mode)
109
+ {
110
+ throw std::runtime_error (std::string (" Could not write register \" Drive_Mode\" for servo " +
111
+ std::to_string (index)).c_str ());
112
+ }
90
113
}
91
114
92
115
You can’t perform that action at this time.
0 commit comments