@@ -24,7 +24,6 @@ namespace rt_manipulators_cpp {
24
24
// Ref: https://emanual.robotis.com/docs/en/dxl/x/xm430-w350/
25
25
// Ref: https://emanual.robotis.com/docs/en/dxl/x/xm540-w270/
26
26
// Ref: https://emanual.robotis.com/docs/en/dxl/x/xm540-w150/
27
- const double PROTOCOL_VERSION = 2.0 ;
28
27
const int DXL_HOME_POSITION = 2048 ;
29
28
const double TO_RADIANS = (180.0 / 2048.0 ) * M_PI / 180.0 ;
30
29
const double TO_DXL_POS = 1.0 / TO_RADIANS;
@@ -47,7 +46,6 @@ const uint16_t ADDR_OPERATING_MODE = 11;
47
46
const uint16_t ADDR_CURRENT_LIMIT = 38 ;
48
47
const uint16_t ADDR_MAX_POSITION_LIMIT = 48 ;
49
48
const uint16_t ADDR_MIN_POSITION_LIMIT = 52 ;
50
- const uint16_t ADDR_TORQUE_ENABLE = 64 ;
51
49
const uint16_t ADDR_VELOCITY_I_GAIN = 76 ;
52
50
const uint16_t ADDR_VELOCITY_P_GAIN = 78 ;
53
51
const uint16_t ADDR_POSITION_D_GAIN = 80 ;
@@ -194,9 +192,11 @@ void Hardware::disconnect() {
194
192
}
195
193
196
194
bool Hardware::torque_on (const std::string& group_name) {
197
- if (!write_byte_data_to_group (group_name, ADDR_TORQUE_ENABLE, 1 )) {
198
- std::cerr << group_name << " グループのトルクONに失敗しました." << std::endl;
199
- return false ;
195
+ for (const auto & joint_name : joints_.group (group_name)->joint_names ()) {
196
+ if (!joints_.joint (joint_name)->dxl ->write_torque_enable (comm_, true )) {
197
+ std::cerr << joint_name << " ジョイントのトルクONに失敗しました." << std::endl;
198
+ return false ;
199
+ }
200
200
}
201
201
202
202
// 安全のため、サーボの現在角度を目標角度に設定する
@@ -212,7 +212,14 @@ bool Hardware::torque_on(const std::string& group_name) {
212
212
}
213
213
214
214
bool Hardware::torque_off (const std::string& group_name) {
215
- return write_byte_data_to_group (group_name, ADDR_TORQUE_ENABLE, 0 );
215
+ bool retval = true ;
216
+ for (const auto & joint_name : joints_.group (group_name)->joint_names ()) {
217
+ if (!joints_.joint (joint_name)->dxl ->write_torque_enable (comm_, false )) {
218
+ std::cerr << joint_name << " ジョイントのトルクOFFに失敗しました." << std::endl;
219
+ retval = false ;
220
+ }
221
+ }
222
+ return retval;
216
223
}
217
224
218
225
bool Hardware::sync_read (const std::string& group_name) {
@@ -709,23 +716,6 @@ bool Hardware::write_velocity_pi_gain_to_group(const std::string& group_name, co
709
716
return true ;
710
717
}
711
718
712
- bool Hardware::write_byte_data_to_group (const std::string& group_name, const uint16_t address,
713
- const uint8_t write_data) {
714
- if (!joints_.has_group (group_name)) {
715
- std::cerr << group_name << " はjoint_groupsに存在しません." << std::endl;
716
- return false ;
717
- }
718
-
719
- bool retval = true ;
720
- for (const auto & joint_name : joints_.group (group_name)->joint_names ()) {
721
- auto id = joints_.joint (joint_name)->id ();
722
- if (!comm_->write_byte_data (id, address, write_data)) {
723
- retval = false ;
724
- }
725
- }
726
- return retval;
727
- }
728
-
729
719
bool Hardware::write_word_data_to_group (const std::string& group_name, const uint16_t address,
730
720
const uint16_t write_data) {
731
721
if (!joints_.has_group (group_name)) {
0 commit comments