YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
30constexpr int PROTOCOL_VERSION_MAJOR = 1;
31constexpr int PROTOCOL_VERSION_MINOR = 9;
32constexpr int PROTOCOL_VERSION_TWEAK = 0;
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
44class ControlBoardWrapperCommon;
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{
59protected:
82 std::mutex mutex;
83 size_t controlledJoints {0};
84
85public:
89 RPCMessagesParser() = default;
90
98 void reset();
99
100 bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& response) override;
101
102 void handleTorqueMsg(const yarp::os::Bottle& cmd,
103 yarp::os::Bottle& response,
104 bool* rec,
105 bool* ok);
106
108 yarp::os::Bottle& response,
109 bool* rec,
110 bool* ok);
111
113 yarp::os::Bottle& response,
114 bool* rec,
115 bool* ok);
116
117 void handleImpedanceMsg(const yarp::os::Bottle& cmd,
118 yarp::os::Bottle& response,
119 bool* rec,
120 bool* ok);
121
123 yarp::os::Bottle& response,
124 bool* rec,
125 bool* ok);
126
128 yarp::os::Bottle& response,
129 bool* rec,
130 bool* ok);
131
132 void handleRemoteCalibratorMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
133
134 void handleRemoteVariablesMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
135
136 void handleCurrentMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
137
138 void handlePWMMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
139
140 void handlePidMsg(const yarp::os::Bottle& cmd, yarp::os::Bottle& response, bool* rec, bool* ok);
141
146 virtual bool initialize();
147};
148
149#endif // YARP_DEV_CONTROLBOARDWRAPPER_RPCMESSAGESPARSER_H
define control board standard interfaces
constexpr int PROTOCOL_VERSION_TWEAK
constexpr int PROTOCOL_VERSION_MINOR
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
constexpr int PROTOCOL_VERSION_MAJOR
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.
A cheap and cheerful framework for human readable/writable forms of messages to devices.
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.
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.
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
A mini-server for performing network communication in the background.
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21