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

[CM] Use robot_description topic instead of parameter and don't crash on empty URDF 🦿 #940

Merged
merged 13 commits into from
Jun 7, 2023

Conversation

mamueluth
Copy link
Contributor

@mamueluth mamueluth commented Feb 16, 2023

The robot description file is no longer passed to controller manager directly. Instead, if no urdf is passed to controller_manager_node, a subscription on the /robot_description topic is created and urdf is received via callback (needed for my thesis on distributed control).

What has been done:

  • Deprecated passing of robot description file directly to controller manager.
  • Subscribe to robot_state_publisher to get robot_description_file.

Things to consider:

  • Controllers are in "unconfigured" state if robot description file arrives after ControllerManager creates subscription. This way, controller have to be configured and activated by hand.
  • Maybe we should not call init_resource_manager multiple times if we have already received a valid urdf. Should i check this via a flag or if hardware_info_map_ is empty and ignore? Suggestions would be appreciated.

Starting of the concept can be tested with the :

  • ros2 launch ros2_control_demo_bringup empty_robot.launch.py
  • ros2 launch ros2_control_demo_bringup publish_description.launch.py
    in this ros2_control_demos_repo

  • Add tests

Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

I commented about some small changes.

We should also add test for this new functionality. Also with different cases, i.e., publishing description before and later. This is in the core of the framework's functionalities and should be 100% tested.

controller_manager/src/controller_manager.cpp Outdated Show resolved Hide resolved
controller_manager/src/controller_manager.cpp Outdated Show resolved Hide resolved
controller_manager/src/controller_manager.cpp Outdated Show resolved Hide resolved
controller_manager/src/controller_manager.cpp Outdated Show resolved Hide resolved
@bmagyar bmagyar added the iron label Mar 8, 2023
bmagyar
bmagyar previously approved these changes Mar 28, 2023
Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

Can we have tests please?

@codecov-commenter
Copy link

Codecov Report

Merging #940 (c4825b1) into master (925f5f3) will decrease coverage by 1.97%.
The diff coverage is 35.61%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #940      +/-   ##
==========================================
- Coverage   34.61%   32.65%   -1.97%     
==========================================
  Files          52       91      +39     
  Lines        2981     9563    +6582     
  Branches     1855     6441    +4586     
==========================================
+ Hits         1032     3123    +2091     
- Misses        310      716     +406     
- Partials     1639     5724    +4085     
Flag Coverage Δ
unittests 32.65% <35.61%> (-1.97%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
controller_manager/src/controller_manager.cpp 37.81% <ø> (-1.90%) ⬇️
controller_manager/src/ros2_control_node.cpp 0.00% <0.00%> (ø)
..._interface/include/hardware_interface/actuator.hpp 100.00% <ø> (ø)
...re_interface/include/hardware_interface/sensor.hpp 100.00% <ø> (ø)
...re_interface/include/hardware_interface/system.hpp 100.00% <ø> (ø)
hardware_interface/src/resource_manager.cpp 49.91% <ø> (-3.72%) ⬇️
hardware_interface/src/sensor.cpp 50.52% <ø> (ø)
hardware_interface/src/system.cpp 55.45% <ø> (ø)
...rface/test/mock_components/test_generic_system.cpp 9.14% <ø> (ø)
...dware_interface/test/test_component_interfaces.cpp 32.44% <ø> (+4.25%) ⬆️
... and 68 more

... and 19 files with indirect coverage changes

@mamueluth
Copy link
Contributor Author

Can we have tests please?

Added some are those enough?

@destogl destogl changed the title Allow empty urdf [CM] Use robot_description topic instead of parameter and don't crash on empty URDF 🦿 Apr 4, 2023
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

What about controller manager tests?

@mamueluth
Copy link
Contributor Author

Added test for the cm site. Ended up doing a workaround and unfortunately had to make the callback function public. This needs to be addressed in the future but does not seem like a big issue for me at the moment...
First tried to pass the urdf via topic while testing, the way how it's supposed to work later, but this did not work properly. The problem here is how the tests are executed. If the urdf arrives to late then no hardware is found and tests a failing. Waiting and so on didn't work for me.

…lers in test

In tests we have to be sure, that our urdf arrived before continuing
with the actuell tests otherwise they will naturally fail...
@bmagyar
Copy link
Member

bmagyar commented May 28, 2023

@destogl @mamueluth what's the status on this sirs?

@destogl
Copy link
Member

destogl commented May 30, 2023

We didn't mange to get it tested properly yet, and @mamueluth is now finalizing his thesis. I'll check to come to it in the next week or two, since I need this future for a scenario I am working at.

@Noel215
Copy link
Contributor

Noel215 commented Jun 2, 2023

Hi!

I am also interested on this feature!!

I've been testing it on a TIAGo Base and I can get the robot working by using the robot_description from the topic. :)
I only had to cherry-pick the commits to humble (+ solve merge conflicts) and change the subscriber topic from "~/robot_description" to "robot_description".

bmagyar
bmagyar previously approved these changes Jun 7, 2023
Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

Let's get this guy rolling

@bmagyar bmagyar enabled auto-merge (squash) June 7, 2023 11:20
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Now happy!

@destogl destogl disabled auto-merge June 7, 2023 20:50
@destogl destogl merged commit d299208 into ros-controls:master Jun 7, 2023
14 of 16 checks passed
@destogl destogl deleted the allow_empty_urdf branch June 7, 2023 21:12
@Noel215
Copy link
Contributor

Noel215 commented Jun 12, 2023

Could you backport this feature to humble by any chance?

@bmagyar bmagyar added the backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble. label Jun 12, 2023
mergify bot pushed a commit that referenced this pull request Jun 12, 2023
…sh on empty URDF 🦿 (#940)

* on startup wait for robot description, however allow receiving later

---------

Co-authored-by: Dr. Denis <denis@stoglrobotics.de>
(cherry picked from commit d299208)

# Conflicts:
#	controller_manager/CMakeLists.txt
#	controller_manager/src/controller_manager.cpp
#	hardware_interface/doc/mock_components_userdoc.rst
#	hardware_interface/include/hardware_interface/resource_manager.hpp
#	hardware_interface/src/resource_manager.cpp
#	hardware_interface/test/test_resource_manager.cpp
@bmagyar
Copy link
Member

bmagyar commented Jun 12, 2023

Note that this is only the simplest implementation of the feature, it still doesn't allow for updating the URDF on-the-fly and if we agree with my fellow maintainers about adding this to Humble (as it is indeed slightly breaking...) we shouldn't expect anything other than this basic functionality.

@Noel215
Copy link
Contributor

Noel215 commented Jun 12, 2023

I'm aware of that, thanks!! :)

@destogl
Copy link
Member

destogl commented Jun 12, 2023

@Mergifyio backport humble

@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2023

backport humble

✅ Backports have been created

bmagyar pushed a commit that referenced this pull request Aug 14, 2023
…sh on empty URDF 🦿 (#940)

* on startup wait for robot description, however allow receiving later

---------

Co-authored-by: Dr. Denis <denis@stoglrobotics.de>
(cherry picked from commit d299208)

# Conflicts:
#	controller_manager/CMakeLists.txt
#	controller_manager/src/controller_manager.cpp
#	hardware_interface/doc/mock_components_userdoc.rst
#	hardware_interface/include/hardware_interface/resource_manager.hpp
#	hardware_interface/src/resource_manager.cpp
#	hardware_interface/test/test_resource_manager.cpp
bmagyar pushed a commit that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble. iron
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants