YARP
Yet Another Robot Platform
SubDevice.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_SUBDEVICE_H
7#define YARP_DEV_CONTROLBOARDWRAPPER_SUBDEVICE_H
8
9
10// ControlBoardWrapper
11// A modified version of the remote control board class
12// which remaps joints, it can also merge networks into a single part.
13
15#include <yarp/os/Network.h>
17#include <yarp/os/Semaphore.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 "RPCMessagesParser.h"
31#include <string>
32#include <vector>
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/*
47* An Helper class for the controlBoardWrapper
48* It maps only a subpart of the underlying device.
49*/
50
52{
53public:
54 std::string id;
55 size_t base {static_cast<size_t>(-1)};
56 size_t top {static_cast<size_t>(-1)};
57 size_t wbase; //wrapper base
58 size_t wtop; //wrapper top
59 size_t axes {0}; //number of used axis of this subdevice
60 size_t totalAxis; //Numeber of total axis that the subdevice can control
61
62 bool configuredF {false};
63
64 std::string parentName;
65
86
91
92 SubDevice() = default;
93
94 bool attach(yarp::dev::PolyDriver* d, const std::string& id);
95 void detach();
96
97 bool configure(size_t wbase, size_t wtop, size_t base, size_t top, size_t axes, const std::string& id, const std::string& _parentName);
98
99 bool isAttached() const
100 {
101 return attachedF;
102 }
103
104private:
105 bool attachedF {false};
106};
107
108typedef std::vector<SubDevice> SubDeviceVector;
109
111{
112 size_t offset; //an offset, the device is mapped starting from this joint
113 size_t deviceEntry; //index to the joint corresponding subdevice in the list
114 size_t jointIndexInDev; //the index of joint in the numeration inside the device
115};
116
117
119{
120public:
122 std::vector<DevicesLutEntry> lut;
124
125 inline SubDevice* getSubdevice(size_t i)
126 {
127 if (i >= subdevices.size()) {
128 return nullptr;
129 }
130
131 return &subdevices[i];
132 }
133};
134
135#endif // YARP_DEV_CONTROLBOARDWRAPPER_SUBDEVICE_H
define control board standard interfaces
std::vector< SubDevice > SubDeviceVector
Definition: SubDevice.h:108
contains the definition of a Vector type
controlboardwrapper2 deprecated: An updated version of the controlBoard network wrapper.
yarp::dev::IControlLimits * lim
Definition: SubDevice.h:73
yarp::dev::IImpedanceControl * iImpedance
Definition: SubDevice.h:77
size_t totalAxis
Definition: SubDevice.h:60
yarp::dev::IMotorEncoders * iMotEnc
Definition: SubDevice.h:71
size_t base
Definition: SubDevice.h:55
bool configure(size_t wbase, size_t wtop, size_t base, size_t top, size_t axes, const std::string &id, const std::string &_parentName)
Definition: SubDevice.cpp:23
size_t wtop
Definition: SubDevice.h:58
yarp::dev::IControlMode * iMode
Definition: SubDevice.h:78
bool isAttached() const
Definition: SubDevice.h:99
std::string id
Definition: SubDevice.h:54
yarp::dev::IEncodersTimed * iJntEnc
Definition: SubDevice.h:70
yarp::dev::IVelocityControl * vel
Definition: SubDevice.h:69
yarp::sig::Vector subDev_motor_encoders
Definition: SubDevice.h:89
yarp::sig::Vector subDev_joint_encoders
Definition: SubDevice.h:87
yarp::sig::Vector motorEncodersTimes
Definition: SubDevice.h:90
yarp::dev::PolyDriver * subdevice
Definition: SubDevice.h:66
yarp::dev::IAmplifierControl * amp
Definition: SubDevice.h:72
yarp::dev::IAxisInfo * info
Definition: SubDevice.h:79
yarp::dev::IMotor * imotor
Definition: SubDevice.h:82
yarp::dev::IInteractionMode * iInteract
Definition: SubDevice.h:81
yarp::sig::Vector jointEncodersTimes
Definition: SubDevice.h:88
yarp::dev::IPositionControl * pos
Definition: SubDevice.h:68
yarp::dev::ITorqueControl * iTorque
Definition: SubDevice.h:76
std::string parentName
Definition: SubDevice.h:64
void detach()
Definition: SubDevice.cpp:60
yarp::dev::IPidControl * pid
Definition: SubDevice.h:67
yarp::dev::IPreciselyTimed * iTimed
Definition: SubDevice.h:75
SubDevice()=default
bool attach(yarp::dev::PolyDriver *d, const std::string &id)
Definition: SubDevice.cpp:84
yarp::dev::IRemoteVariables * iVar
Definition: SubDevice.h:83
yarp::dev::IPWMControl * iPWM
Definition: SubDevice.h:84
yarp::dev::IPositionDirect * posDir
Definition: SubDevice.h:80
size_t top
Definition: SubDevice.h:56
size_t axes
Definition: SubDevice.h:59
size_t wbase
Definition: SubDevice.h:57
yarp::dev::IControlCalibration * calib
Definition: SubDevice.h:74
bool configuredF
Definition: SubDevice.h:62
yarp::dev::ICurrentControl * iCurr
Definition: SubDevice.h:85
std::vector< DevicesLutEntry > lut
Definition: SubDevice.h:122
size_t maxNumOfJointsInDevices
Definition: SubDevice.h:123
SubDeviceVector subdevices
Definition: SubDevice.h:121
SubDevice * getSubdevice(size_t i)
Definition: SubDevice.h:125
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...
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.
IRemoteVariables interface.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
A container for a device driver.
Definition: PolyDriver.h:23
size_t jointIndexInDev
Definition: SubDevice.h:114
size_t deviceEntry
Definition: SubDevice.h:113