yarp-devices
SpaceNavigator.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __SPACE_NAVIGATOR_HPP__
4 #define __SPACE_NAVIGATOR_HPP__
5 
6 #include <spnav.h>
7 
8 #include <yarp/dev/DeviceDriver.h>
9 #include <yarp/dev/IAnalogSensor.h>
10 
11 namespace roboticslab
12 {
13 
33 class SpaceNavigator : public yarp::dev::DeviceDriver,
34  public yarp::dev::IAnalogSensor
35 {
36 public:
37 
38  ~SpaceNavigator() override
39  { close(); }
40 
41  // --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
42  bool open(yarp::os::Searchable & config) override;
43  bool close() override;
44 
45  // --------- IAnalogSensor Declarations. Implementation in IAnalogSensorImpl.cpp ---------
51  int read(yarp::sig::Vector & out) override;
52 
58  int getState(int ch) override;
59 
64  int getChannels() override;
65 
70  int calibrateSensor() override;
71 
77  int calibrateSensor(const yarp::sig::Vector & value) override;
78 
84  int calibrateChannel(int ch) override;
85 
92  int calibrateChannel(int ch, double value) override;
93 
94 private:
95 
96  double dx {0.0};
97  double dy {0.0};
98  double dz {0.0};
99 
100  double droll {0.0};
101  double dpitch {0.0};
102  double dyaw {0.0};
103 
104  int button1 {0};
105  int button2 {0};
106 
107  unsigned int noDataCounter {0};
108  double deadband {0.0};
109 };
110 
111 } // namespace roboticslab
112 
113 #endif // __SPACE_NAVIGATOR_HPP__
Implementation for the SpaceNavigator 3D mouse.
Definition: SpaceNavigator.hpp:35
int read(yarp::sig::Vector &out) override
Definition: IAnalogSensorImpl.cpp:43
int getChannels() override
Definition: IAnalogSensorImpl.cpp:102
int calibrateSensor() override
Definition: IAnalogSensorImpl.cpp:109
int getState(int ch) override
Definition: IAnalogSensorImpl.cpp:95
int calibrateChannel(int ch) override
Definition: IAnalogSensorImpl.cpp:123
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6