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 
123  msgs::Joint::Type ConvertJointType(const std::string &_str);
124 
129  std::string ConvertJointType(const msgs::Joint::Type _type);
130 
135  math::Vector3 Convert(const msgs::Vector3d &_v);
136 
141  math::Vector2d Convert(const msgs::Vector2d &_v);
142 
147  math::Quaternion Convert(const msgs::Quaternion &_q);
148 
153  math::Pose Convert(const msgs::Pose &_p);
154 
159  void Set(common::Image &_img, const msgs::Image &_msg);
160 
165  common::Color Convert(const msgs::Color &_c);
166 
171  common::Time Convert(const msgs::Time &_t);
172 
177  math::Plane Convert(const msgs::PlaneGeom &_p);
178 
183  void Set(msgs::Image *_msg, const common::Image &_i);
184 
189  void Set(msgs::Vector3d *_pt, const math::Vector3 &_v);
190 
195  void Set(msgs::Vector2d *_pt, const math::Vector2d &_v);
196 
201  void Set(msgs::Quaternion *_q, const math::Quaternion &_v);
202 
207  void Set(msgs::Pose *_p, const math::Pose &_v);
208 
213  void Set(msgs::Color *_c, const common::Color &_v);
214 
219  void Set(msgs::Time *_t, const common::Time &_v);
220 
226  void Set(msgs::SphericalCoordinates *_s,
227  const common::SphericalCoordinates &_v);
228 
233  void Set(msgs::PlaneGeom *_p, const math::Plane &_v);
234 
239  msgs::TrackVisual TrackVisualFromSDF(sdf::ElementPtr _sdf);
240 
245  msgs::GUI GUIFromSDF(sdf::ElementPtr _sdf);
246 
251  msgs::Light LightFromSDF(sdf::ElementPtr _sdf);
252 
257  msgs::MeshGeom MeshFromSDF(sdf::ElementPtr _sdf);
258 
263  msgs::Geometry GeometryFromSDF(sdf::ElementPtr _sdf);
264 
269  msgs::Visual VisualFromSDF(sdf::ElementPtr _sdf);
270 
275  msgs::Fog FogFromSDF(sdf::ElementPtr _sdf);
276 
281  msgs::Scene SceneFromSDF(sdf::ElementPtr _sdf);
282 
289  sdf::ElementPtr LightToSDF(const msgs::Light &_msg,
290  sdf::ElementPtr _sdf = sdf::ElementPtr());
291 
298  sdf::ElementPtr CameraSensorToSDF(const msgs::CameraSensor &_msg,
299  sdf::ElementPtr _sdf = sdf::ElementPtr());
300 
307  sdf::ElementPtr PluginToSDF(const msgs::Plugin &_plugin,
308  sdf::ElementPtr _sdf = sdf::ElementPtr());
309 
316  sdf::ElementPtr CollisionToSDF(const msgs::Collision &_msg,
317  sdf::ElementPtr _sdf = sdf::ElementPtr());
318 
326  sdf::ElementPtr LinkToSDF(const msgs::Link &_msg,
327  sdf::ElementPtr _sdf = sdf::ElementPtr());
328 
335  sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg,
336  sdf::ElementPtr _sdf = sdf::ElementPtr());
337 
344  sdf::ElementPtr SurfaceToSDF(const msgs::Surface &_msg,
345  sdf::ElementPtr _sdf = sdf::ElementPtr());
346 
353  sdf::ElementPtr GeometryToSDF(const msgs::Geometry &_msg,
354  sdf::ElementPtr _sdf = sdf::ElementPtr());
355 
362  sdf::ElementPtr MeshToSDF(const msgs::MeshGeom &_msg,
363  sdf::ElementPtr _sdf = sdf::ElementPtr());
364 
367  const google::protobuf::FieldDescriptor *GetFD(
368  google::protobuf::Message &message, const std::string &name);
370 
375  msgs::Header *GetHeader(google::protobuf::Message &_message);
376 
378  }
379 }
380 
381 #endif
GAZEBO_VISIBLE msgs::Header * GetHeader(google::protobuf::Message &_message)
Get the header from a protobuf message.
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 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 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 an SDF element from a msgs::Light.
GAZEBO_VISIBLE sdf::ElementPtr InertialToSDF(const msgs::Inertial &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create 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 an SDF element from a msgs::Geometry.
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 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 SurfaceToSDF(const msgs::Surface &_msg, sdf::ElementPtr _sdf=sdf::ElementPtr())
Create 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 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 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.