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 MESSAGES_UTILITY_H
18 #define MESSAGES_UTILITY_H
19 
20 #include <string>
21 
22 #include <sdf/sdf.hh>
23 
24 #include "gazebo/msgs/MessageTypes.hh"
25 
26 #include "gazebo/math/MathTypes.hh"
27 #include "gazebo/math/Vector3.hh"
28 #include "gazebo/math/Pose.hh"
29 #include "gazebo/math/Plane.hh"
30 #include "gazebo/math/Box.hh"
31 
33 #include "gazebo/common/Color.hh"
34 #include "gazebo/common/Time.hh"
35 #include "gazebo/common/Image.hh"
36 
37 namespace gazebo
38 {
41  namespace msgs
42  {
46 
52  msgs::Request *CreateRequest(const std::string &_request,
53  const std::string &_data = "");
54 
59  void Init(google::protobuf::Message &_message, const std::string &_id ="");
60 
64  void Stamp(msgs::Header *_header);
65 
69  void Stamp(msgs::Time *_time);
70 
73  std::string Package(const std::string &type,
74  const google::protobuf::Message &message);
76 
81  msgs::Vector3d Convert(const math::Vector3 &_v);
82 
87  msgs::Vector2d Convert(const math::Vector2d &_v);
88 
93  msgs::Quaternion Convert(const math::Quaternion &_q);
94 
99  msgs::Pose Convert(const math::Pose &_p);
100 
105  msgs::Color Convert(const common::Color &_c);
106 
111  msgs::Time Convert(const common::Time &_t);
112 
117  msgs::PlaneGeom Convert(const math::Plane &_p);
118 
124  msgs::Joint::Type ConvertJointType(const std::string &_str);
125 
131  std::string ConvertJointType(const msgs::Joint::Type _type);
132 
137  math::Vector3 Convert(const msgs::Vector3d &_v);
138 
143  math::Vector2d Convert(const msgs::Vector2d &_v);
144 
149  math::Quaternion Convert(const msgs::Quaternion &_q);
150 
155  math::Pose Convert(const msgs::Pose &_p);
156 
161  void Set(common::Image &_img, const msgs::Image &_msg);
162 
167  common::Color Convert(const msgs::Color &_c);
168 
173  common::Time Convert(const msgs::Time &_t);
174 
179  math::Plane Convert(const msgs::PlaneGeom &_p);
180 
185  void Set(msgs::Image *_msg, const common::Image &_i);
186 
191  void Set(msgs::Vector3d *_pt, const math::Vector3 &_v);
192 
197  void Set(msgs::Vector2d *_pt, const math::Vector2d &_v);
198 
203  void Set(msgs::Quaternion *_q, const math::Quaternion &_v);
204 
209  void Set(msgs::Pose *_p, const math::Pose &_v);
210 
215  void Set(msgs::Color *_c, const common::Color &_v);
216 
221  void Set(msgs::Time *_t, const common::Time &_v);
222 
228  void Set(msgs::SphericalCoordinates *_s,
229  const common::SphericalCoordinates &_v);
230 
235  void Set(msgs::PlaneGeom *_p, const math::Plane &_v);
236 
241  msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf);
242 
247  msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf);
248 
253  msgs::Light LightFromSDF(sdf::ElementPtr _sdf);
254 
259  msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf);
260 
265  msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf);
266 
271  msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf);
272 
279  sdf::ElementPtr VisualToSDF(const msgs::Visual &_msg,
280  sdf::ElementPtr _sdf = sdf::ElementPtr());
281 
290  sdf::ElementPtr MaterialToSDF(const msgs::Material &_msg,
291  sdf::ElementPtr _sdf = sdf::ElementPtr());
292 
298  msgs::Material::ShaderType ConvertShaderType(const std::string &_str);
299 
305  std::string ConvertShaderType(const msgs::Material::ShaderType _type);
306 
311  msgs::Fog FogFromSDF(sdf::ElementPtr _sdf);
312 
317  msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf);
318 
325  sdf::ElementPtr LightToSDF(const msgs::Light &_msg,
326  sdf::ElementPtr _sdf = sdf::ElementPtr());
327 
334  sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg,
335  sdf::ElementPtr _sdf = sdf::ElementPtr());
336 
343  sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin,
344  sdf::ElementPtr _sdf = sdf::ElementPtr());
345 
352  sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg,
353  sdf::ElementPtr _sdf = sdf::ElementPtr());
354 
364  sdf::ElementPtr LinkToSDF(const msgs::Link &_msg,
365  sdf::ElementPtr _sdf = sdf::ElementPtr());
366 
373  sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg,
374  sdf::ElementPtr _sdf = sdf::ElementPtr());
375 
382  sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg,
383  sdf::ElementPtr _sdf = sdf::ElementPtr());
384 
394  sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg,
395  sdf::ElementPtr _sdf = sdf::ElementPtr());
396 
403  sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg,
404  sdf::ElementPtr _sdf = sdf::ElementPtr());
405 
414  void AddBoxLink(msgs::Model &_model, const double _mass,
415  const math::Vector3 &_size);
416 
427  void AddCylinderLink(msgs::Model &_model, const double _mass,
428  const double _radius, const double _length);
429 
438  void AddSphereLink(msgs::Model &_model, const double _mass,
439  const double _radius);
440 
447  void AddLinkGeom(Model &_msg, const Geometry &_geom);
448 
457  sdf::ElementPtr ModelToSDF(const msgs::Model &_msg,
458  sdf::ElementPtr _sdf = sdf::ElementPtr());
459 
466  sdf::ElementPtr JointToSDF(const msgs::Joint &_msg,
467  sdf::ElementPtr _sdf = sdf::ElementPtr());
468 
471  const google::protobuf::FieldDescriptor *GetFD(
472  google::protobuf::Message &message, const std::string &name);
474 
479  msgs::Header *GetHeader(google::protobuf::Message &_message);
480 
482  }
483 }
484 
485 #endif
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.
Forward declarations for the common classes.
Definition: Animation.hh:24
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.
GAZEBO_VISIBLE msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf)
Create a msgs::Scene from a scene SDF element.
GAZEBO_VISIBLE msgs::Vector3d Convert(const math::Vector3 &_v)
Convert a math::Vector3 to a msgs::Vector3d.
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())
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 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 void AddBoxLink(msgs::Model &_model, const double _mass, const math::Vector3 &_size)
Add a simple box link to a Model message.
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 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.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
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.