YARP
Yet Another Robot Platform
RPCMessagesParser.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_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
10 #define YARP_DEV_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
11 
12 
13 // This file contains helper functions for the ControlBoardWrapper
14 
15 #include <yarp/os/BufferedPort.h>
16 #include <yarp/os/Network.h>
17 #include <yarp/os/PortablePair.h>
18 #include <yarp/os/Stamp.h>
19 #include <yarp/os/Time.h>
20 #include <yarp/os/Vocab.h>
21 
22 #include <yarp/sig/Vector.h>
23 
27 #include <yarp/dev/PolyDriver.h>
28 
29 #include <mutex>
30 #include <string>
31 #include <vector>
32 
33 
34 #ifdef MSVC
35 # pragma warning(disable : 4355)
36 #endif
37 
38 /*
39  * To optimize memory allocation, for group of joints we can have one mem reserver for rpc port
40  * and on e for streaming. The size could be numOfSubDevices*maxNumOfjointForSubdevice.
41  * (we could also use the actual joint number for each subdevice using a for loop). TODO
42  */
43 
45 
46 /* the control command message type
47 * head is a Bottle which contains the specification of the message type
48 * body is a Vector which move the robot accordingly
49 */
51 
52 
58 {
59 protected:
82  std::mutex mutex;
83  size_t controlledJoints {0};
84 
85 public:
89  RPCMessagesParser() = default;
90 
98 
99  bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
100 
101  void handleTorqueMsg(const yarp::os::Bottle& cmd,
102  yarp::os::Bottle& response,
103  bool* rec,
104  bool* ok);
105 
106  void handleControlModeMsg(const yarp::os::Bottle& cmd,
107  yarp::os::Bottle& response,
108  bool* rec,
109  bool* ok);
110 
111  void handleImpedanceMsg(const yarp::os::Bottle& cmd,
112  yarp::os::Bottle& response,
113  bool* rec,
114  bool* ok);
115 
117  yarp::os::Bottle& response,
118  bool* rec,
119  bool* ok);
120 
122  yarp::os::Bottle& response,
123  bool* rec,
124  bool* ok);
125 
126  void handleRemoteCalibratorMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
127 
128  void handleRemoteVariablesMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
129 
130  void handleCurrentMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
131 
132  void handlePWMMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
133 
134  void handlePidMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
135 
140  virtual bool initialize();
141 };
142 
143 #endif // YARP_DEV_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
RPCMessagesParser::rpc_IPWM
yarp::dev::IPWMControl * rpc_IPWM
Definition: RPCMessagesParser.h:79
yarp::dev::IRemoteVariables
IRemoteVariables interface.
Definition: IRemoteVariables.h:51
RPCMessagesParser::handleCurrentMsg
void handleCurrentMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:719
RPCMessagesParser::handleInteractionModeMsg
void handleInteractionModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:576
Network.h
yarp::os::PortablePair
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:51
Vector.h
contains the definition of a Vector type
yarp::dev::IImpedanceControl
Interface for control boards implementing impedance control.
Definition: IImpedanceControl.h:75
RPCMessagesParser::lastRpcStamp
yarp::os::Stamp lastRpcStamp
Definition: RPCMessagesParser.h:81
RPCMessagesParser::mutex
std::mutex mutex
Definition: RPCMessagesParser.h:82
RPCMessagesParser::rpc_IVar
yarp::dev::IRemoteVariables * rpc_IVar
Definition: RPCMessagesParser.h:77
IPreciselyTimed.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
RPCMessagesParser::rpc_IEncTimed
yarp::dev::IEncodersTimed * rpc_IEncTimed
Definition: RPCMessagesParser.h:65
RPCMessagesParser::handleRemoteVariablesMsg
void handleRemoteVariablesMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1186
ControlBoardInterfaces.h
define control board standard interfaces
PortablePair.h
RPCMessagesParser::handlePWMMsg
void handlePWMMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1096
yarp::sig::VectorOf< double >
yarp::dev::IInteractionMode
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
Definition: IInteractionMode.h:43
RPCMessagesParser::tmpVect
yarp::sig::Vector tmpVect
Definition: RPCMessagesParser.h:80
RPCMessagesParser::RPCMessagesParser
RPCMessagesParser()=default
Constructor.
RPCMessagesParser::rpc_IPosCtrl
yarp::dev::IPositionControl * rpc_IPosCtrl
Definition: RPCMessagesParser.h:62
yarp::dev::IControlMode
Interface for setting control mode in control board.
Definition: IControlMode.h:28
yarp::dev::IControlCalibration
Interface for control devices, calibration commands.
Definition: IControlCalibration.h:85
RPCMessagesParser::handleRemoteCalibratorMsg
void handleRemoteCalibratorMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1243
yarp::dev::IAxisInfo
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:43
PolyDriver.h
Stamp.h
RPCMessagesParser::rpc_IMotEnc
yarp::dev::IMotorEncoders * rpc_IMotEnc
Definition: RPCMessagesParser.h:66
yarp::dev::IControlLimits
Interface for control devices, commands to get/set position and veloity limits.
Definition: IControlLimits.h:33
RPCMessagesParser::rpc_IPid
yarp::dev::IPidControl * rpc_IPid
Definition: RPCMessagesParser.h:61
RPCMessagesParser::respond
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
Definition: RPCMessagesParser.cpp:1330
RPCMessagesParser::rpc_IImpedance
yarp::dev::IImpedanceControl * rpc_IImpedance
Definition: RPCMessagesParser.h:74
yarp::dev::IPWMControl
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition: IPWMControl.h:28
RPCMessagesParser::rpc_IPosDirect
yarp::dev::IPositionDirect * rpc_IPosDirect
Definition: RPCMessagesParser.h:63
RPCMessagesParser::controlledJoints
size_t controlledJoints
Definition: RPCMessagesParser.h:83
RPCMessagesParser::handleImpedanceMsg
void handleImpedanceMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:54
ControlBoardWrapperCommon
Definition: ControlBoardWrapperCommon.h:19
BufferedPort.h
yarp::dev::IMotorEncoders
Control board, encoder interface.
Definition: IMotorEncoders.h:155
CommandMessage
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
Definition: RPCMessagesParser.h:44
yarp::dev::IAmplifierControl
Interface for control devices, amplifier commands.
Definition: IAmplifierControl.h:33
RPCMessagesParser::handleControlModeMsg
void handleControlModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:138
RPCMessagesParser::handleProtocolVersionRequest
void handleProtocolVersionRequest(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:34
yarp::dev::IMotor
Control board, encoder interface.
Definition: IMotor.h:99
yarp::dev::IVelocityControl
Interface for control boards implementing velocity control.
Definition: IVelocityControl.h:160
RPCMessagesParser::rpc_AxisInfo
yarp::dev::IAxisInfo * rpc_AxisInfo
Definition: RPCMessagesParser.h:71
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
yarp::dev::DeviceResponder
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:134
RPCMessagesParser
Helper object for parsing RPC port messages.
Definition: RPCMessagesParser.h:58
RPCMessagesParser::rpc_ICurrent
yarp::dev::ICurrentControl * rpc_ICurrent
Definition: RPCMessagesParser.h:78
yarp::dev::ICurrentControl
Interface for control boards implementing current control.
Definition: ICurrentControl.h:28
RPCMessagesParser::rpc_iCtrlMode
yarp::dev::IControlMode * rpc_iCtrlMode
Definition: RPCMessagesParser.h:70
yarp::dev::IPidControl
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Definition: IPidControl.h:211
RPCMessagesParser::handlePidMsg
void handlePidMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:826
yarp::dev::IPositionDirect
Interface for a generic control board device implementing position control.
Definition: IPositionDirect.h:32
yarp::dev::IEncodersTimed
Control board, extend encoder interface with timestamps.
Definition: IEncodersTimed.h:59
RPCMessagesParser::init
void init(yarp::dev::DeviceDriver *x)
Initialization.
Definition: RPCMessagesParser.cpp:2365
RPCMessagesParser::handleTorqueMsg
void handleTorqueMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:409
RPCMessagesParser::rcp_IAmp
yarp::dev::IAmplifierControl * rcp_IAmp
Definition: RPCMessagesParser.h:67
Vocab.h
RPCMessagesParser::ControlBoardWrapper_p
ControlBoardWrapperCommon * ControlBoardWrapper_p
Definition: RPCMessagesParser.h:60
ControlBoardInterfacesImpl.h
Time.h
RPCMessagesParser::initialize
virtual bool initialize()
Initialize the internal data.
Definition: RPCMessagesParser.cpp:2325
yarp::dev::ITorqueControl
Interface for control boards implementing torque control.
Definition: ITorqueControl.h:39
RPCMessagesParser::rpc_Icalib
yarp::dev::IControlCalibration * rpc_Icalib
Definition: RPCMessagesParser.h:73
RPCMessagesParser::rpc_IMotor
yarp::dev::IMotor * rpc_IMotor
Definition: RPCMessagesParser.h:76
RPCMessagesParser::rpc_ITorque
yarp::dev::ITorqueControl * rpc_ITorque
Definition: RPCMessagesParser.h:69
RPCMessagesParser::rpc_IInteract
yarp::dev::IInteractionMode * rpc_IInteract
Definition: RPCMessagesParser.h:75
yarp::dev::IRemoteCalibrator
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
Definition: IRemoteCalibrator.h:30
yarp::dev::IPositionControl
Interface for a generic control board device implementing position control.
Definition: IPositionControl.h:257
RPCMessagesParser::rpc_IRemoteCalibrator
yarp::dev::IRemoteCalibrator * rpc_IRemoteCalibrator
Definition: RPCMessagesParser.h:72
RPCMessagesParser::rpc_IVelCtrl
yarp::dev::IVelocityControl * rpc_IVelCtrl
Definition: RPCMessagesParser.h:64
RPCMessagesParser::rcp_Ilim
yarp::dev::IControlLimits * rcp_Ilim
Definition: RPCMessagesParser.h:68