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
12#include <yarp/dev/IWrapper.h>
14#include <yarp/dev/PolyDriver.h>
17#include <yarp/os/Bottle.h>
18#include <map>
20
21
24{
25private:
26 typedef bool (yarp::dev::IJoypadController::*getcountmethod)(unsigned int&);
27
28 std::map<int, getcountmethod> countGetters;
30public:
32 ~JoypadCtrlParser() override = default;
33
35 bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
36};
37
48{
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
80public:
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
JoypadControlServer & operator=(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.
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:30
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:151
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:25
A container for a device driver.
Definition: PolyDriver.h:23
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:46
A base class for nested structures that can be searched.
Definition: Searchable.h:63