ImuSensor.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 _GAZEBO_IMUSENSOR_HH_
18 #define _GAZEBO_IMUSENSOR_HH_
19 
20 #include <vector>
21 #include <string>
22 #include <ignition/math/Pose3.hh>
23 #include <ignition/math/Quaternion.hh>
24 #include <ignition/math/Vector3.hh>
25 
27 #include "gazebo/sensors/Sensor.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace sensors
33  {
36 
40  {
42  public: ImuSensor();
43 
45  public: virtual ~ImuSensor();
46 
47  // Documentation inherited.
48  protected: void Load(const std::string &_worldName, sdf::ElementPtr _sdf);
49 
50  // Documentation inherited.
51  protected: virtual void Load(const std::string &_worldName);
52 
54  public: virtual void Init();
55 
56  // Documentation inherited
57  protected: virtual bool UpdateImpl(bool _force);
58 
59  // Documentation inherited
60  protected: virtual void Fini();
61 
64  public: msgs::IMU GetImuMessage() const;
65 
70  public: math::Vector3 GetAngularVelocity() const GAZEBO_DEPRECATED(6.0);
71 
76  public: math::Vector3 GetLinearAcceleration() const
77  GAZEBO_DEPRECATED(6.0);
78 
84  public: math::Quaternion GetOrientation() const GAZEBO_DEPRECATED(6.0);
85 
90  public: ignition::math::Vector3d AngularVelocity(
91  const bool _noiseFree = false) const;
92 
97  public: ignition::math::Vector3d LinearAcceleration(
98  const bool _noiseFree = false) const;
99 
103  public: ignition::math::Quaterniond Orientation() const;
104 
106  public: void SetReferencePose();
107 
108  // Documentation inherited.
109  public: virtual bool IsActive();
110 
113  private: void OnLinkData(ConstLinkDataPtr &_msg);
114 
116  private: ignition::math::Pose3d referencePose;
117 
119  private: ignition::math::Vector3d lastLinearVel;
120 
122  private: ignition::math::Vector3d linearAcc;
123 
125  private: ignition::math::Vector3d gravity;
126 
128  private: transport::PublisherPtr pub;
129 
131  private: transport::SubscriberPtr linkDataSub;
132 
134  private: physics::LinkPtr parentEntity;
135 
137  private: msgs::IMU imuMsg;
138 
140  private: mutable boost::mutex mutex;
141 
143  private: boost::shared_ptr<msgs::LinkData const> incomingLinkData[2];
144 
146  private: unsigned int dataIndex;
147 
149  private: bool dataDirty;
150 
152  private: ignition::math::Vector3d angularVel;
153  };
155  }
156 }
157 #endif
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:47
default namespace for gazebo
A quaternion class.
Definition: Quaternion.hh:42
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An IMU sensor.
Definition: ImuSensor.hh:39
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Base class for sensors.
Definition: Sensor.hh:69
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:92