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/PortablePair.h>
16 #include <yarp/os/BufferedPort.h>
17 #include <yarp/os/Time.h>
18 #include <yarp/os/Network.h>
19 #include <yarp/os/Stamp.h>
20 #include <yarp/os/Vocab.h>
21 
23 #include <yarp/dev/PolyDriver.h>
26 #include <yarp/sig/Vector.h>
27 
28 #include <mutex>
29 #include <string>
30 #include <vector>
31 
32 
33 #ifdef MSVC
34  #pragma warning(disable:4355)
35 #endif
36 
37 /*
38  * To optimize memory allocation, for group of joints we can have one mem reserver for rpc port
39  * and on e for streaming. The size could be numOfSubDevices*maxNumOfjointForSubdevice.
40  * (we could also use the actual joint number for each subdevice using a for loop). TODO
41  */
42 
44 
45 /* the control command message type
46 * head is a Bottle which contains the specification of the message type
47 * body is a Vector which move the robot accordingly
48 */
50 
51 
57 {
58 protected:
81  std::mutex mutex;
83 
84 public:
89 
96  void init(ControlBoardWrapper *x);
97 
98  bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
99 
100  void handleTorqueMsg(const yarp::os::Bottle& cmd,
101  yarp::os::Bottle& response, bool *rec, bool *ok);
102 
103  void handleControlModeMsg(const yarp::os::Bottle& cmd,
104  yarp::os::Bottle& response, bool *rec, bool *ok);
105 
106  void handleImpedanceMsg(const yarp::os::Bottle& cmd,
107  yarp::os::Bottle& response, bool *rec, bool *ok);
108 
110  yarp::os::Bottle& response, bool *rec, bool *ok);
111 
113  yarp::os::Bottle& response, bool *rec, bool *ok);
114 
115  void handleRemoteCalibratorMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool *rec, bool *ok);
116 
117  void handleRemoteVariablesMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool *rec, bool *ok);
118 
119  void handleCurrentMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool *rec, bool *ok);
120 
121  void handlePWMMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool *rec, bool *ok);
122 
123  void handlePidMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool *rec, bool *ok);
124 
129  virtual bool initialize();
130 };
131 
132 #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:72
RPCMessagesParser::rpc_IPWM
yarp::dev::IPWMControl * rpc_IPWM
Definition: RPCMessagesParser.h:78
yarp::dev::IRemoteVariables
Definition: IRemoteVariables.h:50
RPCMessagesParser::handleCurrentMsg
void handleCurrentMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:850
RPCMessagesParser::handleInteractionModeMsg
void handleInteractionModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:666
Network.h
RPCMessagesParser::ControlBoardWrapper_p
ControlBoardWrapper * ControlBoardWrapper_p
Definition: RPCMessagesParser.h:59
yarp::os::PortablePair
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:50
Vector.h
yarp::dev::IImpedanceControl
Definition: IImpedanceControl.h:74
RPCMessagesParser::lastRpcStamp
yarp::os::Stamp lastRpcStamp
Definition: RPCMessagesParser.h:80
RPCMessagesParser::mutex
std::mutex mutex
Definition: RPCMessagesParser.h:81
RPCMessagesParser::rpc_IVar
yarp::dev::IRemoteVariables * rpc_IVar
Definition: RPCMessagesParser.h:76
IPreciselyTimed.h
RPCMessagesParser::rpc_IEncTimed
yarp::dev::IEncodersTimed * rpc_IEncTimed
Definition: RPCMessagesParser.h:64
RPCMessagesParser::init
void init(ControlBoardWrapper *x)
Initialization.
Definition: RPCMessagesParser.cpp:2848
RPCMessagesParser::handleRemoteVariablesMsg
void handleRemoteVariablesMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1430
ControlBoardInterfaces.h
PortablePair.h
RPCMessagesParser::handlePWMMsg
void handlePWMMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1316
yarp::sig::VectorOf< double >
yarp::dev::IInteractionMode
Definition: IInteractionMode.h:42
RPCMessagesParser::tmpVect
yarp::sig::Vector tmpVect
Definition: RPCMessagesParser.h:79
ControlBoardWrapper
Definition: ControlBoardWrapper.h:225
RPCMessagesParser::rpc_IPosCtrl
yarp::dev::IPositionControl * rpc_IPosCtrl
Definition: RPCMessagesParser.h:61
yarp::dev::IControlMode
Definition: IControlMode.h:27
yarp::dev::IControlCalibration
Definition: IControlCalibration.h:84
RPCMessagesParser::handleRemoteCalibratorMsg
void handleRemoteCalibratorMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:1502
yarp::dev::IAxisInfo
Definition: IAxisInfo.h:42
PolyDriver.h
RPCMessagesParser::RPCMessagesParser
RPCMessagesParser()
Constructor.
Definition: RPCMessagesParser.cpp:2823
Stamp.h
RPCMessagesParser::rpc_IMotEnc
yarp::dev::IMotorEncoders * rpc_IMotEnc
Definition: RPCMessagesParser.h:65
yarp::dev::IControlLimits
Definition: IControlLimits.h:32
RPCMessagesParser::rpc_IPid
yarp::dev::IPidControl * rpc_IPid
Definition: RPCMessagesParser.h:60
RPCMessagesParser::respond
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
Definition: RPCMessagesParser.cpp:1614
RPCMessagesParser::rpc_IImpedance
yarp::dev::IImpedanceControl * rpc_IImpedance
Definition: RPCMessagesParser.h:73
yarp::dev::IPWMControl
Definition: IPWMControl.h:27
RPCMessagesParser::rpc_IPosDirect
yarp::dev::IPositionDirect * rpc_IPosDirect
Definition: RPCMessagesParser.h:62
RPCMessagesParser::handleImpedanceMsg
void handleImpedanceMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:52
BufferedPort.h
yarp::dev::IMotorEncoders
Definition: IMotorEncoders.h:154
CommandMessage
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
Definition: RPCMessagesParser.h:43
yarp::dev::IAmplifierControl
Definition: IAmplifierControl.h:32
RPCMessagesParser::handleControlModeMsg
void handleControlModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:157
RPCMessagesParser::handleProtocolVersionRequest
void handleProtocolVersionRequest(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:33
yarp::dev::IMotor
Definition: IMotor.h:98
yarp::dev::IVelocityControl
Definition: IVelocityControl.h:159
RPCMessagesParser::rpc_AxisInfo
yarp::dev::IAxisInfo * rpc_AxisInfo
Definition: RPCMessagesParser.h:70
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:24
yarp::dev::DeviceResponder
Definition: DeviceDriver.h:132
RPCMessagesParser
Helper object for parsing RPC port messages.
Definition: RPCMessagesParser.h:55
RPCMessagesParser::rpc_ICurrent
yarp::dev::ICurrentControl * rpc_ICurrent
Definition: RPCMessagesParser.h:77
yarp::dev::ICurrentControl
Definition: ICurrentControl.h:27
RPCMessagesParser::rpc_iCtrlMode
yarp::dev::IControlMode * rpc_iCtrlMode
Definition: RPCMessagesParser.h:69
yarp::dev::IPidControl
Definition: IPidControl.h:210
RPCMessagesParser::handlePidMsg
void handlePidMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:987
yarp::dev::IPositionDirect
Definition: IPositionDirect.h:31
yarp::dev::IEncodersTimed
Control board, extend encoder interface with timestamps.
Definition: IEncodersTimed.h:58
RPCMessagesParser::handleTorqueMsg
void handleTorqueMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Definition: RPCMessagesParser.cpp:465
RPCMessagesParser::rcp_IAmp
yarp::dev::IAmplifierControl * rcp_IAmp
Definition: RPCMessagesParser.h:66
Vocab.h
ControlBoardInterfacesImpl.h
Time.h
RPCMessagesParser::initialize
virtual bool initialize()
Initialize the internal data.
Definition: RPCMessagesParser.cpp:2784
yarp::dev::ITorqueControl
Definition: ITorqueControl.h:38
RPCMessagesParser::rpc_Icalib
yarp::dev::IControlCalibration * rpc_Icalib
Definition: RPCMessagesParser.h:72
RPCMessagesParser::rpc_IMotor
yarp::dev::IMotor * rpc_IMotor
Definition: RPCMessagesParser.h:75
RPCMessagesParser::rpc_ITorque
yarp::dev::ITorqueControl * rpc_ITorque
Definition: RPCMessagesParser.h:68
RPCMessagesParser::rpc_IInteract
yarp::dev::IInteractionMode * rpc_IInteract
Definition: RPCMessagesParser.h:74
yarp::dev::IRemoteCalibrator
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
Definition: IRemoteCalibrator.h:29
yarp::dev::IPositionControl
Definition: IPositionControl.h:256
RPCMessagesParser::controlledJoints
int controlledJoints
Definition: RPCMessagesParser.h:82
RPCMessagesParser::rpc_IRemoteCalibrator
yarp::dev::IRemoteCalibrator * rpc_IRemoteCalibrator
Definition: RPCMessagesParser.h:71
RPCMessagesParser::rpc_IVelCtrl
yarp::dev::IVelocityControl * rpc_IVelCtrl
Definition: RPCMessagesParser.h:63
RPCMessagesParser::rcp_Ilim
yarp::dev::IControlLimits * rcp_Ilim
Definition: RPCMessagesParser.h:67