Skip to content

Robot spawner services - #6

Open
cychitivav wants to merge 6 commits into
ctu-mrs:ros2from
cychitivav:feat/robot-spawner
Open

Robot spawner services#6
cychitivav wants to merge 6 commits into
ctu-mrs:ros2from
cychitivav:feat/robot-spawner

Conversation

@cychitivav

Copy link
Copy Markdown

This pull request introduces dynamic UAV spawning and removal capabilities to the simulator, along with the necessary ROS 2 service infrastructure. The main changes include the addition of Spawn and Kill services, updates to the build configuration to support ROS 2 interface generation, and modifications to the UAV system to support runtime configuration of UAV parameters.

  • Added new ROS 2 services for spawning and killing UAVs (srv/Spawn.srv, srv/Kill.srv) and implemented their handlers in the simulator, allowing UAVs to be created and removed at runtime with specified parameters.
  • Introduced the SpawnParams_t struct and updated UavSystemRos_CommonHandlers_t to optionally include dynamic spawn parameters, enabling UAVs to use runtime-specified type, position, and heading.
  • Updated CMakeLists.txt and package.xml to include ROSIDL dependencies and interface generation, ensuring service definitions are built and available at runtime. Linked the generated ROSIDL typesupport library to simulator targets for proper service handling.
  • Added a getUavName() method to UavSystemRos for easier identification and management of UAV instances, used in service handlers to check for existing UAVs and remove them.
  • Improved collision handling and pose publishing logic to gracefully handle cases when no UAVs are present.

- Implemented a new service for spawning UAVs with dynamic parameters.
- Added SpawnParams_t structure to hold spawn parameters.
- Updated UavSystemRos to utilize spawn parameters if provided.
- Created Spawn.srv file for service definition.
- Modified CMakeLists.txt and package.xml to include necessary dependencies.
Copilot AI review requested due to automatic review settings March 10, 2026 08:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds ROS 2 service APIs to dynamically spawn and remove UAV instances in mrs_multirotor_simulator, and extends the UAV system to optionally initialize from runtime-provided spawn parameters instead of static config.

Changes:

  • Added new ROS 2 services: Spawn (type/name/pose/heading) and Kill (by name), with simulator handlers that create/remove UavSystemRos instances at runtime.
  • Extended UavSystemRos initialization via optional SpawnParams_t (dynamic type + spawn pose/heading) and added getUavName() for instance identification.
  • Updated build system (CMakeLists.txt, package.xml) to generate and link ROSIDL service interfaces.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
srv/Spawn.srv Defines request/response schema for dynamic UAV creation.
srv/Kill.srv Defines request/response schema for UAV removal by name.
include/mrs_multirotor_simulator/uav_system_ros.h Adds SpawnParams_t, optional spawn params in handlers, and getUavName().
src/uav_system_ros.cpp Uses optional spawn params for type and initial pose/heading; adds getUavName() implementation.
src/multirotor_simulator.cpp Registers Spawn/Kill services and implements callbacks; adds empty-UAV collision guard.
CMakeLists.txt Adds ROSIDL interface generation and links typesupport to simulator targets.
package.xml Adds ROSIDL generator/runtime dependencies for service generation and runtime availability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.xml Outdated
Comment thread src/multirotor_simulator.cpp
Comment thread src/multirotor_simulator.cpp
Comment thread src/multirotor_simulator.cpp
Comment thread CMakeLists.txt Outdated
Comment thread CMakeLists.txt
@klaxalk

klaxalk commented Mar 11, 2026

Copy link
Copy Markdown
Member

Hey, very interesting addition. Could you please rework it such that the message and service definition is place in the mrs_msgs package?

@cychitivav

Copy link
Copy Markdown
Author

Hey, very interesting addition. Could you please rework it such that the message and service definition is place in the mrs_msgs package?

Done, ctu-mrs/mrs_msgs#18

@cychitivav

Copy link
Copy Markdown
Author

@klaxalk, I noticed that the PR in mrs_msgs has already been merged, while this one is still open. Could you please let me know if there’s anything else I should refactor or update here?

@klaxalk

klaxalk commented Jul 7, 2026

Copy link
Copy Markdown
Member

@cychitivav thanks for reminding me. I am going to check if this does not break anything downstream (the flightforge simulator) and then I am gonna merge it.

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