HydraPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 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 
18 #ifndef GAZEBO_PLUGINS_HYDRAPLUGIN_HH_
19 #define GAZEBO_PLUGINS_HYDRAPLUGIN_HH_
20 
21 #include <mutex>
22 #include <thread>
23 
24 #include <ignition/math/Filter.hh>
25 #include <ignition/math/Quaternion.hh>
26 #include <ignition/math/Vector3.hh>
27 #include <gazebo/common/Plugin.hh>
28 
29 namespace gazebo
30 {
32  {
34  public: RazerHydra();
35 
37  public: virtual ~RazerHydra();
38 
39  // Documentation Inherited.
40  public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
41 
45  private: bool Poll(float _lowPassCornerHz = 5.0);
46 
48  private: void Run();
49 
51  private: void Update();
52 
54  private: int16_t rawPos[6];
55 
57  private: int16_t rawQuat[8];
58 
60  private: uint8_t rawButtons[2];
61 
63  private: double rawAnalog[6];
64 
66  private: int hidrawFd;
67 
69  private: ignition::math::Vector3d pos[2];
70 
72  private: ignition::math::Quaterniond quat[2];
73 
75  private: ignition::math::OnePoleVector3 filterPos[2];
76 
78  private: ignition::math::OnePoleQuaternion filterQuat[2];
79 
81  private: float analog[6];
82 
84  private: uint8_t buttons[14];
85 
87  private: ignition::math::OnePole<float> periodEstimate;
88 
90  private: common::Time lastCycleStart;
91 
92  // Pointer to the update event connection
93  private: event::ConnectionPtr updateConnection;
94 
96  private: std::mutex mutex;
97 
99  private: std::thread *pollThread;
100 
102  private: bool stop;
103 
105  private: transport::NodePtr node;
106 
108  private: transport::PublisherPtr pub;
109  };
110 }
111 #endif
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
A plugin with access to physics::World.
Definition: Plugin.hh:235
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
Definition: HydraPlugin.hh:31
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44