@@ -678,9 +678,8 @@ MujocoSystemInterface::~MujocoSystemInterface()
678678}
679679
680680hardware_interface::CallbackReturn
681- // after humble switches from HardwareInfo to HardwareComponentInterfaceParams. This keeps it backwards compatible
682- // between the two distros
683- #if ROS_DISTRO_HUMBLE
681+ // Humble and Jazzy use on_init(HardwareInfo&); Rolling/Kilted use HardwareComponentInterfaceParams.
682+ #if USE_OLD_ON_INIT_API
684683MujocoSystemInterface::on_init (const hardware_interface::HardwareInfo& params)
685684#else
686685MujocoSystemInterface::on_init (const hardware_interface::HardwareComponentInterfaceParams& params)
@@ -1696,12 +1695,18 @@ bool MujocoSystemInterface::register_mujoco_actuators()
16961695
16971696 // Initialize PID controllers for actuators that have them configured
16981697 const auto initialize_position_pids = [&]() -> bool {
1699- // after humble has an additional argument in the PidROS constructor, and uses a different function to initialize from parameters
1698+ // Humble: 3-arg PidROS ctor + old method names; Jazzy: 3-arg ctor + new method names;
1699+ // Rolling/Kilted: 4-arg ctor + new method names
17001700#if ROS_DISTRO_HUMBLE
17011701 actuator_data.pos_pid = std::make_shared<control_toolbox::PidROS>(
17021702 get_node (), " pid_gains.position." + actuator_data.joint_name , false );
17031703 actuator_data.pos_pid ->initPid ();
17041704 const auto gains = actuator_data.pos_pid ->getGains ();
1705+ #elif ROS_DISTRO_JAZZY
1706+ actuator_data.pos_pid = std::make_shared<control_toolbox::PidROS>(
1707+ get_node (), " pid_gains.position." + actuator_data.joint_name , false );
1708+ actuator_data.pos_pid ->initialize_from_ros_parameters ();
1709+ const auto gains = actuator_data.pos_pid ->get_gains ();
17051710#else
17061711 actuator_data.pos_pid = std::make_shared<control_toolbox::PidROS>(
17071712 get_node (), " pid_gains.position." + actuator_data.joint_name , " " , false );
@@ -1712,12 +1717,18 @@ bool MujocoSystemInterface::register_mujoco_actuators()
17121717 };
17131718
17141719 const auto initialize_velocity_pids = [&]() -> bool {
1715- // after humble has an additional argument in the PidROS constructor, and uses a different function to initialize from parameters
1720+ // Humble: 3-arg PidROS ctor + old method names; Jazzy: 3-arg ctor + new method names;
1721+ // Rolling/Kilted: 4-arg ctor + new method names
17161722#if ROS_DISTRO_HUMBLE
17171723 actuator_data.vel_pid = std::make_shared<control_toolbox::PidROS>(
17181724 get_node (), " pid_gains.velocity." + actuator_data.joint_name , false );
17191725 actuator_data.vel_pid ->initPid ();
17201726 const auto gains = actuator_data.pos_pid ->getGains ();
1727+ #elif ROS_DISTRO_JAZZY
1728+ actuator_data.vel_pid = std::make_shared<control_toolbox::PidROS>(
1729+ get_node (), " pid_gains.velocity." + actuator_data.joint_name , false );
1730+ actuator_data.vel_pid ->initialize_from_ros_parameters ();
1731+ const auto gains = actuator_data.vel_pid ->get_gains ();
17211732#else
17221733 actuator_data.vel_pid = std::make_shared<control_toolbox::PidROS>(
17231734 get_node (), " pid_gains.velocity." + actuator_data.joint_name , " " , false );
0 commit comments