msgs.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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_MSGS_MSGS_HH_
18 #define GAZEBO_MSGS_MSGS_HH_
19 
20 #include <string>
21 
22 #include <sdf/sdf.hh>
23 
24 #include <ignition/math/Inertial.hh>
25 #include <ignition/math/MassMatrix3.hh>
26 #include <ignition/math/Plane.hh>
27 #include <ignition/math/Pose3.hh>
28 #include <ignition/math/Vector3.hh>
29 
31 
32 #include "gazebo/msgs/MessageTypes.hh"
33 
34 // Remove gazebo/math includes in Gazebo8
35 // Adding the word deprecation so that a grep will find this.
36 #include "gazebo/math/MathTypes.hh"
37 #include "gazebo/math/Vector3.hh"
38 #include "gazebo/math/Pose.hh"
39 #include "gazebo/math/Plane.hh"
40 
42 #include "gazebo/common/Color.hh"
43 #include "gazebo/common/Time.hh"
44 #include "gazebo/common/Image.hh"
45 
46 namespace gazebo
47 {
50  namespace msgs
51  {
55 
61  msgs::Request *CreateRequest(const std::string &_request,
62  const std::string &_data = "");
63 
68  void Init(google::protobuf::Message &_message, const std::string &_id ="");
69 
73  void Stamp(msgs::Header *_header);
74 
78  void Stamp(msgs::Time *_time);
79 
82  std::string Package(const std::string &type,
83  const google::protobuf::Message &message);
85 
90  msgs::Any ConvertAny(const double _v);
91 
96  msgs::Any ConvertAny(const int _i);
97 
102  msgs::Any ConvertAny(const std::string &_s);
103 
108  msgs::Any ConvertAny(const char *_s);
109 
114  msgs::Any ConvertAny(const bool _b);
115 
120  msgs::Any ConvertAny(const ignition::math::Vector3d &_v);
121 
126  msgs::Any ConvertAny(const common::Color &_c);
127 
132  msgs::Any ConvertAny(const ignition::math::Pose3d &_p);
133 
138  msgs::Any ConvertAny(const ignition::math::Quaterniond &_q);
139 
144  msgs::Any ConvertAny(const common::Time &_t);
145 
150  msgs::Vector3d Convert(const ignition::math::Vector3d &_v);
151 
156  msgs::Vector2d Convert(const ignition::math::Vector2d &_v);
157 
162  msgs::Quaternion Convert(const ignition::math::Quaterniond &_q);
163 
168  msgs::Pose Convert(const ignition::math::Pose3d &_p);
169 
174  msgs::Color Convert(const common::Color &_c);
175 
180  msgs::Time Convert(const common::Time &_t);
181 
186  msgs::Inertial Convert(const ignition::math::Inertiald &_i);
187 
192  msgs::Inertial Convert(const ignition::math::MassMatrix3d &_m);
193 
198  msgs::PlaneGeom Convert(const ignition::math::Planed &_p);
199 
205  msgs::Joint::Type ConvertJointType(const std::string &_str);
206 
212  std::string ConvertJointType(const msgs::Joint::Type &_type);
213 
218  msgs::Geometry::Type ConvertGeometryType(const std::string &_str);
219 
224  std::string ConvertGeometryType(const msgs::Geometry::Type _type);
225 
230  ignition::math::Vector3d ConvertIgn(const msgs::Vector3d &_v);
231 
236  ignition::math::Vector2d ConvertIgn(const msgs::Vector2d &_v);
237 
242  ignition::math::Quaterniond ConvertIgn(const msgs::Quaternion &_q);
243 
248  ignition::math::Pose3d ConvertIgn(const msgs::Pose &_p);
249 
254  ignition::math::Inertiald Convert(const msgs::Inertial &_i);
255 
260  void Set(common::Image &_img, const msgs::Image &_msg);
261 
266  common::Color Convert(const msgs::Color &_c);
267 
272  common::Time Convert(const msgs::Time &_t);
273 
278  ignition::math::Planed ConvertIgn(const msgs::PlaneGeom &_p);
279 
284  void Set(msgs::Image *_msg, const common::Image &_i);
285 
290  void Set(msgs::Vector3d *_pt, const ignition::math::Vector3d &_v);
291 
296  void Set(msgs::Vector2d *_pt, const ignition::math::Vector2d &_v);
297 
302  void Set(msgs::Quaternion *_q, const ignition::math::Quaterniond &_v);
303 
308  void Set(msgs::Pose *_p, const ignition::math::Pose3d &_v);
309 
314  void Set(msgs::Color *_c, const common::Color &_v);
315 
320  void Set(msgs::Time *_t, const common::Time &_v);
321 
327  void Set(msgs::SphericalCoordinates *_s,
328  const common::SphericalCoordinates &_v);
329 
334  void Set(msgs::Inertial *_i, const ignition::math::Inertiald &_m);
335 
340  void Set(msgs::Inertial *_i, const ignition::math::MassMatrix3d &_m);
341 
346  void Set(msgs::PlaneGeom *_p, const ignition::math::Planed &_v);
347 
352  msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf);
353 
358  msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf);
359 
364  msgs::Light LightFromSDF(sdf::ElementPtr _sdf);
365 
370  msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf);
371 
376  msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf);
377 
382  msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf);
383 
388  msgs::Collision CollisionFromSDF(sdf::ElementPtr _sdf);
389 
394  msgs::Surface SurfaceFromSDF(sdf::ElementPtr _sdf);
395 
400  msgs::Friction FrictionFromSDF(sdf::ElementPtr _sdf);
401 
406  msgs::Axis AxisFromSDF(sdf::ElementPtr _sdf);
407 
412  msgs::Joint JointFromSDF(sdf::ElementPtr _sdf);
413 
418  msgs::Plugin PluginFromSDF(const 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 
473  msgs::Sensor SensorFromSDF(sdf::ElementPtr _sdf);
474 
480  msgs::CameraSensor CameraSensorFromSDF(sdf::ElementPtr _sdf);
481 
487  msgs::RaySensor RaySensorFromSDF(sdf::ElementPtr _sdf);
488 
494  msgs::ContactSensor ContactSensorFromSDF(sdf::ElementPtr _sdf);
495 
502  sdf::ElementPtr LightToSDF(const msgs::Light &_msg,
503  sdf::ElementPtr _sdf = sdf::ElementPtr());
504 
511  sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg,
512  sdf::ElementPtr _sdf = sdf::ElementPtr());
513 
520  sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin,
521  sdf::ElementPtr _sdf = sdf::ElementPtr());
522 
529  sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg,
530  sdf::ElementPtr _sdf = sdf::ElementPtr());
531 
540  sdf::ElementPtr LinkToSDF(const msgs::Link &_msg,
541  sdf::ElementPtr _sdf = sdf::ElementPtr());
542 
549  sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg,
550  sdf::ElementPtr _sdf = sdf::ElementPtr());
551 
558  sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg,
559  sdf::ElementPtr _sdf = sdf::ElementPtr());
560 
570  sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg,
571  sdf::ElementPtr _sdf = sdf::ElementPtr());
572 
579  sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg,
580  sdf::ElementPtr _sdf = sdf::ElementPtr());
581 
590  void AddBoxLink(msgs::Model &_model, const double _mass,
591  const ignition::math::Vector3d &_size);
592 
603  void AddCylinderLink(msgs::Model &_model, const double _mass,
604  const double _radius, const double _length);
605 
614  void AddSphereLink(msgs::Model &_model, const double _mass,
615  const double _radius);
616 
623  void AddLinkGeom(Model &_msg, const Geometry &_geom);
624 
633  sdf::ElementPtr ModelToSDF(const msgs::Model &_msg,
634  sdf::ElementPtr _sdf = sdf::ElementPtr());
635 
642  sdf::ElementPtr JointToSDF(const msgs::Joint &_msg,
643  sdf::ElementPtr _sdf = sdf::ElementPtr());
644 
647  const google::protobuf::FieldDescriptor *GetFD(
648  google::protobuf::Message &message, const std::string &name);
650 
655  msgs::Header *GetHeader(google::protobuf::Message &_message);
656 
658  }
659 }
660 
661 #endif
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.
Forward declarations for the common classes.
Definition: Animation.hh:33
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&#39;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::Any ConvertAny(const double _v)
Convert a double to a msgs::Any.
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.