Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

gazebo_system.cpp crashes when trying to change multiple joint's PID values #48

@cco-seasony

Description

@cco-seasony

Hi,

I am trying to test the simulated RRBOT robot without moveit! and I am facing some issues when trying to adjust the PID paremeters through the xacro file. As a disclaimer, I followed the documentation provided with the difference of having a 2 DOF robot instead of using the slider_to_cart (which I tested and it works fine).

I believe everything is set up correctly including having only one joint per transmission. I can indeed adjust the PID parameters for the first joint but it fails when trying to declare the parameters inside of the gazebo_system.cpp.
More specifically I am working in the branch ahcorde/update/foxy created by @ahcorde .

On https://github.com/ros-simulation/gazebo_ros2_control/blob/7334f06cb849cc49b222f9ce674c8bbd87a7ab28/gazebo_ros2_control/src/gazebo_system.cpp I can see that the DOF, transmissions and the names of the joints are correctly retrieved from the .xacro file that I am using.

On line 61, when the iterator j is equal to 0 it will declare the PID parameters and initialize the PID for that joint. That works. Then when j is equal to 1, an exception rises. More specifically I believe that it crashes on line 180

A quick test that I did to avoid the issue was to comment out line 164, line 165, line 166, line 167, line 168, line 169 and instead declaring the PID parameters in a different loop just before line 61.
Something like this:

  for (unsigned int k = 0; k < this->n_dof_; k++) {
    nh_->declare_parameter(transmissions[k].joints[0].name + ".p");
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
    nh_->declare_parameter(transmissions[k].joints[0].name + ".i");
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
    nh_->declare_parameter(transmissions[k].joints[0].name + ".d");
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
    nh_->declare_parameter(transmissions[k].joints[0].name + ".i_clamp_max");
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
    nh_->declare_parameter(transmissions[k].joints[0].name + ".i_clamp_min");
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
    nh_->declare_parameter(transmissions[k].joints[0].name + ".antiwindup", false);
    RCLCPP_WARN_STREAM(nh_->get_logger(),"--------------" << k);
  }

Of course this is not the most efficient way but it does the job of initializing the PIDs for both joints. I am not sure if the problem is coming from the control_toolbox package or something related to gazebo_ros2_control.

Anyone going through a similar issue?

Thanks in advance for the help.

Kind regards,
Carlos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions