Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller manager update_rate is wrongly limited by gazebo's simulation rate #476

Open
tonynajjar opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@tonynajjar
Copy link
Contributor

Describe the bug

The controller manager update_rate seems to be wrongly limited by gazebo's simulation rate

To Reproduce
Steps to reproduce the behavior:

I have a world with 60Hz update_rate and RTF 1.0 which is reached:

    <physics name="1ms" type="ode">
      <max_step_size>0.01666666</max_step_size>
      <real_time_factor>1.0</real_time_factor>
    </physics>

My controller_manager has an update_rate of 50 Hz:

/**:
  controller_manager:
    ros__parameters:
      update_rate: 50 # Hz

Expected behavior

I expect the controller manager to run at 50Hz, however the diagnostics complain that only 30Hz is reached.

If I change max_step_size to 0.01 (100Hz) then the CM is able to reach the 50Hz

Screenshots

image

Environment (please complete the following information):

  • OS: Ubuntu Noble
  • Version Jazzy

Additional context
Add any other context about the problem here, especially include any modifications to ros2_control that relate to this issue.

@tonynajjar tonynajjar added the bug Something isn't working label Jan 7, 2025
@christophfroehlich
Copy link
Contributor

Isn't this an issue that your update rates don't have a common integer divider? The controller_manager update is only triggered with the update rate of gz

// Get the simulation time and period
rclcpp::Time sim_time_ros(std::chrono::duration_cast<std::chrono::nanoseconds>(
_info.simTime).count(), RCL_ROS_TIME);
rclcpp::Duration sim_period = sim_time_ros - this->dataPtr->last_update_sim_time_ros_;
if (sim_period >= this->dataPtr->control_period_) {
this->dataPtr->last_update_sim_time_ros_ = sim_time_ros;
auto gz_controller_manager =
std::dynamic_pointer_cast<gz_ros2_control::GazeboSimSystemInterface>(
this->dataPtr->controller_manager_);
this->dataPtr->controller_manager_->read(sim_time_ros, sim_period);
this->dataPtr->controller_manager_->update(sim_time_ros, sim_period);
}

@saikishor
Copy link
Member

@tonynajjar I believe the max step should be a common divisor factor higher than the CM loop rate to be able to have proper simulation. For instance, a CM update rate of 100 Hz might need a step time of 0.005 or lower by the possible common factor. If not, you might observe some loop skipping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants