HydraPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-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 
18 #ifndef _GAZEBO_RAZER_HYDRA_HH_
19 #define _GAZEBO_RAZER_HYDRA_HH_
20 
21 #include <gazebo/math/Filter.hh>
22 #include <gazebo/math/Vector3.hh>
23 #include <gazebo/common/Plugin.hh>
24 
25 namespace gazebo
26 {
28  {
30  public: RazerHydra();
31 
33  public: virtual ~RazerHydra();
34 
35  // Documentation Inherited.
36  public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
37 
41  private: bool Poll(float _lowPassCornerHz = 5.0);
42 
44  private: void Run();
45 
48  private: void Update(const common::UpdateInfo &_info);
49 
51  private: int16_t rawPos[6];
52 
54  private: int16_t rawQuat[8];
55 
57  private: uint8_t rawButtons[2];
58 
60  private: double rawAnalog[6];
61 
63  private: int hidrawFd;
64 
66  private: math::Vector3 pos[2];
67 
69  private: math::Quaternion quat[2];
70 
72  private: math::OnePoleVector3 filterPos[2];
73 
75  private: math::OnePoleQuaternion filterQuat[2];
76 
78  private: float analog[6];
79 
81  private: uint8_t buttons[14];
82 
84  private: math::OnePole<float> periodEstimate;
85 
87  private: common::Time lastCycleStart;
88 
89  // Pointer to the update event connection
90  private: event::ConnectionPtr updateConnection;
91 
93  private: boost::mutex mutex;
94 
96  private: boost::thread *pollThread;
97 
99  private: bool stop;
100 
102  private: transport::NodePtr node;
103 
105  private: transport::PublisherPtr pub;
106  };
107 }
108 #endif
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
One-pole quaternion filter.
Definition: Filter.hh:102
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
A plugin with access to physics::World.
Definition: Plugin.hh:220
Information for use in an update event.
Definition: UpdateInfo.hh:30
GZ_GUI_VISIBLE void stop()
One-pole vector3 filter.
Definition: Filter.hh:131
A quaternion class.
Definition: Quaternion.hh:42
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:84
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Definition: HydraPlugin.hh:27
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
#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