A custom gazebo plugin that provides an interface to programatically interact with the World object. More...
#include <WorldUtils.hh>
Public Member Functions | |
WorldUtils () | |
Constructs the object. More... | |
void | Load (physics::WorldPtr _world, sdf::ElementPtr _sdf) |
Loads the object. More... | |
void | onUpdate () |
Callback function for handling world updates. More... | |
Public Attributes | |
std::mutex | mutex |
Mutex for safe data access. More... | |
Private Member Functions | |
void | onRequest (WorldUtilsRequestPtr &_msg) |
Callback function for handling incoming requests. More... | |
void | clearWorld () |
Removes everything from the world. More... | |
void | clearMatching (const std::string &match, const bool is_light) |
Removes entities matching a given string. More... | |
const std::string | genSphere (const std::string &model_name, const double mass, const double radius, const ignition::math::Vector3d position, const ignition::math::Quaterniond orientation) |
Returns the SDF of a sphere. More... | |
const std::string | genCylinder (const std::string &model_name, const double mass, const double radius, const double length, const ignition::math::Vector3d position, const ignition::math::Quaterniond orientation) |
Returns the SDF of a cylinder. More... | |
const std::string | genBox (const std::string &model_name, const double mass, const ignition::math::Vector3d size, const ignition::math::Vector3d position, const ignition::math::Quaterniond orientation) |
Returns the SDF of a box. More... | |
Private Attributes | |
physics::WorldPtr | world |
A pointer to the world. More... | |
event::ConnectionPtr | updateConnection |
Connection to World Update events. More... | |
transport::NodePtr | node |
A node used for transport. More... | |
transport::SubscriberPtr | sub |
A subscriber to the request topic. More... | |
transport::PublisherPtr | pub |
A publisher to the reply topic. More... | |
transport::PublisherPtr | request_pub |
A publisher to the gazebo request topic. More... | |
transport::SubscriberPtr | response_sub |
A subscriber to the gazebo response topic. More... | |
transport::PublisherPtr | light_pub |
A publisher to light modify topic. More... | |
std::regex | script_reg |
Regex for applying custom material. More... | |
std::regex | pose_reg |
Regex for applying custom pose. More... | |
int | sphere_counter {0} |
Number of generated spheres. More... | |
int | cylinder_counter {0} |
Number of generated cylinders. More... | |
int | box_counter {0} |
Number of generated boxes. More... | |
int | light_counter {0} |
Number of generated lights. More... | |
std::queue< MoveObject > | move_queue |
Queue of objects with pending move actions. More... | |
A custom gazebo plugin that provides an interface to programatically interact with the World object.
See the example usage below:
See worlds/spawner.world for a complete example.
WorldUtils | ( | ) |
Constructs the object.
|
private |
Removes entities matching a given string.
match | The string to be matched |
is_light | Whether to target light objects or not |
|
private |
Removes everything from the world.
|
private |
Returns the SDF of a box.
model_name | Model name |
mass | Model mass |
size | Box size 3D vector |
position | Box position |
orientation | Box orientation |
|
private |
Returns the SDF of a cylinder.
model_name | Model name |
mass | Model mass |
radius | Cylinder radius |
length | Cylinder length |
position | Cylinder position |
orientation | Cylinder orientation |
|
private |
Returns the SDF of a sphere.
model_name | Model name |
mass | Model mass |
radius | Sphere radius |
position | Sphere position |
orientation | Sphere orientation |
void Load | ( | physics::WorldPtr | _world, |
sdf::ElementPtr | _sdf | ||
) |
Loads the object.
_world | The World object to which the plugin is attached |
_sdf | The SDF element with plugin parameters |
|
private |
Callback function for handling incoming requests.
_msg | The message |
TODO - better structure
Extract parameters from message
If a spawn message was requested
Enclose in sdf xml tags
Regex to modify pose string in custom model
Change material script in string
void onUpdate | ( | ) |
Callback function for handling world updates.
|
private |
Number of generated boxes.
|
private |
Number of generated cylinders.
|
private |
Number of generated lights.
|
private |
A publisher to light modify topic.
|
private |
Queue of objects with pending move actions.
std::mutex mutex |
Mutex for safe data access.
|
private |
A node used for transport.
|
private |
Regex for applying custom pose.
|
private |
A publisher to the reply topic.
|
private |
A publisher to the gazebo request topic.
|
private |
A subscriber to the gazebo response topic.
|
private |
Regex for applying custom material.
|
private |
Number of generated spheres.
|
private |
A subscriber to the request topic.
|
private |
Connection to World Update events.
|
private |
A pointer to the world.