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/Quaternion.hh>
29 #include <ignition/math/Vector2.hh>
30 #include <ignition/math/Vector3.hh>
31 
32 #include <ignition/msgs/color.pb.h>
33 #include <ignition/msgs/material.pb.h>
34 
35 #include "gazebo/msgs/MessageTypes.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 
86  msgs::Any ConvertAny(const double _v);
87 
92  msgs::Any ConvertAny(const int _i);
93 
98  msgs::Any ConvertAny(const std::string &_s);
99 
104  msgs::Any ConvertAny(const char *_s);
105 
110  msgs::Any ConvertAny(const bool _b);
111 
116  msgs::Any ConvertAny(const ignition::math::Vector3d &_v);
117 
126  msgs::Any ConvertAny(const common::Color &_c); // GAZEBO_DEPRECATED(9.0);
127 
132  msgs::Any ConvertAny(const ignition::math::Color &_c);
133 
138  msgs::Any ConvertAny(const ignition::math::Pose3d &_p);
139 
144  msgs::Any ConvertAny(const ignition::math::Quaterniond &_q);
145 
150  msgs::Any ConvertAny(const common::Time &_t);
151 
156  msgs::Vector3d Convert(const ignition::math::Vector3d &_v);
157 
162  msgs::Vector2d Convert(const ignition::math::Vector2d &_v);
163 
168  msgs::Quaternion Convert(const ignition::math::Quaterniond &_q);
169 
174  msgs::Pose Convert(const ignition::math::Pose3d &_p);
175 
181  msgs::Color Convert(const common::Color &_c) GAZEBO_DEPRECATED(9.0);
182 
187  msgs::Color Convert(const ignition::math::Color &_c);
188 
193  msgs::Time Convert(const common::Time &_t);
194 
199  msgs::Inertial Convert(const ignition::math::Inertiald &_i);
200 
205  msgs::Inertial Convert(const ignition::math::MassMatrix3d &_m);
206 
211  msgs::PlaneGeom Convert(const ignition::math::Planed &_p);
212 
218  msgs::Joint::Type ConvertJointType(const std::string &_str);
219 
225  std::string ConvertJointType(const msgs::Joint::Type &_type);
226 
231  msgs::Geometry::Type ConvertGeometryType(const std::string &_str);
232 
237  std::string ConvertGeometryType(const msgs::Geometry::Type _type);
238 
243  ignition::math::Vector3d ConvertIgn(const msgs::Vector3d &_v);
244 
249  ignition::math::Vector2d ConvertIgn(const msgs::Vector2d &_v);
250 
255  ignition::math::Quaterniond ConvertIgn(const msgs::Quaternion &_q);
256 
261  ignition::math::Pose3d ConvertIgn(const msgs::Pose &_p);
262 
267  ignition::math::Inertiald Convert(const msgs::Inertial &_i);
268 
273  void Set(common::Image &_img, const msgs::Image &_msg);
274 
279  ignition::math::Color Convert(const msgs::Color &_c);
280 
285  common::Time Convert(const msgs::Time &_t);
286 
291  ignition::math::Planed ConvertIgn(const msgs::PlaneGeom &_p);
292 
297  void Set(msgs::Image *_msg, const common::Image &_i);
298 
303  void Set(msgs::Vector3d *_pt, const ignition::math::Vector3d &_v);
304 
309  void Set(msgs::Vector2d *_pt, const ignition::math::Vector2d &_v);
310 
315  void Set(msgs::Quaternion *_q, const ignition::math::Quaterniond &_v);
316 
321  void Set(msgs::Pose *_p, const ignition::math::Pose3d &_v);
322 
328  void Set(msgs::Color *_c, const common::Color &_v) GAZEBO_DEPRECATED(9.0);
329 
334  void Set(msgs::Color *_c, const ignition::math::Color &_v);
335 
340  void Set(msgs::Time *_t, const common::Time &_v);
341 
347  void Set(msgs::SphericalCoordinates *_s,
348  const common::SphericalCoordinates &_v);
349 
354  void Set(msgs::Inertial *_i, const ignition::math::Inertiald &_m);
355 
360  void Set(msgs::Inertial *_i, const ignition::math::MassMatrix3d &_m);
361 
366  void Set(msgs::PlaneGeom *_p, const ignition::math::Planed &_v);
367 
372  msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf);
373 
378  msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf);
379 
384  msgs::Light LightFromSDF(sdf::ElementPtr _sdf);
385 
390  msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf);
391 
396  msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf);
397 
402  msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf);
403 
408  msgs::Collision CollisionFromSDF(sdf::ElementPtr _sdf);
409 
414  msgs::Surface SurfaceFromSDF(sdf::ElementPtr _sdf);
415 
420  msgs::Friction FrictionFromSDF(sdf::ElementPtr _sdf);
421 
426  msgs::Axis AxisFromSDF(sdf::ElementPtr _sdf);
427 
432  msgs::Joint JointFromSDF(sdf::ElementPtr _sdf);
433 
438  msgs::Plugin PluginFromSDF(const sdf::ElementPtr _sdf);
439 
446  sdf::ElementPtr VisualToSDF(const msgs::Visual &_msg,
447  sdf::ElementPtr _sdf = sdf::ElementPtr());
448 
457  sdf::ElementPtr MaterialToSDF(const msgs::Material &_msg,
458  sdf::ElementPtr _sdf = sdf::ElementPtr());
459 
465  msgs::Material::ShaderType ConvertShaderType(const std::string &_str);
466 
472  std::string ConvertShaderType(const msgs::Material::ShaderType &_type);
473 
478  msgs::Fog FogFromSDF(sdf::ElementPtr _sdf);
479 
484  msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf);
485 
496  msgs::Sensor SensorFromSDF(sdf::ElementPtr _sdf);
497 
503  msgs::CameraSensor CameraSensorFromSDF(sdf::ElementPtr _sdf);
504 
510  msgs::RaySensor RaySensorFromSDF(sdf::ElementPtr _sdf);
511 
517  msgs::ContactSensor ContactSensorFromSDF(sdf::ElementPtr _sdf);
518 
525  sdf::ElementPtr LightToSDF(const msgs::Light &_msg,
526  sdf::ElementPtr _sdf = sdf::ElementPtr());
527 
534  sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg,
535  sdf::ElementPtr _sdf = sdf::ElementPtr());
536 
543  sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin,
544  sdf::ElementPtr _sdf = sdf::ElementPtr());
545 
552  sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg,
553  sdf::ElementPtr _sdf = sdf::ElementPtr());
554 
563  sdf::ElementPtr LinkToSDF(const msgs::Link &_msg,
564  sdf::ElementPtr _sdf = sdf::ElementPtr());
565 
572  sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg,
573  sdf::ElementPtr _sdf = sdf::ElementPtr());
574 
581  sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg,
582  sdf::ElementPtr _sdf = sdf::ElementPtr());
583 
593  sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg,
594  sdf::ElementPtr _sdf = sdf::ElementPtr());
595 
602  sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg,
603  sdf::ElementPtr _sdf = sdf::ElementPtr());
604 
613  void AddBoxLink(msgs::Model &_model, const double _mass,
614  const ignition::math::Vector3d &_size);
615 
626  void AddCylinderLink(msgs::Model &_model, const double _mass,
627  const double _radius, const double _length);
628 
637  void AddSphereLink(msgs::Model &_model, const double _mass,
638  const double _radius);
639 
646  void AddLinkGeom(Model &_msg, const Geometry &_geom);
647 
656  sdf::ElementPtr ModelToSDF(const msgs::Model &_msg,
657  sdf::ElementPtr _sdf = sdf::ElementPtr());
658 
665  sdf::ElementPtr JointToSDF(const msgs::Joint &_msg,
666  sdf::ElementPtr _sdf = sdf::ElementPtr());
667 
670  const google::protobuf::FieldDescriptor *GetFD(
671  google::protobuf::Message &message, const std::string &name);
673 
678  msgs::Header *GetHeader(google::protobuf::Message &_message);
679 
685  msgs::GPSSensor GPSSensorFromSDF(sdf::ElementPtr _sdf);
686 
692  msgs::SensorNoise SensorNoiseFromSDF(sdf::ElementPtr _elem);
693 
699  msgs::IMUSensor IMUSensorFromSDF(sdf::ElementPtr _sdf);
700 
707  msgs::LogicalCameraSensor LogicalCameraSensorFromSDF(sdf::ElementPtr _sdf);
708 
715  sdf::ElementPtr LogicalCameraSensorToSDF(
716  const msgs::LogicalCameraSensor &_msg,
717  sdf::ElementPtr _sdf = sdf::ElementPtr());
718 
725  sdf::ElementPtr IMUSensorToSDF(const msgs::IMUSensor &_msg,
726  sdf::ElementPtr _sdf = sdf::ElementPtr());
727 
734  sdf::ElementPtr SensorNoiseToSDF(const msgs::SensorNoise &_msg,
735  sdf::ElementPtr _sdf = sdf::ElementPtr());
736 
743  sdf::ElementPtr GPSSensorToSDF(const msgs::GPSSensor &_msg,
744  sdf::ElementPtr _sdf = sdf::ElementPtr());
745 
750  ignition::msgs::Color ConvertIgnMsg(const msgs::Color &_msg);
751 
756  msgs::Color ConvertIgnMsg(const ignition::msgs::Color &_msg);
757 
763  ignition::msgs::Material::ShaderType ConvertIgnMsg(
764  const msgs::Material::ShaderType &_type);
765 
771  msgs::Material::ShaderType ConvertIgnMsg(
772  const ignition::msgs::Material::ShaderType &_type);
773 
779  ignition::msgs::Material::Script ConvertIgnMsg(
780  const msgs::Material::Script &_script);
781 
787  msgs::Material::Script ConvertIgnMsg(
788  const ignition::msgs::Material::Script &_script);
789 
794  ignition::msgs::Material ConvertIgnMsg(const msgs::Material &_msg);
795 
800  msgs::Material ConvertIgnMsg(const ignition::msgs::Material &_msg);
802  }
803 }
804 
805 #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.
GAZEBO_VISIBLE msgs::GPSSensor GPSSensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::GPSSensor from a gps sensor SDF element.
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 sdf::ElementPtr LogicalCameraSensorToSDF(const msgs::LogicalCameraSensor &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::LogicalCameraSensor.
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::LogicalCameraSensor LogicalCameraSensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::LogicalCameraSensor from a logical camera sensor.
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 SensorNoiseToSDF(const msgs::SensorNoise &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::SensorNoise.
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 msgs::SensorNoise SensorNoiseFromSDF(sdf::ElementPtr _elem)
Create a msgs::SensorNoise from a sensor noise SDF element.
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.
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.
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
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 ignition::msgs::Color ConvertIgnMsg(const msgs::Color &_msg)
Convert gazebo::msgs::Color to ignition::msgs::Color.
GAZEBO_VISIBLE sdf::ElementPtr IMUSensorToSDF(const msgs::IMUSensor &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::IMUSensor.
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 msgs::IMUSensor IMUSensorFromSDF(sdf::ElementPtr _sdf)
Create a msgs::IMUSensor from an imu 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 sdf::ElementPtr GPSSensorToSDF(const msgs::GPSSensor &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create or update an SDF element from a msgs::GPSSensor.
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.