17 #ifndef _GAZEBO_MESSAGES_UTILITY_HH_
18 #define _GAZEBO_MESSAGES_UTILITY_HH_
24 #include <ignition/math/Vector3.hh>
25 #include <ignition/math/Pose3.hh>
26 #include <ignition/math/Plane.hh>
30 #include "gazebo/msgs/MessageTypes.hh"
58 const std::string &_data =
"");
64 void Init(google::protobuf::Message &_message,
const std::string &_id =
"");
69 void Stamp(msgs::Header *_header);
74 void Stamp(msgs::Time *_time);
78 std::string Package(
const std::string &type,
79 const google::protobuf::Message &message);
86 msgs::Vector3d
Convert(
const ignition::math::Vector3d &_v);
92 msgs::Vector2d
Convert(
const ignition::math::Vector2d &_v);
98 msgs::Quaternion
Convert(
const ignition::math::Quaterniond &_q);
104 msgs::Pose
Convert(
const ignition::math::Pose3d &_p);
110 msgs::Color
Convert(
const common::Color &_c);
116 msgs::Time
Convert(
const common::Time &_t);
122 msgs::PlaneGeom
Convert(
const ignition::math::Planed &_p);
154 ignition::math::Vector3d
ConvertIgn(
const msgs::Vector3d &_v);
160 ignition::math::Vector2d
ConvertIgn(
const msgs::Vector2d &_v);
166 ignition::math::Quaterniond
ConvertIgn(
const msgs::Quaternion &_q);
172 ignition::math::Pose3d
ConvertIgn(
const msgs::Pose &_p);
178 void Set(common::Image &_img,
const msgs::Image &_msg);
184 common::Color
Convert(
const msgs::Color &_c);
190 common::Time
Convert(
const msgs::Time &_t);
196 ignition::math::Planed
ConvertIgn(
const msgs::PlaneGeom &_p);
202 void Set(msgs::Image *_msg,
const common::Image &_i);
208 void Set(msgs::Vector3d *_pt,
const ignition::math::Vector3d &_v);
214 void Set(msgs::Vector2d *_pt,
const ignition::math::Vector2d &_v);
220 void Set(msgs::Quaternion *_q,
const ignition::math::Quaterniond &_v);
226 void Set(msgs::Pose *_p,
const ignition::math::Pose3d &_v);
232 void Set(msgs::Color *_c,
const common::Color &_v);
238 void Set(msgs::Time *_t,
const common::Time &_v);
245 void Set(msgs::SphericalCoordinates *_s,
246 const common::SphericalCoordinates &_v);
252 void Set(msgs::PlaneGeom *_p,
const ignition::math::Planed &_v);
332 sdf::ElementPtr
VisualToSDF(
const msgs::Visual &_msg,
333 sdf::ElementPtr _sdf = sdf::ElementPtr());
344 sdf::ElementPtr _sdf = sdf::ElementPtr());
408 sdf::ElementPtr
LightToSDF(
const msgs::Light &_msg,
409 sdf::ElementPtr _sdf = sdf::ElementPtr());
418 sdf::ElementPtr _sdf = sdf::ElementPtr());
426 sdf::ElementPtr
PluginToSDF(
const msgs::Plugin &_plugin,
427 sdf::ElementPtr _sdf = sdf::ElementPtr());
436 sdf::ElementPtr _sdf = sdf::ElementPtr());
446 sdf::ElementPtr
LinkToSDF(
const msgs::Link &_msg,
447 sdf::ElementPtr _sdf = sdf::ElementPtr());
456 sdf::ElementPtr _sdf = sdf::ElementPtr());
465 sdf::ElementPtr _sdf = sdf::ElementPtr());
477 sdf::ElementPtr _sdf = sdf::ElementPtr());
485 sdf::ElementPtr
MeshToSDF(
const msgs::MeshGeom &_msg,
486 sdf::ElementPtr _sdf = sdf::ElementPtr());
496 void AddBoxLink(msgs::Model &_model,
const double _mass,
497 const ignition::math::Vector3d &_size);
510 const double _radius,
const double _length);
521 const double _radius);
529 void AddLinkGeom(Model &_msg,
const Geometry &_geom);
539 sdf::ElementPtr
ModelToSDF(
const msgs::Model &_msg,
540 sdf::ElementPtr _sdf = sdf::ElementPtr());
548 sdf::ElementPtr
JointToSDF(
const msgs::Joint &_msg,
549 sdf::ElementPtr _sdf = sdf::ElementPtr());
553 const google::protobuf::FieldDescriptor *GetFD(
554 google::protobuf::Message &message,
const std::string &name);
561 msgs::Header *
GetHeader(google::protobuf::Message &_message);
GAZEBO_VISIBLE msgs::Plugin PluginFromSDF(const sdf::ElementPtr _sdf)
Create a msgs::Plugin from a plugin SDF element.
GAZEBO_VISIBLE msgs::Geometry::Type ConvertGeometryType(const std::string &_str)
Convert a string to a msgs::Geometry::Type enum.
GAZEBO_VISIBLE void AddLinkGeom(Model &_msg, const Geometry &_geom)
Add a link with a collision and visual of specified geometry to a model message.
GAZEBO_VISIBLE msgs::Collision CollisionFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Collision from a collision SDF element.
GAZEBO_VISIBLE msgs::Header * GetHeader(google::protobuf::Message &_message)
Get the header from a protobuf message.
GAZEBO_VISIBLE ignition::math::Vector3d ConvertIgn(const msgs::Vector3d &_v)
Convert a msgs::Vector3d to an ignition::math::Vector.
GAZEBO_VISIBLE msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf)
Create a msgs::GUI from a GUI SDF element.
GAZEBO_VISIBLE msgs::Joint::Type ConvertJointType(const std::string &_str)
Convert a string to a msgs::Joint::Type enum.
GAZEBO_VISIBLE msgs::Sensor SensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Sensor from a sensor SDF element.
GAZEBO_VISIBLE msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Visual from a visual SDF element.
GAZEBO_VISIBLE msgs::Light LightFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Light from a light SDF element.
GAZEBO_VISIBLE sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Mesh.
GAZEBO_VISIBLE msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Scene from a scene SDF element.
GAZEBO_VISIBLE msgs::ContactSensor ContactSensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::ContactSensor from a contact sensor SDF element.
GAZEBO_VISIBLE msgs::Friction FrictionFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Friction from a friction SDF element.
GAZEBO_VISIBLE sdf::ElementPtr VisualToSDF(const msgs::Visual &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Visual.
GAZEBO_VISIBLE sdf::ElementPtr JointToSDF(const msgs::Joint &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from msgs::Joint.
GAZEBO_VISIBLE void AddSphereLink(msgs::Model &_model, const double _mass, const double _radius)
Add a simple sphere link to a Model message.
GAZEBO_VISIBLE sdf::ElementPtr ModelToSDF(const msgs::Model &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from msgs::Model.
GAZEBO_VISIBLE sdf::ElementPtr LinkToSDF(const msgs::Link &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Link.
GAZEBO_VISIBLE sdf::ElementPtr LightToSDF(const msgs::Light &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Light.
GAZEBO_VISIBLE void AddBoxLink(msgs::Model &_model, const double _mass, const ignition::math::Vector3d &_size)
Add a simple box link to a Model message.
GAZEBO_VISIBLE sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Inertial.
GAZEBO_VISIBLE msgs::Vector3d Convert(const ignition::math::Vector3d &_v)
Convert a ignition::math::Vector3 to a msgs::Vector3d.
GAZEBO_VISIBLE msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf)
Create a msgs::MeshGeom from a mesh SDF element.
GAZEBO_VISIBLE msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Geometry from a geometry SDF element.
GAZEBO_VISIBLE sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Geometry If _sdf is supplied and the _msg has non-empty ...
GAZEBO_VISIBLE msgs::Material::ShaderType ConvertShaderType(const std::string &_str)
Convert a string to a msgs::Material::ShaderType enum.
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
Forward declarations for the math classes.
GAZEBO_VISIBLE sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::CameraSensor.
GAZEBO_VISIBLE msgs::Fog FogFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Fog from a fog SDF element.
GAZEBO_VISIBLE sdf::ElementPtr MaterialToSDF(const msgs::Material &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Material If _sdf is supplied and _msg has script uri's t...
GAZEBO_VISIBLE sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Surface.
GAZEBO_VISIBLE void Stamp(msgs::Header *_header)
Time stamp a header.
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
GAZEBO_VISIBLE msgs::Surface SurfaceFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Surface from a surface SDF element.
GAZEBO_VISIBLE msgs::Axis AxisFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Axis from an axis SDF element.
GAZEBO_VISIBLE sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Plugin.
GAZEBO_VISIBLE msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf)
Create a msgs::TrackVisual from a track visual SDF element.
GAZEBO_VISIBLE msgs::RaySensor RaySensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::RaySensor from a ray sensor SDF element.
GAZEBO_VISIBLE sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::Collision.
GAZEBO_VISIBLE msgs::Joint JointFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Joint from a joint SDF element.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
GAZEBO_VISIBLE msgs::Request * CreateRequest(const std::string &_request, const std::string &_data="")
Create a request message.
GAZEBO_VISIBLE msgs::CameraSensor CameraSensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::CameraSensor from a camera sensor SDF element.
GAZEBO_VISIBLE void AddCylinderLink(msgs::Model &_model, const double _mass, const double _radius, const double _length)
Add a simple cylinder link to a Model message.