SphericalCoordinates.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_SPHERICALCOORDINATES_HH_
18#define _GAZEBO_SPHERICALCOORDINATES_HH_
19
20#include <string>
21
22#include <ignition/math/Angle.hh>
23#include <ignition/math/Vector3.hh>
24
26#include "gazebo/util/system.hh"
27
28namespace gazebo
29{
30 namespace common
31 {
32 class SphericalCoordinatesPrivate;
33
36
39 class GZ_COMMON_VISIBLE SphericalCoordinates
40 {
43 public: enum SurfaceType
44 {
47 EARTH_WGS84 = 1
48 };
49
52 public: enum CoordinateType
53 {
55 SPHERICAL = 1,
56
58 ECEF = 2,
59
61 GLOBAL = 3,
62
64 LOCAL = 4
65 };
66
69
72 public: explicit SphericalCoordinates(const SurfaceType _type);
73
80 public: SphericalCoordinates(const SurfaceType _type,
81 const ignition::math::Angle &_latitude,
82 const ignition::math::Angle &_longitude,
83 double _elevation,
84 const ignition::math::Angle &_heading);
85
88
93 public: ignition::math::Vector3d SphericalFromLocal(
94 const ignition::math::Vector3d &_xyz) const;
95
100 public: ignition::math::Vector3d GlobalFromLocal(
101 const ignition::math::Vector3d &_xyz) const;
102
106 public: static SurfaceType Convert(const std::string &_str);
107
117 public: static double Distance(const ignition::math::Angle &_latA,
118 const ignition::math::Angle &_lonA,
119 const ignition::math::Angle &_latB,
120 const ignition::math::Angle &_lonB);
121
125
128 public: ignition::math::Angle LatitudeReference() const;
129
132 public: ignition::math::Angle LongitudeReference() const;
133
136 public: double GetElevationReference() const;
137
142 public: ignition::math::Angle HeadingOffset() const;
143
146 public: void SetSurfaceType(const SurfaceType &_type);
147
150 public: void SetLatitudeReference(const ignition::math::Angle &_angle);
151
154 public: void SetLongitudeReference(const ignition::math::Angle &_angle);
155
158 public: void SetElevationReference(double _elevation);
159
162 public: void SetHeadingOffset(const ignition::math::Angle &_angle);
163
167 public: ignition::math::Vector3d LocalFromSpherical(
168 const ignition::math::Vector3d &_xyz) const;
169
174 public: ignition::math::Vector3d LocalFromGlobal(
175 const ignition::math::Vector3d &_xyz) const;
176
179
185 public: ignition::math::Vector3d
186 PositionTransform(const ignition::math::Vector3d &_pos,
187 const CoordinateType &_in, const CoordinateType &_out) const;
188
194 public: ignition::math::Vector3d VelocityTransform(
195 const ignition::math::Vector3d &_vel,
196 const CoordinateType &_in, const CoordinateType &_out) const;
197
200 private: SphericalCoordinatesPrivate *dataPtr;
201 };
203 }
204}
205#endif
common
Definition FuelModelDatabase.hh:37
Convert spherical coordinates for planetary surfaces.
Definition SphericalCoordinates.hh:40
void UpdateTransformationMatrix()
Update coordinate transformation matrix with reference location.
SphericalCoordinates(const SurfaceType _type)
Constructor with surface type input.
SurfaceType
Unique identifiers for planetary surface models.
Definition SphericalCoordinates.hh:44
@ EARTH_WGS84
Model of reference ellipsoid for earth, based on WGS 84 standard.
Definition SphericalCoordinates.hh:47
static double Distance(const ignition::math::Angle &_latA, const ignition::math::Angle &_lonA, const ignition::math::Angle &_latB, const ignition::math::Angle &_lonB)
Get the distance between two points expressed in geographic latitude and longitude.
ignition::math::Angle LatitudeReference() const
Get reference geodetic latitude.
void SetLatitudeReference(const ignition::math::Angle &_angle)
Set reference geodetic latitude.
ignition::math::Angle HeadingOffset() const
Get heading offset for gazebo reference frame, expressed as angle from East to gazebo x-axis,...
void SetElevationReference(double _elevation)
Set reference elevation above sea level in meters.
SphericalCoordinates(const SurfaceType _type, const ignition::math::Angle &_latitude, const ignition::math::Angle &_longitude, double _elevation, const ignition::math::Angle &_heading)
Constructor with surface type, angle, and elevation inputs.
ignition::math::Vector3d GlobalFromLocal(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian velocity vector in the local gazebo frame to a global Cartesian frame with compon...
double GetElevationReference() const
Get reference elevation in meters.
static SurfaceType Convert(const std::string &_str)
Convert a string to a SurfaceType.
void SetLongitudeReference(const ignition::math::Angle &_angle)
Set reference longitude.
ignition::math::Vector3d LocalFromGlobal(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian vector with components East, North, Up to a local Gazebo cartesian frame vector X...
ignition::math::Vector3d VelocityTransform(const ignition::math::Vector3d &_vel, const CoordinateType &_in, const CoordinateType &_out) const
Convert between velocity in SPHERICAL/ECEF/LOCAL/GLOBAL frame.
void SetHeadingOffset(const ignition::math::Angle &_angle)
Set heading angle offset for gazebo frame.
ignition::math::Vector3d PositionTransform(const ignition::math::Vector3d &_pos, const CoordinateType &_in, const CoordinateType &_out) const
Convert between positions in SPHERICAL/ECEF/LOCAL/GLOBAL frame.
ignition::math::Vector3d LocalFromSpherical(const ignition::math::Vector3d &_xyz) const
Convert a geodetic position vector to Cartesian coordinates.
ignition::math::Vector3d SphericalFromLocal(const ignition::math::Vector3d &_xyz) const
Convert a Cartesian position vector to geodetic coordinates.
CoordinateType
Unique identifiers for coordinate types.
Definition SphericalCoordinates.hh:53
@ ECEF
Earth centered, earth fixed Cartesian.
Definition SphericalCoordinates.hh:58
@ LOCAL
Heading-adjusted tangent plane (X, Y, Z)
Definition SphericalCoordinates.hh:64
@ SPHERICAL
Latitude, Longitude and Altitude by SurfaceType.
Definition SphericalCoordinates.hh:55
@ GLOBAL
Local tangent plane (East, North, Up)
Definition SphericalCoordinates.hh:61
void SetSurfaceType(const SurfaceType &_type)
Set SurfaceType for planetary surface model.
ignition::math::Angle LongitudeReference() const
Get reference longitude.
SurfaceType GetSurfaceType() const
Get SurfaceType currently in use.
Forward declarations for the common classes.
Definition Animation.hh:27