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>
28
29namespace gazebo
30{
31 class GZ_PLUGIN_VISIBLE RazerHydra : public WorldPlugin
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
Definition HydraPlugin.hh:32
void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
Load function.
virtual ~RazerHydra()
Destructor.
RazerHydra()
Constructor.
A plugin with access to physics::World.
Definition Plugin.hh:279
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
boost::shared_ptr< Connection > ConnectionPtr
Definition CommonTypes.hh:134
boost::shared_ptr< World > WorldPtr
Definition PhysicsTypes.hh:89
boost::shared_ptr< Publisher > PublisherPtr
Definition TransportTypes.hh:49
boost::shared_ptr< Node > NodePtr
Definition TransportTypes.hh:57
Forward declarations for the common classes.
Definition Animation.hh:27