YARP
Yet Another Robot Platform
RPCMessagesParser.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_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
7#define YARP_DEV_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
8
9
10// This file contains helper functions for the ControlBoardWrapper
11
13#include <yarp/os/Network.h>
15#include <yarp/os/Stamp.h>
16#include <yarp/os/Time.h>
17#include <yarp/os/Vocab.h>
18
19#include <yarp/sig/Vector.h>
20
24#include <yarp/dev/PolyDriver.h>
25
26#include <mutex>
27#include <string>
28#include <vector>
29
30
31#ifdef MSVC
32# pragma warning(disable : 4355)
33#endif
34
35/*
36 * To optimize memory allocation, for group of joints we can have one mem reserver for rpc port
37 * and on e for streaming. The size could be numOfSubDevices*maxNumOfjointForSubdevice.
38 * (we could also use the actual joint number for each subdevice using a for loop). TODO
39 */
40
42
43/* the control command message type
44* head is a Bottle which contains the specification of the message type
45* body is a Vector which move the robot accordingly
46*/
48
49
55{
56protected:
79 std::mutex mutex;
80 size_t controlledJoints {0};
81
82public:
86 RPCMessagesParser() = default;
87
95 void reset();
96
97 bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
98
99 void handleTorqueMsg(const yarp::os::Bottle& cmd,
100 yarp::os::Bottle& response,
101 bool* rec,
102 bool* ok);
103
105 yarp::os::Bottle& response,
106 bool* rec,
107 bool* ok);
108
110 yarp::os::Bottle& response,
111 bool* rec,
112 bool* ok);
113
114 void handleImpedanceMsg(const yarp::os::Bottle& cmd,
115 yarp::os::Bottle& response,
116 bool* rec,
117 bool* ok);
118
120 yarp::os::Bottle& response,
121 bool* rec,
122 bool* ok);
123
125 yarp::os::Bottle& response,
126 bool* rec,
127 bool* ok);
128
129 void handleRemoteCalibratorMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
130
131 void handleRemoteVariablesMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
132
133 void handleCurrentMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
134
135 void handlePWMMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
136
137 void handlePidMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
138
143 virtual bool initialize();
144};
145
146#endif // YARP_DEV_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
define control board standard interfaces
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
contains the definition of a Vector type
Helper object for parsing RPC port messages.
void handleRemoteCalibratorMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IControlCalibration * rpc_Icalib
yarp::dev::IEncodersTimed * rpc_IEncTimed
yarp::dev::IControlMode * rpc_iCtrlMode
yarp::dev::IRemoteCalibrator * rpc_IRemoteCalibrator
yarp::dev::IAxisInfo * rpc_AxisInfo
yarp::dev::ITorqueControl * rpc_ITorque
yarp::dev::IPidControl * rpc_IPid
void handleProtocolVersionRequest(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void handlePWMMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IRemoteVariables * rpc_IVar
yarp::dev::IImpedanceControl * rpc_IImpedance
void handleCurrentMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void handleInteractionModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void handleControlModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void init(yarp::dev::DeviceDriver *x)
Initialization.
yarp::dev::IPositionDirect * rpc_IPosDirect
yarp::dev::ICurrentControl * rpc_ICurrent
void handleTorqueMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IMotorEncoders * rpc_IMotEnc
yarp::dev::IInteractionMode * rpc_IInteract
void handleJointFaultMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void handlePidMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IJointFault * rpc_IJointFault
virtual bool initialize()
Initialize the internal data.
yarp::dev::IPositionControl * rpc_IPosCtrl
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
yarp::sig::Vector tmpVect
yarp::dev::IVelocityControl * rpc_IVelCtrl
yarp::dev::IPWMControl * rpc_IPWM
yarp::dev::IAmplifierControl * rcp_IAmp
yarp::dev::IMotor * rpc_IMotor
yarp::dev::IControlLimits * rcp_Ilim
yarp::os::Stamp lastRpcStamp
void handleImpedanceMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
void handleRemoteVariablesMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
RPCMessagesParser()=default
Constructor.
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 control devices, amplifier commands.
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:36
Interface for control devices, calibration commands.
Interface for control devices, commands to get/set position and veloity limits.
Interface for setting control mode in control board.
Definition: IControlMode.h:23
Interface for control boards implementing current control.
Control board, extend encoder interface with timestamps.
Interface for control boards implementing impedance control.
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
Interface for getting info about the fault which may occur on a robot.
Definition: IJointFault.h:23
Control board, encoder interface.
Control board, encoder interface.
Definition: IMotor.h:94
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition: IPWMControl.h:23
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Definition: IPidControl.h:204
Interface for a generic control board device implementing position control.
Interface for a generic control board device implementing position control.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
IRemoteVariables interface.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:47
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:21