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
Interface for control boards implementing current control.
Interface for control devices, calibration commands.
yarp::dev::IVelocityControl * rpc_IVelCtrl
yarp::dev::IControlCalibration * rpc_Icalib
void init(ControlBoardWrapper *x)
Initialization.
Control board, encoder interface.
yarp::dev::IPWMControl * rpc_IPWM
yarp::dev::IRemoteVariables * rpc_IVar
void handleInteractionModeMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IControlLimits * rcp_Ilim
Interface for controlling an axis, by sending directly a PWM reference signal to a motor...
Definition: IPWMControl.h:27
Interface for control boards implementing torque control.
void handleRemoteVariablesMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Interface for a generic control board device implementing position control.
yarp::os::Stamp lastRpcStamp
ControlBoardWrapper * ControlBoardWrapper_p
yarp::sig::Vector tmpVect
yarp::dev::IEncodersTimed * rpc_IEncTimed
Interface for setting control mode in control board.
Definition: IControlMode.h:27
Interface for a generic control board device implementing a PID controller, with scaled arguments...
Definition: IPidControl.h:210
Control board, extend encoder interface with timestamps.
Interface for a generic control board device implementing position control.
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:42
yarp::dev::IPidControl * rpc_IPid
Interface for control boards implementing impedance control.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
void handlePWMMsg(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)
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:50
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.
RPCMessagesParser()
Constructor.
yarp::dev::IPositionDirect * rpc_IPosDirect
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:132
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:72
yarp::dev::IPositionControl * rpc_IPosCtrl
yarp::dev::IMotorEncoders * rpc_IMotEnc
void handleRemoteCalibratorMsg(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)
Control board, encoder interface.
Definition: IMotor.h:98
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
define control board standard interfaces
yarp::dev::IAxisInfo * rpc_AxisInfo
void handleImpedanceMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
contains the definition of a Vector type
Interface for control devices, amplifier commands.
void handleProtocolVersionRequest(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
yarp::dev::IImpedanceControl * rpc_IImpedance
void handleTorqueMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)
Interface for control boards implementing velocity control.
yarp::dev::IAmplifierControl * rcp_IAmp
yarp::dev::ITorqueControl * rpc_ITorque
yarp::dev::IInteractionMode * rpc_IInteract
yarp::dev::ICurrentControl * rpc_ICurrent
yarp::dev::IControlMode * rpc_iCtrlMode
yarp::dev::IRemoteCalibrator * rpc_IRemoteCalibrator
virtual bool initialize()
Initialize the internal data.
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:24
Helper object for parsing RPC port messages.
Interface for control devices, commands to get/set position and veloity limits.
yarp::dev::IMotor * rpc_IMotor
IRemoteVariables interface.
void handleCurrentMsg(const yarp::os::Bottle &cmd, yarp::os::Bottle &response, bool *rec, bool *ok)