12#define DEFAULT_THREAD_PERIOD 0.010
35 for (
size_t i = 0;
i < b.
size();
i++)
77 if(m_countGetters.find(
toGet) != m_countGetters.end())
82 if((m_device->*
getter)(count))
145 for(
size_t i = 0;
i <
frame.size(); ++
i)
178 for(
size_t i = 0;
i < pos.
size(); ++
i)
195 for(
size_t i = 0;
i < axes.
size(); ++
i)
242 m_rpcPortName =
m_name +
"/rpc:i";
243 m_portButtons.name =
m_name +
"/buttons:o";
244 m_portAxis.name =
m_name +
"/axis:o";
245 m_portStick.name =
m_name +
"/stick:o";
246 m_portTouch.name =
m_name +
"/touch:o";
247 m_portTrackball.name =
m_name +
"/trackball:o";
248 m_portHats.name =
m_name +
"/hat:o";
257 poly->
view(m_IJoypad);
260 if(m_IJoypad ==
nullptr)
302bool JoypadControlServer::openPorts()
309 if(!m_rpcPort.
open(m_rpcPortName))
444 if(
getter.port->count == 0)
446 getter.port->valid =
false;
451 getter.port->valid =
true;
469void JoypadControlServer::profile()
476 for(
unsigned int i = 0;
i < count; ++
i)
480 message += std::to_string(data) +
" ";
486 for(
unsigned int i = 0;
i < count; ++
i)
490 message += std::to_string(data) +
" ";
494 message =
"Buttons: ";
496 for(
unsigned int i = 0;
i < count; ++
i)
500 message += std::to_string(data) +
" ";
506 for(
unsigned int i = 0;
i < count; ++
i)
510 message +=
"n_" + std::to_string(
i) +
": ";
511 for (
size_t j = 0;
j < data.
size(); ++
j)
513 message += std::to_string(data[
j]) +
" ";
520 message =
"trackball: ";
522 for(
unsigned int i = 0;
i < count; ++
i)
526 message +=
"n_" + std::to_string(
i) +
": ";
527 for (
size_t j = 0;
j < data.
size(); ++
j)
529 message += std::to_string(data[
j]) +
" ";
534 message =
"touch Surface: ";
536 for(
unsigned int i = 0;
i < count; ++
i)
540 message +=
"n_" + std::to_string(
i) +
": ";
541 for (
size_t j = 0;
j < data.
size(); ++
j)
543 message += std::to_string(data[
j]) +
" ";
554 if (m_portButtons.valid)
560 for(
size_t i = 0;
i < m_portButtons.count; ++
i)
571 m_portButtons.
write();
575 if (m_portHats.valid)
582 for(
size_t i = 0;
i < m_portHats.count; ++
i)
597 if (m_portAxis.valid)
604 for(
size_t i = 0;
i < m_portAxis.count; ++
i)
620 if (m_portTrackball.valid)
627 for(
size_t i = 0;
i < m_portTrackball.count; ++
i)
639 m_portTrackball.
write();
643 if (m_portStick.valid)
649 for(
size_t i = 0;
i < m_portStick.count; ++
i)
665 if (m_portTouch.valid)
671 for(
unsigned int i = 0;
i < m_portTouch.count; ++
i)
706 std::vector<JoypadControl::LoopablePort*>
portv;
707 portv.push_back(&m_portButtons);
708 portv.push_back(&m_portAxis);
709 portv.push_back(&m_portStick);
710 portv.push_back(&m_portTouch);
711 portv.push_back(&m_portTrackball);
712 portv.push_back(&m_portHats);
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_VALUE
constexpr yarp::conf::vocab32_t VOCAB_COUNT
constexpr yarp::conf::vocab32_t VOCAB_BUTTON
constexpr yarp::conf::vocab32_t VOCAB_IJOYPADCTRL
constexpr yarp::conf::vocab32_t VOCAB_TOUCH
constexpr yarp::conf::vocab32_t VOCAB_HAT
constexpr yarp::conf::vocab32_t VOCAB_TRACKBALL
constexpr yarp::conf::vocab32_t VOCAB_CARTESIAN
constexpr yarp::conf::vocab32_t VOCAB_STICKDOF
constexpr yarp::conf::vocab32_t VOCAB_AXIS
constexpr yarp::conf::vocab32_t VOCAB_STICK
#define DEFAULT_THREAD_PERIOD
void cat(Vector &a, const Vector &b)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool m_use_separate_ports
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
void threadRelease() override
Release method.
~JoypadControlServer() override
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool close() override
Close the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
void run() override
Loop function.
bool threadInit() override
Initialization method.
bool configure(yarp::dev::IJoypadController *interface)
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
bool view(T *&x)
Get an interface to the device driver.
virtual bool getHatCount(unsigned int &Hat_count)=0
Get number of hats.
virtual bool getTrackballCount(unsigned int &Trackball_count)=0
Get number of trackballs.
virtual bool getTouchSurfaceCount(unsigned int &touch_count)=0
Get the number of touch surface.
virtual bool getButton(unsigned int button_id, float &value)=0
Get the value of a button.
virtual bool getAxisCount(unsigned int &axis_count)=0
Get number of axes.
virtual bool getAxis(unsigned int axis_id, double &value)=0
Get the value of an axis if present, return false otherwise.
virtual bool getStickCount(unsigned int &stick_count)=0
Get the number of the sticks.
virtual bool getTrackball(unsigned int trackball_id, yarp::sig::Vector &value)=0
Get the axes change of a Trackball.
virtual bool getStick(unsigned int stick_id, yarp::sig::Vector &value, JoypadCtrl_coordinateMode coordinate_mode)=0
Get the value of a stick if present, return false otherwise.
virtual bool getStickDoF(unsigned int stick_id, unsigned int &DoF)=0
Get the Degree Of Freedom count for desired stick.
virtual bool getHat(unsigned int hat_id, unsigned char &value)=0
Get the value of an Hat.
virtual bool getButtonCount(unsigned int &button_count)=0
Get number of buttons.
virtual bool getTouch(unsigned int touch_id, yarp::sig::Vector &value)=0
Get the value of a touch if present, return false otherwise.
A container for a device driver.
bool detachAll() final
Detach the object (you must have first called attach).
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An abstraction for a periodic thread.
bool setPeriod(double period)
Set the (new) period of the thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
void setReader(PortReader &reader) override
Set an external reader for port data.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual bool isInt32() const
Checks if value is a 32-bit integer.
virtual bool isVocab32() const
Checks if value is a vocabulary identifier.
void push_back(const T &elem)
Push a new element in the vector: size is changed.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.