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 
43  public yarp::dev::IWrapper,
46 {
48  typedef yarp::sig::Vector Vector;
50 
51  template<typename T>
53 
54  double m_period;
55  JoypadCtrlParser m_parser;
57  yarp::os::Port m_rpcPort;
58  yarp::dev::PolyDriver* m_subDeviceOwned;
59  bool m_isSubdeviceOwned;
60  bool m_separatePorts;
61  bool m_profile;
62  std::string m_rpcPortName;
63  std::string m_name;
64  JoyPort<Vector> m_portAxis;
65  JoyPort<Vector> m_portStick;
66  JoyPort<Vector> m_portTouch;
67  JoyPort<Vector> m_portButtons;
68  JoyPort<VecOfChar> m_portHats;
69  JoyPort<Vector> m_portTrackball;
70  yarp::os::BufferedPort<JoyData> m_godPort; //TODO: single port purpose
71  coordsMode m_coordsMode;
72 
73 
74  bool openAndAttachSubDevice(yarp::os::Searchable& prop);
75  bool openPorts();
76  void profile();
77 
78 public:
84  ~JoypadControlServer() override;
85 
86  bool open(yarp::os::Searchable& params) override;
88  bool close() override;
89  bool attachAll(const yarp::dev::PolyDriverList& p) override;
90  bool detachAll() override;
91  bool attach(yarp::dev::PolyDriver* poly) override;
93  bool detach() override;
94  bool threadInit() override;
95  void threadRelease() override;
96  void run() override;
97 };
98 
99 #endif
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:38
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:134
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:29
A container for a device driver.
Definition: PolyDriver.h:27
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:50
A base class for nested structures that can be searched.
Definition: Searchable.h:69