YARP
Yet Another Robot Platform
JoypadControlServer.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_DEV_JOYPADCONTROLSERVER_JOYPADCONTROLSERVER_H
7 #define YARP_DEV_JOYPADCONTROLSERVER_JOYPADCONTROLSERVER_H
8 
10 #include <yarp/dev/DeviceDriver.h>
12 #include <yarp/dev/IWrapper.h>
14 #include <yarp/dev/PolyDriver.h>
16 #include <yarp/os/BufferedPort.h>
17 #include <yarp/os/Bottle.h>
18 #include <map>
19 #include <JoypadControlNetUtils.h>
20 
21 
24 {
25 private:
26  typedef bool (yarp::dev::IJoypadController::*getcountmethod)(unsigned int&);
27 
28  std::map<int, getcountmethod> countGetters;
30 public:
32  ~JoypadCtrlParser() override = default;
33 
34  bool configure(yarp::dev::IJoypadController* interface);
35  bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
36 };
37 
45  public yarp::dev::IWrapper,
48 {
50  typedef yarp::sig::Vector Vector;
52 
53  template<typename T>
55 
56  double m_period;
57  JoypadCtrlParser m_parser;
59  yarp::os::Port m_rpcPort;
60  yarp::dev::PolyDriver* m_subDeviceOwned;
61  bool m_isSubdeviceOwned;
62  bool m_separatePorts;
63  bool m_profile;
64  std::string m_rpcPortName;
65  std::string m_name;
66  JoyPort<Vector> m_portAxis;
67  JoyPort<Vector> m_portStick;
68  JoyPort<Vector> m_portTouch;
69  JoyPort<Vector> m_portButtons;
70  JoyPort<VecOfChar> m_portHats;
71  JoyPort<Vector> m_portTrackball;
72  yarp::os::BufferedPort<JoyData> m_godPort; //TODO: single port purpose
73  coordsMode m_coordsMode;
74 
75 
76  bool openAndAttachSubDevice(yarp::os::Searchable& prop);
77  bool openPorts();
78  void profile();
79 
80 public:
86  ~JoypadControlServer() override;
87 
88  bool open(yarp::os::Searchable& params) override;
90  bool close() override;
91  bool attachAll(const yarp::dev::PolyDriverList& p) override;
92  bool detachAll() override;
93  bool attach(yarp::dev::PolyDriver* poly) override;
95  bool detach() override;
96  bool threadInit() override;
97  void threadRelease() override;
98  void run() override;
99 };
100 
101 #endif
JoypadControlServer: Documentation to be added
JoypadControlServer & operator=(const JoypadControlServer &)=delete
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
JoypadControlServer(JoypadControlServer &&)=delete
void threadRelease() override
Release method.
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
bool close() override
Close the DeviceDriver.
JoypadControlServer(const JoypadControlServer &)=delete
bool detach() override
Detach the object (you must have first called attach).
void run() override
Loop function.
JoypadControlServer & operator=(JoypadControlServer &&)=delete
bool fromConfig(yarp::os::Searchable &params)
bool threadInit() override
Initialization method.
bool detachAll() override
Detach the object (you must have first called attach).
bool configure(yarp::dev::IJoypadController *interface)
~JoypadCtrlParser() override=default
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:131
Interface for an object that can wrap/attach to to another.
Interface for an object that can wrap/or "attach" to another.
Definition: IWrapper.h:26
A container for a device driver.
Definition: PolyDriver.h:24
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:47
A base class for nested structures that can be searched.
Definition: Searchable.h:66