yarp-devices
Loading...
Searching...
No Matches
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 <mutex>
7
8#include <yarp/os/Thread.h>
9
10#include <yarp/dev/DeviceDriver.h>
11#include <yarp/dev/IJoypadController.h>
12
13#include <spnav.h>
14
15#include "SpaceNavigator_ParamsParser.h"
16
36class SpaceNavigator : public yarp::dev::DeviceDriver,
37 public yarp::dev::IJoypadController,
38 public yarp::os::Thread, // not using PeriodicThread for performance reasons
40{
41public:
42 // --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
43 bool open(yarp::os::Searchable & config) override;
44 bool close() override;
45
46 // --------- Thread Declarations. Implementation in ThreadImpl.cpp ---------
47 void run() override;
48
49 // --------- IAnalogSensor Declarations. Implementation in IJoypadControllerImpl.cpp ---------
50 bool getAxisCount(unsigned int & axis_count) override;
51 bool getButtonCount(unsigned int & button_count) override;
52 bool getTrackballCount(unsigned int & trackball_count) override;
53 bool getHatCount(unsigned int & hat_count) override;
54 bool getTouchSurfaceCount(unsigned int & touch_count) override;
55 bool getStickCount(unsigned int & stick_count) override;
56 bool getStickDoF(unsigned int stick_id, unsigned int & DoF) override;
57 bool getButton(unsigned int button_id, float & value) override;
58 bool getTrackball(unsigned int trackball_id, yarp::sig::Vector & value) override;
59 bool getHat(unsigned int hat_id, unsigned char & value) override;
60 bool getAxis(unsigned int axis_id, double & value) override;
61 bool getStick(unsigned int stick_id, yarp::sig::Vector & value, yarp::dev::IJoypadController::JoypadCtrl_coordinateMode coordinate_mode) override;
62 bool getTouch(unsigned int touch_id, yarp::sig::Vector & value) override;
63
64private:
65 double dx {0.0};
66 double dy {0.0};
67 double dz {0.0};
68
69 double drx {0.0};
70 double dry {0.0};
71 double drz {0.0};
72
73 float button1 {0.f};
74 float button2 {0.f};
75
76 double deadband {0.0};
77
78 mutable std::mutex mtx;
79};
80
81#endif // __SPACE_NAVIGATOR_HPP__
Definition SpaceNavigator_ParamsParser.h:49
Implementation for the SpaceNavigator 3D mouse.
Definition SpaceNavigator.hpp:40