-
Notifications
You must be signed in to change notification settings - Fork 148
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
Bridge as a gz sim system #501
Conversation
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
ros_gz_sim/CMakeLists.txt
Outdated
@@ -12,6 +12,8 @@ endif() | |||
|
|||
find_package(ament_cmake REQUIRED) | |||
find_package(rclcpp REQUIRED) | |||
find_package(rclcpp_components REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to include this dependency, with rclcpp should be enough, you are not adding any component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I don't add it, the code doesn't compile. Maybe a dependency isn't exporting it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we determined that ros_gz_bridge isn't correctly exporting the dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
ros_gz_sim/src/ros_gz.cpp
Outdated
} | ||
|
||
// Sanity check: Make sure that the config file exists and it's a file. | ||
std::filesystem::path configFile = _sdf->Get<std::string>("config_file"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <filesystem>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was already there :)
ros_gz_sim/src/ros_gz.cpp
Outdated
// Sanity check: Make sure that the config file exists and it's a file. | ||
std::filesystem::path configFile = _sdf->Get<std::string>("config_file"); | ||
if (!std::filesystem::is_regular_file(configFile)) { | ||
std::cerr << "[" << configFile << "] is not a regular file. Plugin disabled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <iostream>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gz::sim::EventManager & _eventMgr) override; | ||
|
||
|
||
/// \brief Private data pointer. | ||
std::unique_ptr<ROSGzPluginPrivate> dataPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gz::sim::EventManager & _eventMgr) override; | |
/// \brief Private data pointer. | |
std::unique_ptr<ROSGzPluginPrivate> dataPtr; | |
gz::sim::EventManager & _eventMgr) override; | |
/// \brief Private data pointer. | |
std::unique_ptr<ROSGzPluginPrivate> dataPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
ros_gz_image/CMakeLists.txt
Outdated
@@ -14,6 +14,7 @@ find_package(ament_cmake REQUIRED) | |||
find_package(image_transport REQUIRED) | |||
find_package(ros_gz_bridge REQUIRED) | |||
find_package(rclcpp REQUIRED) | |||
find_package(rclcpp_components REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR should fix this issue #501
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Signed-off-by: Carlos Agüero <[email protected]>
Ah sorry, there was a bad merge there. Thanks for fixing that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I have a few comments that I think will make this more consistent with the ROS ecosystem as well as existing naming schemes in Gazebo.
One question I have is how this deals with models spawned at runtime. Would the user be able to add another bridge system as part of the model?
filename="ignition-gazebo-physics-system" | ||
name="gz::sim::systems::Physics"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-user-commands-system" | ||
name="gz::sim::systems::UserCommands"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-scene-broadcaster-system" | ||
name="gz::sim::systems::SceneBroadcaster"> | ||
</plugin> | ||
<plugin | ||
filename="ignition-gazebo-contact-system" | ||
name="gz::sim::systems::Contact"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use gz-sim
instead of ignition-gazebo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in #511
gz_type_name: "ignition.msgs.StringMsg" | ||
subscriber_queue: 5 | ||
publisher_queue: 6 | ||
lazy: true | ||
direction: ROS_TO_GZ | ||
|
||
- ros_topic_name: "ros_chatter" | ||
gz_topic_name: "gz_chatter" | ||
ros_type_name: "std_msgs/msg/String" | ||
gz_type_name: "ignition.msgs.StringMsg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can use gz.msgs
for the gz_type_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in #511.
std::string path = gz::common::findFile(filename); | ||
if (!gz::common::isFile(path)) { | ||
std::cerr << "Unable to open YAML file [" << filename | ||
<< "], check your GAZEBO_RESOURCE_PATH settings." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use GAZEBO_RESOURCE_PATH
? I thought that was for Gazebo-classic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that was a typo. Changed in #511.
<plugin name="ros_gz_sim::ROSGzPlugin" | ||
filename="libROSGzPlugin.so"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to be name=ros_gz_sim::ROSGzBridge
and filename=ros-gz-bridge-system
to have bridge
in the name and to be more consistent with our other systems (eg. we haven't used Plugin
in any of our existing systems). For the filename
, the shared library would need to be libros-gz-bridge-system.so
. In the <plugin>
tag the lib
and .so
can be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in #511.
|
||
// Sanity check: Make sure that the config file exists and it's a file. | ||
std::string filename = _sdf->Get<std::string>("config_file"); | ||
std::string path = gz::common::findFile(filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use package://
URIs for the file name since this is all happening in the ROS ecosystem. Then, instead of calling gz::common::findFile
, we can pass the file directly to RosGzBridge
(so no need to call findFile
here) and update RosGzBridge
so it can use resource_retriever
to find the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource_retriever
is functional but the API is slightly different because as far as I know it can't resolve the path only. Instead, it resolves the path and read the content of the file, returning it as a byte array.
However I figured that we still can use the package://
approach. I guess findFile()
is solving it for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the API is different. That's why I was suggesting to pass the filename directly to RosGzBridge
and use resource_retriever
there where we are currently opening the file:
ros_gz/ros_gz_bridge/src/bridge_config.cpp
Line 176 in ef9cd5c
std::ifstream in(filename); |
I don't know how common::findFile
is handling package://
. My guess is it ignores the package://
part and tries to find the path based on Gazebo environment variables, which is not what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case I can tackle it in a separate PR as it affects mainly ros_gz_bridge
. I already played with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with #511 targeting ROS 2 rolling. |
🎉 New feature
Summary
This PR runs the ROS<->Gz bridge as a gz sim system.
Test it
Verify the output to confirm that two topics are bridged:
Then, you should see a ROS topic
/ros_chatter
:Checklist
codecheck
passed (See contributing)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.