SphericalCoordinates.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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/math/Angle.hh"
27 #include "gazebo/math/Vector3.hh"
28 #include "gazebo/math/Matrix3.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace common
34  {
35  class SphericalCoordinatesPrivate;
36 
39 
43  {
46  public: enum SurfaceType
47  {
50  EARTH_WGS84 = 1
51  };
52 
55  public: enum CoordinateType
56  {
58  SPHERICAL = 1,
59 
61  ECEF = 2,
62 
64  GLOBAL = 3,
65 
67  LOCAL = 4
68  };
69 
71  public: SphericalCoordinates();
72 
75  public: SphericalCoordinates(const SurfaceType _type);
76 
83  public: SphericalCoordinates(const SurfaceType _type,
84  const ignition::math::Angle &_latitude,
85  const ignition::math::Angle &_longitude,
86  double _elevation,
87  const ignition::math::Angle &_heading);
88 
90  public: ~SphericalCoordinates();
91 
96  public: ignition::math::Vector3d SphericalFromLocal(
97  const ignition::math::Vector3d &_xyz) const;
98 
103  public: ignition::math::Vector3d GlobalFromLocal(
104  const ignition::math::Vector3d &_xyz) const;
105 
109  public: static SurfaceType Convert(const std::string &_str);
110 
120  public: static double Distance(const ignition::math::Angle &_latA,
121  const ignition::math::Angle &_lonA,
122  const ignition::math::Angle &_latB,
123  const ignition::math::Angle &_lonB);
124 
127  public: SurfaceType GetSurfaceType() const;
128 
131  public: ignition::math::Angle LatitudeReference() const;
132 
135  public: ignition::math::Angle LongitudeReference() const;
136 
139  public: double GetElevationReference() const;
140 
145  public: ignition::math::Angle HeadingOffset() const;
146 
149  public: void SetSurfaceType(const SurfaceType &_type);
150 
153  public: void SetLatitudeReference(const ignition::math::Angle &_angle);
154 
157  public: void SetLongitudeReference(const ignition::math::Angle &_angle);
158 
161  public: void SetElevationReference(double _elevation);
162 
165  public: void SetHeadingOffset(const ignition::math::Angle &_angle);
166 
170  public: ignition::math::Vector3d LocalFromSpherical(
171  const ignition::math::Vector3d &_xyz) const;
172 
177  public: ignition::math::Vector3d LocalFromGlobal(
178  const ignition::math::Vector3d &_xyz) const;
179 
181  public: void UpdateTransformationMatrix();
182 
188  public: ignition::math::Vector3d
189  PositionTransform(const ignition::math::Vector3d &_pos,
190  const CoordinateType &_in, const CoordinateType &_out) const;
191 
197  public: ignition::math::Vector3d VelocityTransform(
198  const ignition::math::Vector3d &_vel,
199  const CoordinateType &_in, const CoordinateType &_out) const;
200 
203  private: SphericalCoordinatesPrivate *dataPtr;
204  };
206  }
207 }
208 #endif
Convert spherical coordinates for planetary surfaces.
Definition: SphericalCoordinates.hh:42
CoordinateType
Unique identifiers for coordinate types.
Definition: SphericalCoordinates.hh:55
#define GZ_COMMON_VISIBLE
Definition: system.hh:84
GAZEBO_VISIBLE msgs::Vector3d Convert(const ignition::math::Vector3d &_v)
Convert a ignition::math::Vector3 to a msgs::Vector3d.
commmon/common.hh
Definition: SphericalCoordinatesPrivate.hh:40
SurfaceType
Unique identifiers for planetary surface models.
Definition: SphericalCoordinates.hh:46