@@ -82,6 +82,15 @@ CallbackReturn DynamixelHardware::on_init(
8282 return CallbackReturn::SUCCESS ;
8383 }
8484
85+ if (
86+ info_.hardware_parameters .find (" enable_torque" ) != info_.hardware_parameters .end () &&
87+ info_.hardware_parameters .at (" enable_torque" ) == " false" )
88+ {
89+ should_enable_torque_ = false ;
90+ } else {
91+ should_enable_torque_ = true ;
92+ }
93+
8594 auto usb_port = info_.hardware_parameters .at (" usb_port" );
8695 auto baud_rate = std::stoi (info_.hardware_parameters .at (" baud_rate" ));
8796 const char * log = nullptr ;
@@ -105,7 +114,9 @@ CallbackReturn DynamixelHardware::on_init(
105114 enable_torque (false );
106115 set_control_mode (ControlMode::Position, true );
107116 set_joint_params ();
108- enable_torque (true );
117+ if (should_enable_torque_) {
118+ enable_torque (true );
119+ }
109120
110121 const ControlItem * goal_position =
111122 dynamixel_workbench_.getItemInfo (joint_ids_[0 ], kGoalPositionItem );
@@ -411,7 +422,7 @@ return_type DynamixelHardware::set_control_mode(const ControlMode & mode, const
411422 control_mode_ = ControlMode::Velocity;
412423 }
413424
414- if (torque_enabled) {
425+ if (torque_enabled && should_enable_torque_ ) {
415426 enable_torque (true );
416427 }
417428 return return_type::OK ;
@@ -435,7 +446,7 @@ return_type DynamixelHardware::set_control_mode(const ControlMode & mode, const
435446 control_mode_ = ControlMode::Position;
436447 }
437448
438- if (torque_enabled) {
449+ if (torque_enabled && should_enable_torque_ ) {
439450 enable_torque (true );
440451 }
441452 return return_type::OK ;
0 commit comments