Skip to content

New system plugin called DriveToPoseController #2679

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

Merged
merged 18 commits into from
Feb 19, 2025

Conversation

sauk2
Copy link
Contributor

@sauk2 sauk2 commented Nov 17, 2024

🎉 New feature

Closes #2379

Summary

This PR adds a new system plugin to gz-sim called DriveToPoseController. This is not a standalone plugin and requires other systems plugins (DiffDrive and OdometryPublisher) to function.

This controller receives a target pose in the Gazebo coordinate system on /cmd_pose topic and calculates and publishes a command velocity on /cmd_vel topic to move the robot towards the target. This plugin contains separate linear and angular proportional controllers with adjustable gains. The user can also specify an allowable deviation from the goal pose in the form of linear and angular deviations. Upon reaching the goal pose, the controller publishes an acknowledgement on /reached_pose topic to indicate the end of the navigation operation.

The plugin needs to be attached to a model entity as in the SDF as follows,

    <model>
        <!-- Model information --> 
 
        <!-- Required to define DiffDrive and OdometryPublisher -->

        <!-- DriveToPoseController --> 
        <plugin
          filename="gz-sim-drive-to-pose-controller-system"
          name="gz::sim::systems::DriveToPoseController">
          <linear_p_gain>1.0</linear_p_gain>
          <angular_p_gain>2.0</angular_p_gain>
          <linear_deviation>0.1</linear_deviation>
          <angular_deviation>0.05</angular_deviation>
        </plugin>
    </model>

It has the following parameter tags,

  • <linear_p_gain> - (Optional) Proportional gain for the linear velocity controller. Default: 1.0
  • <angular_p_gain> - (Optional) Proportional gain for the angular velocity controller. Default: 2.0
  • <linear_deviation> - (Optional) Allowable linear deviation (in meters) from the desired coordinate. Default: 0.1
  • <angular_deviation> - (Optional) Allowable angular deviation (in radians) from the desired orientation. Default: 0.05

The following example warehouse world can be found at src/gz-sim/examples/worlds/drive_to_pose_controller.sdf with an AMR spawned at its start position.

image

image

Test it

The integration test for this plugin can be run using the following command,

  colcon test --event-handlers console_direct+ --merge-install \
    --packages-select gz-sim9 --ctest-args -R drive_to_pose_controller

Use the following steps to test the functionality in the warehouse world by sending the robot to four different poses,

  1. Launch the following world,
  gz sim drive_to_pose_controller.sdf

NOTE: The world opens in a paused state so make sure to unpause before sending the pose commands

  1. Send the robot to the first pose in the warehouse, [x, y, orientation] = [1.78, -9.4, -3.14]
  gz topic -t "/model/DeliveryBot/cmd_pose" -m gz.msgs.Pose_V \
    -p "pose:[{position: {x: 1.78, y: -9.4, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: -0.99, w: 0.0}}]"
  1. Send the robot to the second pose, [x, y, orientation] = [-3.75, -9.4, 1.57]
  gz topic -t "/model/DeliveryBot/cmd_pose" -m gz.msgs.Pose_V \
    -p "pose:[{position: {x: -3.75, y: -9.4, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.707, w: 0.707}}]"
  1. Send the robot to its third pose, [x, y, orientation] = [-3.75, 9.18, 3.14]
  gz topic -t "/model/DeliveryBot/cmd_pose" -m gz.msgs.Pose_V \
    -p "pose:[{position: {x: -3.75, y: 9.18, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.99, w: 0.0}}]"
  1. Send the robot to its final pose, [x, y, orientation] = [-5.9, 9.18, 3.14]
  gz topic -t "/model/DeliveryBot/cmd_pose" -m gz.msgs.Pose_V \
    -p "pose:[{position: {x: -5.9, y: 9.18, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.99, w: 0.0}}]"

The entire operation is shown in the following video,

drive_to_pose_controller_test.mp4

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Saurabh Kamat <[email protected]>
Signed-off-by: Saurabh Kamat <[email protected]>
Signed-off-by: Saurabh Kamat <[email protected]>
Signed-off-by: Saurabh Kamat <[email protected]>
Signed-off-by: Saurabh Kamat <[email protected]>
Signed-off-by: Saurabh Kamat <[email protected]>
@sauk2 sauk2 requested a review from mjcarroll as a code owner November 17, 2024 09:39
@github-actions github-actions bot added 🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty labels Nov 17, 2024
Signed-off-by: Saurabh Kamat <[email protected]>
Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Here is some feedback.

topicNamespace + "/cmd_pose", &DriveToPoseControllerPrivate::OnCmdPose,
this->dataPtr.get());

this->dataPtr->node.Subscribe(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing for subscribers, we can detect if there are publishers. If no publishers inform the user that we need to load the correct set of plugins. (We could also automatically load them if that is something you are willing to look into).

Copy link
Contributor Author

@sauk2 sauk2 Nov 21, 2024

Choose a reason for hiding this comment

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

@arjo129 Thanks for all the feedback! It makes perfect sense to warn users if no publishers or subscribers are found. I have made the changes to check for the availability of necessary publishers and subscribers and warn users to load the required plugins.

However, I agree it would be a good idea to load the plugins ourselves if they are found to be missing, and I would be happy to implement this. If you have any references for this that would be great help. Also, do you want this change to be a part of this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Of the top of my head there is a service to load plugins:

Since the system is running inside the server it may be worth exposing an API for doing this via the ECS instead of relying on gz-transport for later.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sauk2 can you create an issue to add this functionality in follow up PRs.

Since the system is running inside the server it may be worth exposing an API for doing this via the ECS instead of relying on gz-transport for later.

Yes, we currently have the possibility to load plugins with the LoadSdfPlugins event (

using LoadSdfPlugins = common::EventT<void(Entity, sdf::Plugins),
) but I don't think we have an API for introspecting what plugins are currently available.

Ideally, we would create a new component that holds the list of plugins attached to an entity. Or, maybe better would be to create entities for each plugin and use the ParentEntity component to point to the entity they're attached to. The latter would be my preference.

Copy link
Contributor Author

@sauk2 sauk2 Feb 13, 2025

Choose a reason for hiding this comment

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

Created a new issue (#2773) for this discussion.

@sauk2 sauk2 requested review from ahcorde and arjo129 November 21, 2024 11:29
Signed-off-by: Saurabh Kamat <[email protected]>
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Some minor changes, otherwise look good to me

@sauk2
Copy link
Contributor Author

sauk2 commented Dec 17, 2024

Some minor changes, otherwise look good to me

Thank you for the feedback! I have made the requested changes.

@sauk2 sauk2 requested a review from ahcorde December 17, 2024 13:37
@azeey
Copy link
Contributor

azeey commented Jan 7, 2025

@ahcorde , @arjo129 mind taking another look?

@azeey
Copy link
Contributor

azeey commented Jan 8, 2025

Tests are failing on windows because DART is missing in our windows CI.
Test Result (4 failures / +4)

Can you disable these tests on windows?

@j-rivero
Copy link
Contributor

Can you disable these tests on windows?

Time has passed we back to have DART for Windows. I have reverted the commit in a local branch here and launched a new Windows PR test: Build Status

@j-rivero
Copy link
Contributor

Time has passed we back to have DART for Windows. I have reverted the commit in a local branch here and launched a new Windows PR test: Build Status

Passed !

109: (2025-02-12 18:50:33.733) [info] [SceneBroadcaster.cc:711] Publishing dynamic pose messages on [/world/drive_to_pose_controller/dynamic_pose/info]
109: (2025-02-12 18:50:34.269) [debug] [SimulationRunner.cc:569] Exiting postupdate worker thread (0)
109: (2025-02-12 18:50:34.269) [debug] [SimulationRunner.cc:569] Exiting postupdate worker thread (4)
109: (2025-02-12 18:50:34.269) [debug] [SimulationRunner.cc:569] Exiting postupdate worker thread (1)
109: (2025-02-12 18:50:34.269) [debug] [SimulationRunner.cc:569] Exiting postupdate worker thread (3)
109: (2025-02-12 18:50:34.269) [debug] [SimulationRunner.cc:569] Exiting postupdate worker thread (2)
109: [       OK ] DriveToPoseControllerTest.XYCoordinateYawPublish (759 ms)
109: [----------] 5 tests from DriveToPoseControllerTest (5687 ms total)
109: 
109: [----------] Global test environment tear-down
109: [==========] 5 tests from 1 test suite ran. (5687 ms total)
109: [  PASSED  ] 5 tests.
109/252 Test #109: INTEGRATION_drive_to_pose_controller_system ............   Passed    5.79 sec

@sauk2 could you revert a0901ee ?

@sauk2
Copy link
Contributor Author

sauk2 commented Feb 13, 2025

@sauk2 could you revert a0901ee ?

@j-rivero Thank you for the update! I have reverted that commit

Copy link
Contributor

@j-rivero j-rivero left a comment

Choose a reason for hiding this comment

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

Confirmed that it works as expected ! Congrats @sauk2

We need to find some ways to give this a bit of publicity. Some ideas:

@j-rivero j-rivero merged commit 54830b9 into gazebosim:gz-sim9 Feb 19, 2025
11 checks passed
@sauk2 sauk2 deleted the drive-to-pose-controller branch February 24, 2025 13:56
@sauk2
Copy link
Contributor Author

sauk2 commented Feb 24, 2025

Confirmed that it works as expected ! Congrats @sauk2

We need to find some ways to give this a bit of publicity. Some ideas:

Thanks Jose, for testing it out. I will work on contributing a tutorial soon!

@elmeripk
Copy link

elmeripk commented Jun 5, 2025

Will this be ported to Harmonic at some point? This would provide a nice alternative to nav2 in simple use cases/demos.

@j-rivero
Copy link
Contributor

j-rivero commented Jun 5, 2025

Will this be ported to Harmonic at some point? This would provide a nice alternative to nav2 in simple use cases/demos.

@Mergifyio backport gz-sim8

It was a really nice contribution indeed!

j-rivero pushed a commit that referenced this pull request Jun 6, 2025
New system plugin to gz-sim called DriveToPoseController:

This controller receives a target pose in the Gazebo coordinate system on /cmd_pose topic and calculates and publishes a command velocity on /cmd_vel topic to move the robot towards the target. 
---------

Signed-off-by: Saurabh Kamat <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]>
@j-rivero
Copy link
Contributor

j-rivero commented Jun 6, 2025

@Mergifyio backport gz-sim8

Stupid bot.

@elmeripk could you please check if #2939 works for you on Harmonic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: Highlights
Development

Successfully merging this pull request may close these issues.

[Proposal] Drive to point/configuration controller plugin for wheeled vehicles
6 participants