17 #ifndef GZ_MSGS_CONVERT_SPHERICALCOORDINATES_HH_
18 #define GZ_MSGS_CONVERT_SPHERICALCOORDINATES_HH_
21 #include "gz/msgs/spherical_coordinates.pb.h"
24 #include <gz/math/SphericalCoordinates.hh>
28 inline namespace GZ_MSGS_VERSION_NAMESPACE {
35 auto result = msgs::SphericalCoordinatesType::LOCAL2;
38 case math::SphericalCoordinates::CoordinateType::ECEF:
39 result = msgs::SphericalCoordinatesType::ECEF;
41 case math::SphericalCoordinates::CoordinateType::GLOBAL:
42 result = msgs::SphericalCoordinatesType::GLOBAL;
44 case math::SphericalCoordinates::CoordinateType::SPHERICAL:
45 result = msgs::SphericalCoordinatesType::SPHERICAL;
47 case math::SphericalCoordinates::CoordinateType::LOCAL:
48 result = msgs::SphericalCoordinatesType::LOCAL;
50 case math::SphericalCoordinates::CoordinateType::LOCAL2:
51 result = msgs::SphericalCoordinatesType::LOCAL2;
61 const msgs::SphericalCoordinatesType &_sc)
65 case msgs::SphericalCoordinatesType::ECEF:
66 return math::SphericalCoordinates::CoordinateType::ECEF;
67 case msgs::SphericalCoordinatesType::GLOBAL:
68 return math::SphericalCoordinates::CoordinateType::GLOBAL;
69 case msgs::SphericalCoordinatesType::SPHERICAL:
70 return math::SphericalCoordinates::CoordinateType::SPHERICAL;
71 case msgs::SphericalCoordinatesType::LOCAL:
72 return math::SphericalCoordinates::CoordinateType::LOCAL;
73 case msgs::SphericalCoordinatesType::LOCAL2:
74 return math::SphericalCoordinates::CoordinateType::LOCAL2;
78 return math::SphericalCoordinates::CoordinateType::LOCAL2;
82 inline void Set(gz::msgs::SphericalCoordinates *_msg,
87 _msg->set_surface_model(msgs::SphericalCoordinates::EARTH_WGS84);
91 _msg->set_surface_model(msgs::SphericalCoordinates::MOON_SCS);
96 _msg->set_surface_model(
97 msgs::SphericalCoordinates::CUSTOM_SURFACE);
103 std::cerr <<
"Unrecognized spherical surface type ["
105 <<
"]. Not populating message field." <<
std::endl;
114 const gz::msgs::SphericalCoordinates &_msg)
116 if (_msg.surface_model() == msgs::SphericalCoordinates::EARTH_WGS84)
120 else if (_msg.surface_model() == msgs::SphericalCoordinates::MOON_SCS)
124 else if (_msg.surface_model() == msgs::SphericalCoordinates::CUSTOM_SURFACE)
127 _msg.surface_axis_equatorial(),
128 _msg.surface_axis_polar());
132 std::cerr <<
"Unrecognized spherical surface type ["
133 << _msg.surface_model()
134 <<
"]. Not populating data field." <<
std::endl;
138 lat.SetDegree(_msg.latitude_deg());
142 lon.SetDegree(_msg.longitude_deg());
146 head.SetDegree(_msg.heading_deg());
152 inline gz::msgs::SphericalCoordinates
155 gz::msgs::SphericalCoordinates ret;
161 Convert(
const gz::msgs::SphericalCoordinates &_msg)