Gazebo Sensors

API Reference

6.9.0
gz/sensors/ImuSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 GZ_SENSORS_IMUSENSOR_HH_
18 #define GZ_SENSORS_IMUSENSOR_HH_
19 
20 #include <memory>
21 
22 #include <sdf/sdf.hh>
23 
24 #include <gz/common/SuppressWarning.hh>
25 #include <gz/math/Pose3.hh>
26 
27 #include <gz/sensors/config.hh>
28 #include <gz/sensors/imu/Export.hh>
29 
30 #include "gz/sensors/Sensor.hh"
31 
32 namespace ignition
33 {
34  namespace sensors
35  {
37  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
38 
40  enum class IGNITION_SENSORS_VISIBLE WorldFrameEnumType
41  {
44  NONE = 0,
45 
47  ENU = 1,
48 
50  NED = 2,
51 
53  NWU = 3,
54 
56  CUSTOM = 4
57  };
58 
61  class ImuSensorPrivate;
62 
67  class IGNITION_SENSORS_IMU_VISIBLE ImuSensor : public Sensor
68  {
70  public: ImuSensor();
71 
73  public: virtual ~ImuSensor();
74 
78  public: virtual bool Load(const sdf::Sensor &_sdf) override;
79 
83  public: virtual bool Load(sdf::ElementPtr _sdf) override;
84 
87  public: virtual bool Init() override;
88 
92  public: virtual bool Update(
93  const std::chrono::steady_clock::duration &_now) override;
94 
98  public: void SetAngularVelocity(const math::Vector3d &_angularVel);
99 
103  public: math::Vector3d AngularVelocity() const;
104 
108  public: void SetLinearAcceleration(const math::Vector3d &_linearAcc);
109 
113  public: math::Vector3d LinearAcceleration() const;
114 
117  public: void SetWorldPose(const math::Pose3d _pose);
118 
121  public: math::Pose3d WorldPose() const;
122 
128  const math::Quaterniond &_orient);
129 
132  public: math::Quaterniond OrientationReference() const;
133 
139  public: math::Quaterniond Orientation() const;
140 
143  public: void SetGravity(const math::Vector3d &_gravity);
144 
150  public: void SetOrientationEnabled(bool _enabled);
151 
154  public: bool OrientationEnabled() const;
155 
158  public: math::Vector3d Gravity() const;
159 
165  const math::Quaterniond &_rot, WorldFrameEnumType _relativeTo);
166 
170  public: bool HasConnections() const;
171 
172  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
175  private: std::unique_ptr<ImuSensorPrivate> dataPtr;
176  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
177  };
178  }
179  }
180 }
181 
182 #endif
Imu Sensor Class.
Definition: gz/sensors/ImuSensor.hh:68
math::Vector3d LinearAcceleration() const
Get the linear acceleration of the imu.
bool OrientationEnabled() const
Get whether or not orientation is enabled.
virtual ~ImuSensor()
destructor
void SetOrientationEnabled(bool _enabled)
Set whether to output orientation. Not all imu's generate orientation values as they use filters to p...
void SetGravity(const math::Vector3d &_gravity)
Set the gravity vector.
math::Vector3d AngularVelocity() const
Get the angular velocity of the imu.
void SetOrientationReference(const math::Quaterniond &_orient)
Set the orientation reference, i.e. initial imu orientation. Imu orientation data generated will be r...
virtual bool Load(sdf::ElementPtr _sdf) override
Load the sensor with SDF parameters.
virtual bool Load(const sdf::Sensor &_sdf) override
Load the sensor based on data from an sdf::Sensor object.
void SetLinearAcceleration(const math::Vector3d &_linearAcc)
Set the linear acceleration of the imu.
virtual bool Update(const std::chrono::steady_clock::duration &_now) override
Update the sensor and generate data.
math::Quaterniond Orientation() const
Get the orienation of the imu with respect to reference frame.
void SetWorldPose(const math::Pose3d _pose)
Set the world pose of the imu.
void SetWorldFrameOrientation(const math::Quaterniond &_rot, WorldFrameEnumType _relativeTo)
Specify the rotation offset of the coordinates of the World frame relative to a geo-referenced frame.
void SetAngularVelocity(const math::Vector3d &_angularVel)
Set the angular velocity of the imu.
math::Pose3d WorldPose() const
Get the world pose of the imu.
math::Quaterniond OrientationReference() const
Get the world orienation reference of the imu.
virtual bool Init() override
Initialize values in the sensor.
bool HasConnections() const
Check if there are any subscribers.
math::Vector3d Gravity() const
Get the gravity vector.
a base sensor class
Definition: gz/sensors/Sensor.hh:60
WorldFrameEnumType
Inline bracket to help doxygen filtering.
Definition: gz/sensors/ImuSensor.hh:41
@ ENU
ENU (East-North-Up): x - East, y - North, z - Up.
@ NWU
NWU (North-West-Up): x - North, y - West, z - Up.
@ NED
NED (North-East-Down): x - North, y - East, z - Down.
Definition: gz/sensors/AirPressureSensor.hh:32