WorldUtils Class Reference

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< MoveObjectmove_queue
 Queue of objects with pending move actions. More...
 

Detailed Description

A custom gazebo plugin that provides an interface to programatically interact with the World object.

See the example usage below:

1 <plugin name="world" filename="libWorldUtils.so"/>

See worlds/spawner.world for a complete example.

Warning
This plugin is likely to undergo major changes, as some of its features can easily be done client-side.

Constructor & Destructor Documentation

Constructs the object.

Member Function Documentation

void clearMatching ( const std::string &  match,
const bool  is_light 
)
private

Removes entities matching a given string.

Parameters
matchThe string to be matched
is_lightWhether to target light objects or not
void clearWorld ( )
private

Removes everything from the world.

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 
)
private

Returns the SDF of a box.

Parameters
model_nameModel name
massModel mass
sizeBox size 3D vector
positionBox position
orientationBox orientation
Returns
Box SDF
Deprecated:
Unused feature, easily replaced by client command
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 
)
private

Returns the SDF of a cylinder.

Parameters
model_nameModel name
massModel mass
radiusCylinder radius
lengthCylinder length
positionCylinder position
orientationCylinder orientation
Returns
Cylinder SDF string
Deprecated:
Unused feature, easily replaced by client command
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 
)
private

Returns the SDF of a sphere.

Parameters
model_nameModel name
massModel mass
radiusSphere radius
positionSphere position
orientationSphere orientation
Returns
Sphere SDF string
Deprecated:
Unused feature, easily replaced by client command
void Load ( physics::WorldPtr  _world,
sdf::ElementPtr  _sdf 
)

Loads the object.

Parameters
_worldThe World object to which the plugin is attached
_sdfThe SDF element with plugin parameters
void onRequest ( WorldUtilsRequestPtr _msg)
private

Callback function for handling incoming requests.

Parameters
_msgThe 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.

Member Data Documentation

int box_counter {0}
private

Number of generated boxes.

int cylinder_counter {0}
private

Number of generated cylinders.

int light_counter {0}
private

Number of generated lights.

transport::PublisherPtr light_pub
private

A publisher to light modify topic.

std::queue<MoveObject> move_queue
private

Queue of objects with pending move actions.

std::mutex mutex

Mutex for safe data access.

transport::NodePtr node
private

A node used for transport.

std::regex pose_reg
private

Regex for applying custom pose.

transport::PublisherPtr pub
private

A publisher to the reply topic.

transport::PublisherPtr request_pub
private

A publisher to the gazebo request topic.

transport::SubscriberPtr response_sub
private

A subscriber to the gazebo response topic.

std::regex script_reg
private

Regex for applying custom material.

int sphere_counter {0}
private

Number of generated spheres.

transport::SubscriberPtr sub
private

A subscriber to the request topic.

event::ConnectionPtr updateConnection
private

Connection to World Update events.

physics::WorldPtr world
private

A pointer to the world.


The documentation for this class was generated from the following files: