YARP
Yet Another Robot Platform
JoypadControlServer.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 
9 #ifndef YARP_DEV_JOYPADCONTROLSERVER_JOYPADCONTROLSERVER_H
10 #define YARP_DEV_JOYPADCONTROLSERVER_JOYPADCONTROLSERVER_H
11 
12 #include <yarp/os/PeriodicThread.h>
13 #include <yarp/dev/DeviceDriver.h>
15 #include <yarp/dev/IWrapper.h>
17 #include <yarp/dev/PolyDriver.h>
19 #include <yarp/os/BufferedPort.h>
20 #include <yarp/os/Bottle.h>
21 #include <map>
22 #include <JoypadControlNetUtils.h>
23 
24 
27 {
28 private:
29  typedef bool (yarp::dev::IJoypadController::*getcountmethod)(unsigned int&);
30 
31  std::map<int, getcountmethod> countGetters;
33 public:
35  ~JoypadCtrlParser() override = default;
36 
37  bool configure(yarp::dev::IJoypadController* interface);
38  bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
39 };
40 
48  public yarp::dev::IWrapper,
51 {
53  typedef yarp::sig::Vector Vector;
55 
56  template<typename T>
58 
59  double m_period;
60  JoypadCtrlParser m_parser;
62  yarp::os::Port m_rpcPort;
63  yarp::dev::PolyDriver* m_subDeviceOwned;
64  bool m_isSubdeviceOwned;
65  bool m_separatePorts;
66  bool m_profile;
67  std::string m_rpcPortName;
68  std::string m_name;
69  JoyPort<Vector> m_portAxis;
70  JoyPort<Vector> m_portStick;
71  JoyPort<Vector> m_portTouch;
72  JoyPort<Vector> m_portButtons;
73  JoyPort<VecOfChar> m_portHats;
74  JoyPort<Vector> m_portTrackball;
75  yarp::os::BufferedPort<JoyData> m_godPort; //TODO: single port purpose
76  coordsMode m_coordsMode;
77 
78 
79  bool openAndAttachSubDevice(yarp::os::Searchable& prop);
80  bool openPorts();
81  void profile();
82 
83 public:
89  ~JoypadControlServer() override;
90 
91  bool open(yarp::os::Searchable& params) override;
93  bool close() override;
94  bool attachAll(const yarp::dev::PolyDriverList& p) override;
95  bool detachAll() override;
96  bool attach(yarp::dev::PolyDriver* poly) override;
98  bool detach() override;
99  bool threadInit() override;
100  void threadRelease() override;
101  void run() override;
102 };
103 
104 #endif
yarp::dev::IJoypadController::JoypadCtrl_coordinateMode
JoypadCtrl_coordinateMode
Definition: IJoypadController.h:37
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
JoypadControlServer
JoypadControlServer: Documentation to be added
Definition: JoypadControlServer.h:51
JoypadControlServer::detachAll
bool detachAll() override
Detach the object (you must have first called attach).
Definition: JoypadControlServer.cpp:824
IWrapper.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
JoypadControlNetUtils.h
JoypadControlServer::detach
bool detach() override
Detach the object (you must have first called attach).
Definition: JoypadControlServer.cpp:384
JoypadControlServer::~JoypadControlServer
~JoypadControlServer() override
Definition: JoypadControlServer.cpp:239
yarp::dev::PolyDriverList
Definition: PolyDriverList.h:22
JoypadControlServer::attachAll
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
Definition: JoypadControlServer.cpp:788
PolyDriverList.h
JoypadControlServer::operator=
JoypadControlServer & operator=(const JoypadControlServer &)=delete
yarp::sig::VectorOf
Provides:
Definition: Vector.h:122
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::BufferedPort< JoyData >
PolyDriver.h
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
JoypadCtrlParser::respond
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
Definition: JoypadControlServer.cpp:61
JoypadControlServer::open
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
Definition: JoypadControlServer.cpp:249
yarp::dev::IWrapper
Interface for an object that can wrap/or "attach" to another.
Definition: IWrapper.h:29
JoypadControl::JoyPort
Definition: JoypadControlNetUtils.h:50
JoypadCtrlParser::JoypadCtrlParser
JoypadCtrlParser()
Definition: JoypadControlServer.cpp:27
BufferedPort.h
IMultipleWrapper.h
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
JoypadControlServer::fromConfig
bool fromConfig(yarp::os::Searchable &params)
JoypadControlServer::attach
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
Definition: JoypadControlServer.cpp:360
JoypadControlServer::close
bool close() override
Close the DeviceDriver.
Definition: JoypadControlServer.cpp:837
PeriodicThread.h
JoypadControlServer::threadRelease
void threadRelease() override
Release method.
Definition: JoypadControlServer.cpp:396
JoypadControlServer::JoypadControlServer
JoypadControlServer()
Definition: JoypadControlServer.cpp:227
yarp::dev::DeviceResponder
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:134
JoypadControlServer::run
void run() override
Loop function.
Definition: JoypadControlServer.cpp:649
yarp::dev::IMultipleWrapper
Interface for an object that can wrap/attach to to another.
Definition: IMultipleWrapper.h:30
JoypadControlServer::operator=
JoypadControlServer & operator=(JoypadControlServer &&)=delete
JoypadControlServer::JoypadControlServer
JoypadControlServer(const JoypadControlServer &)=delete
JoypadCtrlParser::configure
bool configure(yarp::dev::IJoypadController *interface)
Definition: JoypadControlServer.cpp:37
JoypadControlServer::JoypadControlServer
JoypadControlServer(JoypadControlServer &&)=delete
JoypadControlServer::threadInit
bool threadInit() override
Initialization method.
Definition: JoypadControlServer.cpp:390
IJoypadController.h
JoypadCtrlParser::~JoypadCtrlParser
~JoypadCtrlParser() override=default
yarp::dev::IJoypadController
Definition: IJoypadController.h:35
Bottle.h
JoypadCtrlParser
Definition: JoypadControlServer.h:27
DeviceDriver.h