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

New ros_gz_interface_demos package #705

Open
wants to merge 14 commits into
base: ros2
Choose a base branch
from

Conversation

khaledgabr77
Copy link

@khaledgabr77 khaledgabr77 commented Mar 16, 2025

🎉 New feature

Summary

This PR adds a new package ros_gz_interface_demos which provides utilities for managing Gazebo entities through ROS 2. The package includes three primary functionalities:

  1. spawn_entity: Creates new entities in Gazebo simulations
  2. set_entity_pose: Modifies the position and orientation of existing entities
  3. delete_entity: Removes entities from simulations

These utilities provide a complete solution for programmatically manipulating simulation entities, which is useful for testing, creating dynamic environments, and integrating with other ROS 2 systems.

Test it

Note: This PR depends on #380. Please ensure that PR has been merged before testing this functionality.
To test this new feature:

  1. Build the package:

    colcon build --packages-select ros_gz_interface_demos
    source install/setup.bash
  2. Launch Gazebo:

    gz sim ~/ros_gz_ws/src/ros_gz/ros_gz_interface_demos/worlds/default.sdf
  3. Run the ROS-Gazebo bridge for entity creation:

       ros2 run ros_gz_bridge parameter_bridge /world/default/create@ros_gz_interfaces/srv/SpawnEntity
  4. Spawn an entity:

     ros2 run ros_gz_interface_demos spawn_entity --name box --sdf_filename $(ros2 pkg prefix 
     ros_gz_interface_demos)/share/ros_gz_interface_demos/models/cardboard_box/model.sdf
  5. Similarly, you can test set_entity_pose and delete_entity with their respective bridge services.

Checklist

  • Signed all commits for DCO
  • Added tests
  • 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: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
…ables

Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
@khaledgabr77 khaledgabr77 force-pushed the ros_gz_entity_manager branch from 1dc6fe3 to 5f4b4fd Compare March 16, 2025 22:20
Copy link
Collaborator

@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.

Thank you for openning the PR, I have some comments. Feel free to ask any questions.

Linters are failing https://github.com/gazebosim/ros_gz/actions/runs/13887944210/job/38874261436?pr=705

cmake_minimum_required(VERSION 3.8)
project(ros_gz_interface_demos)

# Default to C++14
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
# Default to C++14
# Default to C++17


# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
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
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.8)
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
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.20)

Comment on lines 14 to 18
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(ros_gz_interfaces REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetical order

Comment on lines 25 to 28
rclcpp
ros_gz_interfaces
geometry_msgs
builtin_interfaces
Copy link
Collaborator

Choose a reason for hiding this comment

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

alphabetical order

<name>ros_gz_interface_demos</name>
<version>0.1.0</version>
<description>C++ package for managing Gazebo entities through ROS 2</description>
<maintainer email="khaledgabr77@email.com">Khaled Gabr</maintainer>
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can add the tag <author> and please add me as a mantainer too

Suggested change
<maintainer email="khaledgabr77@email.com">Khaled Gabr</maintainer>
<maintainer email="khaledgabr77@email.com">Khaled Gabr</maintainer>
<maintainer email="alejandro@openrobotics.org">Alejandro Hernandez</maintainer>
<author email="khaledgabr77@email.com">Khaled Gabr</author>

@@ -0,0 +1,145 @@
#include <memory>
Copy link
Collaborator

Choose a reason for hiding this comment

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

add License

return 1;
}

// Parse command line arguments
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are parsing cmd manually, maybe you want to check or use cli11 https://github.com/ros/rosdistro/blob/master/rosdep/base.yaml#L614, it's already available in rosdistro.

Same in other executables

@@ -0,0 +1,251 @@
#include <memory>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add License

@khaledgabr77 khaledgabr77 requested a review from ahcorde March 20, 2025 22:29
@j-rivero j-rivero changed the title ros gz entity manager New ros_gz_interface_demos package Mar 21, 2025
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
Signed-off-by: khaledgabr77 <khaledgabr77@gmail.com>
@khaledgabr77 khaledgabr77 force-pushed the ros_gz_entity_manager branch from 53206ed to 55c3f2c Compare March 21, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants