yarp-devices
LeapMotionSensor.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __LEAP_MOTION_SENSOR_HPP__
4 #define __LEAP_MOTION_SENSOR_HPP__
5 
6 #include <Leap.h>
7 
8 #include <yarp/dev/DeviceDriver.h>
9 #include <yarp/dev/IAnalogSensor.h>
10 
11 #include <yarp/sig/Vector.h>
12 
13 namespace roboticslab
14 {
15 
31 class LeapMotionSensor : public yarp::dev::DeviceDriver,
32  public yarp::dev::IAnalogSensor
33 {
34 public:
35 
36  LeapMotionSensor() : controller(nullptr)
37  { }
38 
39  ~LeapMotionSensor() override
40  { close(); }
41 
42  // --------- DeviceDriver Declarations. Implementation in DeviceDriverImpl.cpp ---------
43  bool open(yarp::os::Searchable& config) override;
44  bool close() override;
45 
46  // --------- IAnalogSensor Declarations. Implementation in IAnalogSensorImpl.cpp ---------
52  int read(yarp::sig::Vector &out) override;
53 
59  int getState(int ch) override;
60 
65  int getChannels() override;
66 
71  int calibrateSensor() override;
72 
78  int calibrateSensor(const yarp::sig::Vector& value) override;
79 
85  int calibrateChannel(int ch) override;
86 
93  int calibrateChannel(int ch, double value) override;
94 
95 protected:
96 
97  Leap::Controller * controller;
98  int32_t currentHandId;
99  yarp::sig::Vector lastValidData;
100 };
101 
102 } // namespace roboticslab
103 
104 #endif // __LEAP_MOTION_SENSOR_HPP__
Implementation for the LeapMotionSensor controller.
Definition: LeapMotionSensor.hpp:33
int getChannels() override
Definition: IAnalogSensorImpl.cpp:73
int read(yarp::sig::Vector &out) override
Definition: IAnalogSensorImpl.cpp:13
int calibrateSensor() override
Definition: IAnalogSensorImpl.cpp:80
int getState(int ch) override
Definition: IAnalogSensorImpl.cpp:66
int calibrateChannel(int ch) override
Definition: IAnalogSensorImpl.cpp:94
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6