@@ -1092,7 +1092,7 @@ void MujocoSystemInterface::register_joints(const hardware_interface::HardwareIn
10921092 last_joint_state.actuator_type == ActuatorType::CUSTOM)
10931093 {
10941094 last_joint_state.pos_pid =
1095- std::make_shared<control_toolbox::PidROS>(mujoco_node_, " pid_gains.position." + joint.name , " " );
1095+ std::make_shared<control_toolbox::PidROS>(mujoco_node_, " pid_gains.position." + joint.name , " " , false );
10961096 last_joint_state.pos_pid ->initialize_from_ros_parameters ();
10971097 const auto gains = last_joint_state.pos_pid ->get_gains ();
10981098 last_joint_state.has_pos_pid =
@@ -1127,12 +1127,6 @@ void MujocoSystemInterface::register_joints(const hardware_interface::HardwareIn
11271127 }
11281128 else if (command_if.name .find (hardware_interface::HW_IF_VELOCITY) != std::string::npos)
11291129 {
1130- last_joint_state.vel_pid =
1131- std::make_shared<control_toolbox::PidROS>(mujoco_node_, " pid_gains.velocity." + joint.name , " " );
1132- last_joint_state.vel_pid ->initialize_from_ros_parameters ();
1133- const auto gains = last_joint_state.vel_pid ->get_gains ();
1134- last_joint_state.has_vel_pid =
1135- std::isfinite (gains.p_gain_ ) && std::isfinite (gains.i_gain_ ) && std::isfinite (gains.d_gain_ );
11361130 if (last_joint_state.actuator_type == ActuatorType::POSITION)
11371131 {
11381132 RCLCPP_ERROR (rclcpp::get_logger (" MujocoSystemInterface" ),
@@ -1145,27 +1139,36 @@ void MujocoSystemInterface::register_joints(const hardware_interface::HardwareIn
11451139 last_joint_state.is_velocity_control_enabled = true ;
11461140 last_joint_state.velocity_command = last_joint_state.velocity ;
11471141 }
1148- else if ((last_joint_state.actuator_type == ActuatorType::MOTOR ||
1149- last_joint_state.actuator_type == ActuatorType::CUSTOM) &&
1150- last_joint_state.has_vel_pid )
1142+ else if (last_joint_state.actuator_type == ActuatorType::MOTOR ||
1143+ last_joint_state.actuator_type == ActuatorType::CUSTOM)
11511144 {
1152- last_joint_state.is_velocity_pid_control_enabled = true ;
1145+ last_joint_state.vel_pid =
1146+ std::make_shared<control_toolbox::PidROS>(mujoco_node_, " pid_gains.velocity." + joint.name , " " , false );
1147+ last_joint_state.vel_pid ->initialize_from_ros_parameters ();
11531148 const auto gains = last_joint_state.vel_pid ->get_gains ();
1154- last_joint_state.velocity_command = last_joint_state.velocity ;
1155- RCLCPP_INFO (rclcpp::get_logger (" MujocoSystemInterface" ),
1156- " Velocity control PID gains for joint %s : P=%.4f, I=%.4f, D=%.4f, Imax=%.4f, Imin=%.4f, "
1157- " Umin=%.4f, Umax=%.4f, antiwindup_strategy=%s" ,
1158- joint.name .c_str (), gains.p_gain_ , gains.i_gain_ , gains.d_gain_ , gains.antiwindup_strat_ .i_max ,
1159- gains.antiwindup_strat_ .i_min , gains.u_min_ , gains.u_max_ ,
1160- gains.antiwindup_strat_ .to_string ().c_str ());
1161- }
1162- else
1163- {
1164- RCLCPP_ERROR (rclcpp::get_logger (" MujocoSystemInterface" ),
1165- " Velocity command interface for the joint : %s is not supported with motor or custom actuator "
1166- " without defining the PIDs" ,
1167- joint.name .c_str ());
1168- continue ;
1149+ last_joint_state.has_vel_pid =
1150+ std::isfinite (gains.p_gain_ ) && std::isfinite (gains.i_gain_ ) && std::isfinite (gains.d_gain_ );
1151+
1152+ if (last_joint_state.has_vel_pid )
1153+ {
1154+ last_joint_state.is_velocity_pid_control_enabled = true ;
1155+ const auto gains = last_joint_state.vel_pid ->get_gains ();
1156+ last_joint_state.velocity_command = last_joint_state.velocity ;
1157+ RCLCPP_INFO (rclcpp::get_logger (" MujocoSystemInterface" ),
1158+ " Velocity control PID gains for joint %s : P=%.4f, I=%.4f, D=%.4f, Imax=%.4f, Imin=%.4f, "
1159+ " Umin=%.4f, Umax=%.4f, antiwindup_strategy=%s" ,
1160+ joint.name .c_str (), gains.p_gain_ , gains.i_gain_ , gains.d_gain_ , gains.antiwindup_strat_ .i_max ,
1161+ gains.antiwindup_strat_ .i_min , gains.u_min_ , gains.u_max_ ,
1162+ gains.antiwindup_strat_ .to_string ().c_str ());
1163+ }
1164+ else
1165+ {
1166+ RCLCPP_ERROR (rclcpp::get_logger (" MujocoSystemInterface" ),
1167+ " Velocity command interface for the joint : %s is not supported with motor or custom actuator "
1168+ " without defining the PIDs" ,
1169+ joint.name .c_str ());
1170+ continue ;
1171+ }
11691172 }
11701173 }
11711174 else if (command_if.name .find (hardware_interface::HW_IF_EFFORT) != std::string::npos)
0 commit comments