msgs.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_MESSAGES_UTILITY_HH_
18 #define _GAZEBO_MESSAGES_UTILITY_HH_
19 
20 #include <string>
21 
22 #include <sdf/sdf.hh>
23 
24 #include <ignition/math/Vector3.hh>
25 #include <ignition/math/Pose3.hh>
26 #include <ignition/math/Plane.hh>
27 
29 
30 #include "gazebo/msgs/MessageTypes.hh"
31 
32 #include "gazebo/math/MathTypes.hh"
33 #include "gazebo/math/Vector3.hh"
34 #include "gazebo/math/Pose.hh"
35 #include "gazebo/math/Plane.hh"
36 
38 #include "gazebo/common/Color.hh"
39 #include "gazebo/common/Time.hh"
40 #include "gazebo/common/Image.hh"
41 
42 namespace gazebo
43 {
46  namespace msgs
47  {
51 
57  msgs::Request *CreateRequest(const std::string &_request,
58  const std::string &_data = "");
59 
64  void Init(google::protobuf::Message &_message, const std::string &_id ="");
65 
69  void Stamp(msgs::Header *_header);
70 
74  void Stamp(msgs::Time *_time);
75 
78  std::string Package(const std::string &type,
79  const google::protobuf::Message &message);
81 
87  msgs::Vector3d Convert(const math::Vector3 &_v) GAZEBO_DEPRECATED(6.0);
88 
94  msgs::Vector2d Convert(const math::Vector2d &_v) GAZEBO_DEPRECATED(6.0);
95 
101  msgs::Quaternion Convert(const math::Quaternion &_q) GAZEBO_DEPRECATED(6.0);
102 
108  msgs::Pose Convert(const math::Pose &_p) GAZEBO_DEPRECATED(6.0);
109 
114  msgs::Vector3d Convert(const ignition::math::Vector3d &_v);
115 
120  msgs::Vector2d Convert(const ignition::math::Vector2d &_v);
121 
126  msgs::Quaternion Convert(const ignition::math::Quaterniond &_q);
127 
132  msgs::Pose Convert(const ignition::math::Pose3d &_p);
133 
138  msgs::Color Convert(const common::Color &_c);
139 
144  msgs::Time Convert(const common::Time &_t);
145 
151  msgs::PlaneGeom Convert(const math::Plane &_p) GAZEBO_DEPRECATED(6.0);
152 
157  msgs::PlaneGeom Convert(const ignition::math::Planed &_p);
158 
164  msgs::Joint::Type ConvertJointType(const std::string &_str);
165 
171  std::string ConvertJointType(const msgs::Joint::Type &_type);
172 
177  msgs::Geometry::Type ConvertGeometryType(const std::string &_str);
178 
183  std::string ConvertGeometryType(const msgs::Geometry::Type _type);
184 
191  math::Vector3 Convert(const msgs::Vector3d &_v) GAZEBO_DEPRECATED(6.0);
192 
199  math::Vector2d Convert(const msgs::Vector2d &_v) GAZEBO_DEPRECATED(6.0);
200 
207  math::Quaternion Convert(const msgs::Quaternion &_q) GAZEBO_DEPRECATED(6.0);
208 
215  math::Pose Convert(const msgs::Pose &_p) GAZEBO_DEPRECATED(6.0);
216 
221  ignition::math::Vector3d ConvertIgn(const msgs::Vector3d &_v);
222 
227  ignition::math::Vector2d ConvertIgn(const msgs::Vector2d &_v);
228 
233  ignition::math::Quaterniond ConvertIgn(const msgs::Quaternion &_q);
234 
239  ignition::math::Pose3d ConvertIgn(const msgs::Pose &_p);
240 
245  void Set(common::Image &_img, const msgs::Image &_msg);
246 
251  common::Color Convert(const msgs::Color &_c);
252 
257  common::Time Convert(const msgs::Time &_t);
258 
265  math::Plane Convert(const msgs::PlaneGeom &_p) GAZEBO_DEPRECATED(6.0);
266 
271  ignition::math::Planed ConvertIgn(const msgs::PlaneGeom &_p);
272 
277  void Set(msgs::Image *_msg, const common::Image &_i);
278 
285  void Set(msgs::Vector3d *_pt, const math::Vector3 &_v)
286  GAZEBO_DEPRECATED(6.0);
287 
294  void Set(msgs::Vector2d *_pt, const math::Vector2d &_v)
295  GAZEBO_DEPRECATED(6.0);
296 
303  void Set(msgs::Quaternion *_q, const math::Quaternion &_v)
304  GAZEBO_DEPRECATED(6.0);
305 
312  void Set(msgs::Pose *_p, const math::Pose &_v) GAZEBO_DEPRECATED(6.0);
313 
318  void Set(msgs::Vector3d *_pt, const ignition::math::Vector3d &_v);
319 
324  void Set(msgs::Vector2d *_pt, const ignition::math::Vector2d &_v);
325 
330  void Set(msgs::Quaternion *_q, const ignition::math::Quaterniond &_v);
331 
336  void Set(msgs::Pose *_p, const ignition::math::Pose3d &_v);
337 
342  void Set(msgs::Color *_c, const common::Color &_v);
343 
348  void Set(msgs::Time *_t, const common::Time &_v);
349 
355  void Set(msgs::SphericalCoordinates *_s,
356  const common::SphericalCoordinates &_v);
357 
364  void Set(msgs::PlaneGeom *_p, const math::Plane &_v) GAZEBO_DEPRECATED(6.0);
365 
370  void Set(msgs::PlaneGeom *_p, const ignition::math::Planed &_v);
371 
376  msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf);
377 
382  msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf);
383 
388  msgs::Light LightFromSDF(sdf::ElementPtr _sdf);
389 
394  msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf);
395 
400  msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf);
401 
406  msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf);
407 
412  msgs::Axis AxisFromSDF(sdf::ElementPtr _sdf);
413 
418  msgs::Joint JointFromSDF(sdf::ElementPtr _sdf);
419 
426  sdf::ElementPtr VisualToSDF(const msgs::Visual &_msg,
427  sdf::ElementPtr _sdf = sdf::ElementPtr());
428 
437  sdf::ElementPtr MaterialToSDF(const msgs::Material &_msg,
438  sdf::ElementPtr _sdf = sdf::ElementPtr());
439 
445  msgs::Material::ShaderType ConvertShaderType(const std::string &_str);
446 
452  std::string ConvertShaderType(const msgs::Material::ShaderType &_type);
453 
458  msgs::Fog FogFromSDF(sdf::ElementPtr _sdf);
459 
464  msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf);
465 
472  sdf::ElementPtr LightToSDF(const msgs::Light &_msg,
473  sdf::ElementPtr _sdf = sdf::ElementPtr());
474 
481  sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg,
482  sdf::ElementPtr _sdf = sdf::ElementPtr());
483 
490  sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin,
491  sdf::ElementPtr _sdf = sdf::ElementPtr());
492 
499  sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg,
500  sdf::ElementPtr _sdf = sdf::ElementPtr());
501 
510  sdf::ElementPtr LinkToSDF(const msgs::Link &_msg,
511  sdf::ElementPtr _sdf = sdf::ElementPtr());
512 
519  sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg,
520  sdf::ElementPtr _sdf = sdf::ElementPtr());
521 
528  sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg,
529  sdf::ElementPtr _sdf = sdf::ElementPtr());
530 
540  sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg,
541  sdf::ElementPtr _sdf = sdf::ElementPtr());
542 
549  sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg,
550  sdf::ElementPtr _sdf = sdf::ElementPtr());
551 
562  void AddBoxLink(msgs::Model &_model, const double _mass,
563  const math::Vector3 &_size) GAZEBO_DEPRECATED(6.0);
564 
573  void AddBoxLink(msgs::Model &_model, const double _mass,
574  const ignition::math::Vector3d &_size);
575 
586  void AddCylinderLink(msgs::Model &_model, const double _mass,
587  const double _radius, const double _length);
588 
597  void AddSphereLink(msgs::Model &_model, const double _mass,
598  const double _radius);
599 
606  void AddLinkGeom(Model &_msg, const Geometry &_geom);
607 
616  sdf::ElementPtr ModelToSDF(const msgs::Model &_msg,
617  sdf::ElementPtr _sdf = sdf::ElementPtr());
618 
625  sdf::ElementPtr JointToSDF(const msgs::Joint &_msg,
626  sdf::ElementPtr _sdf = sdf::ElementPtr());
627 
630  const google::protobuf::FieldDescriptor *GetFD(
631  google::protobuf::Message &message, const std::string &name);
633 
638  msgs::Header *GetHeader(google::protobuf::Message &_message);
639 
641  }
642 }
643 
644 #endif
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::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::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.
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:47
GAZEBO_VISIBLE msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Scene from a scene 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 msgs::Vector3d Convert(const math::Vector3 &_v) GAZEBO_DEPRECATED(6.0)
Convert a math::Vector3 to a msgs::Vector3d.
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 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::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 void AddBoxLink(msgs::Model &_model, const double _mass, const math::Vector3 &_size) GAZEBO_DEPRECATED(6.0)
Add a simple box link to a Model message.
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::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 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:66
GAZEBO_VISIBLE msgs::Request * CreateRequest(const std::string &_request, const std::string &_data="")
Create a request message.
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.