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

Don't spin the executor if the sim is paused #379

Closed
wants to merge 2 commits into from

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Oct 1, 2024

After the refactoring done by ros-controls/ros2_control#1638, the switch_controller service has a working timeout for each controller. This time is hardcoded within the spawner.py to 5s.

If the simulation is started paused, like with

    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']),
                launch_arguments={
                    'pause': 'true'}.items()
             )

then the CM services are started but the update method is not called yet. This leads to running into the timeout

[gzserver-5] [ERROR] [1727713930.188912404] [controller_manager]: Switch controller timed out after 5.000000 seconds!
[spawner-18] [ERROR] [1727713930.190697406] [spawner_joint_state_broadcaster]: Failed to activate controller

The same happens if a running simulation is paused and a service call to the CM is done.

As there is currently no possibility to pause the services in the CM, I see the possibility to just not spin the executor. Otherwise we have to change the API of the CM.

@christophfroehlich
Copy link
Contributor Author

@mergify backport humble iron

Copy link
Contributor

mergify bot commented Oct 1, 2024

backport humble iron

🟠 Waiting for conditions to match

  • merged [📌 backport requirement]

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you for the fix!

@christophfroehlich christophfroehlich marked this pull request as draft October 1, 2024 08:07
@@ -395,7 +395,11 @@ void GazeboRosControlPlugin::Load(gazebo::physics::ModelPtr parent, sdf::Element
auto spin = [this]()
{
while (rclcpp::ok() && !impl_->stop_) {
impl_->executor_->spin_once();
if (impl_->parent_model_->GetWorld()->IsPaused() == false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (impl_->parent_model_->GetWorld()->IsPaused() == false) {
if (!impl_->parent_model_->GetWorld()->IsPaused()) {

@christophfroehlich
Copy link
Contributor Author

This approach does not work with the rolling version of the controller_manager, because it expects the URDF via topic. And one can't press the play button if the configure() method of the plugin is not finished.
I opened #380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants