Class EntitySpawner

Inheritance Relationships

Base Type

  • public rclcpp::Node

Class Documentation

class EntitySpawner : public rclcpp::Node

A ROS 2 node for spawning entities into a Gazebo simulation.

Public Functions

EntitySpawner()

Default constructor. Initializes the node and spawn client.

explicit EntitySpawner(rclcpp::Client<ros_gz_interfaces::srv::SpawnEntity>::SharedPtr client)

Constructor that accepts an external spawn service client.

Parameters:

client[in] Shared pointer to the spawn entity service client.

bool spawn_entity(const std::string &model_name, const std::string &sdf_filename, const geometry_msgs::msg::Pose &pose)

Spawns a model entity in the simulation.

Parameters:
  • model_name[in] Name of the model.

  • sdf_filename[in] Path to the SDF file.

  • pose[in] Initial pose of the model.

Returns:

True if the model was spawned successfully, false otherwise.

Protected Attributes

rclcpp::Client<ros_gz_interfaces::srv::SpawnEntity>::SharedPtr client_

Client used to call the spawn entity service.