YARP
Yet Another Robot Platform
JoypadControlClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 #include <yarp/dev/DeviceDriver.h>
11 #include <yarp/os/PeriodicThread.h>
12 #include <vector>
13 #include <JoypadControlNetUtils.h>
14 
15 #define DEFAULT_THREAD_PERIOD 10
16 
19 {
20 public:
22  virtual ~JoypadControlWatchdog() = default;
23 
24 
25  std::vector<JoypadControl::LoopablePort*> m_ports;
26  void run() override;
27 
28 };
29 
46 {
47 private:
48  //---------------utils
49  template<typename T>
51  typedef yarp::sig::Vector Vector;
53 
54  //---------------properties
55  yarp::os::Port m_rpcPort;
56  JOYPORT<Vector> m_buttonsPort;
57  JOYPORT<Vector> m_axisPort;
58  JOYPORT<Vector> m_trackballPort;
59  JOYPORT<Vector> m_touchPort;
60  JOYPORT<CharVector> m_hatsPort;
61  JOYPORT<Vector> m_stickPort;
62  std::vector<size_t> m_stickDof;
63  bool m_rpc_only;
64  std::string m_local;
65  std::string m_remote;
66 
67  JoypadControlWatchdog watchdog;
68  std::vector<JoypadControl::LoopablePort*> m_ports;
69 
70  //--------------method
71  bool getCount(const int& vocab_toget, unsigned int& value);
72  bool getJoypadInfo();
73 
74 public:
80  ~JoypadControlClient() override = default;
81 
82  //rateThread
83 
84  //DeviceDriver
85  bool open(yarp::os::Searchable& config) override;
86  bool close() override;
87 
88  //IJoypadController;
89  bool getRawAxisCount(unsigned int& axis_count) override;
90  bool getRawButtonCount(unsigned int& button_count) override;
91  bool getRawTrackballCount(unsigned int& Trackball_count) override;
92  bool getRawHatCount(unsigned int& Hat_count) override;
93  bool getRawTouchSurfaceCount(unsigned int& touch_count) override;
94  bool getRawStickCount(unsigned int& stick_count) override;
95  bool getRawStickDoF(unsigned int stick_id, unsigned int& DoF) override;
96  bool getRawButton(unsigned int button_id, float& value) override;
97  bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector& value) override;
98  bool getRawHat(unsigned int hat_id, unsigned char& value) override;
99  bool getRawAxis(unsigned int axis_id, double& value) override;
100  bool getRawStick(unsigned int stick_id, yarp::sig::Vector& value, JoypadCtrl_coordinateMode coordinate_mode) override;
101  bool getRawTouch(unsigned int touch_id, yarp::sig::Vector& value) override;
102 };
yarp::dev::IJoypadController::JoypadCtrl_coordinateMode
JoypadCtrl_coordinateMode
Definition: IJoypadController.h:37
JoypadControlClient::getRawStickCount
bool getRawStickCount(unsigned int &stick_count) override
Definition: JoypadControlClient.cpp:241
JoypadControlClient::operator=
JoypadControlClient & operator=(const JoypadControlClient &)=delete
JoypadControlClient::~JoypadControlClient
~JoypadControlClient() override=default
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
JoypadControlClient::getRawStick
bool getRawStick(unsigned int stick_id, yarp::sig::Vector &value, JoypadCtrl_coordinateMode coordinate_mode) override
Definition: JoypadControlClient.cpp:421
JoypadControlClient::operator=
JoypadControlClient & operator=(JoypadControlClient &&)=delete
JoypadControlClient::getRawTrackballCount
bool getRawTrackballCount(unsigned int &Trackball_count) override
Definition: JoypadControlClient.cpp:226
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
JoypadControlNetUtils.h
JoypadControlClient::getRawButton
bool getRawButton(unsigned int button_id, float &value) override
Definition: JoypadControlClient.cpp:266
yarp::os::PeriodicThread::PeriodicThread
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No)
Constructor.
Definition: PeriodicThread.cpp:271
yarp::dev::IJoypadEventDriven
Definition: IJoypadController.h:209
JoypadControlClient::getRawTouchSurfaceCount
bool getRawTouchSurfaceCount(unsigned int &touch_count) override
Definition: JoypadControlClient.cpp:236
JoypadControlWatchdog::m_ports
std::vector< JoypadControl::LoopablePort * > m_ports
Definition: JoypadControlClient.h:25
JoypadControlWatchdog::run
void run() override
Loop function.
Definition: JoypadControlClient.cpp:149
yarp::sig::VectorOf
Provides:
Definition: Vector.h:122
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
JoypadControlClient::getRawHatCount
bool getRawHatCount(unsigned int &Hat_count) override
Definition: JoypadControlClient.cpp:231
JoypadControlClient::close
bool close() override
Close the DeviceDriver.
Definition: JoypadControlClient.cpp:537
JoypadControlWatchdog::~JoypadControlWatchdog
virtual ~JoypadControlWatchdog()=default
JoypadControlClient
JoypadControlClient: joypad input network wrapper on client side
Definition: JoypadControlClient.h:46
JoypadControlClient::getRawButtonCount
bool getRawButtonCount(unsigned int &button_count) override
Definition: JoypadControlClient.cpp:216
JoypadControlClient::getRawAxisCount
bool getRawAxisCount(unsigned int &axis_count) override
Definition: JoypadControlClient.cpp:221
JoypadControlClient::getRawAxis
bool getRawAxis(unsigned int axis_id, double &value) override
Definition: JoypadControlClient.cpp:382
JoypadControlClient::getRawTouch
bool getRawTouch(unsigned int touch_id, yarp::sig::Vector &value) override
Definition: JoypadControlClient.cpp:497
JoypadControl::JoyPort
Definition: JoypadControlNetUtils.h:50
JoypadControlClient::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: JoypadControlClient.cpp:98
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
PeriodicThread.h
JoypadControlClient::JoypadControlClient
JoypadControlClient(const JoypadControlClient &)=delete
JoypadControlWatchdog
Definition: JoypadControlClient.h:19
JoypadControlClient::getRawHat
bool getRawHat(unsigned int hat_id, unsigned char &value) override
Definition: JoypadControlClient.cpp:345
JoypadControlClient::getRawStickDoF
bool getRawStickDoF(unsigned int stick_id, unsigned int &DoF) override
Definition: JoypadControlClient.cpp:246
JoypadControlClient::JoypadControlClient
JoypadControlClient(JoypadControlClient &&)=delete
JoypadControlClient::JoypadControlClient
JoypadControlClient()
Definition: JoypadControlClient.cpp:24
JoypadControlWatchdog::JoypadControlWatchdog
JoypadControlWatchdog()
Definition: JoypadControlClient.h:21
IJoypadController.h
JoypadControlClient::getRawTrackball
bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector &value) override
Definition: JoypadControlClient.cpp:305
DeviceDriver.h