YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoardRemapperHelpers.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_CONTROLBOARDREMAPPER_CONTROLBOARDREMAPPERHELPERS_H
7#define YARP_DEV_CONTROLBOARDREMAPPER_CONTROLBOARDREMAPPERHELPERS_H
8
9
11#include <yarp/os/Time.h>
12#include <yarp/os/Network.h>
13#include <yarp/os/Stamp.h>
14#include <yarp/os/Vocab.h>
15
19#include <yarp/dev/PolyDriver.h>
22
23
24#include <yarp/sig/Vector.h>
25
26#include <mutex>
27#include <string>
28#include <vector>
29
30
31#ifdef MSVC
32 #pragma warning(disable:4355)
33#endif
34
35/*
36 * Helper class for the ControlBoardRemapper.
37 * It contains all the data structure related
38 * to a given controlboard used by the remapper.
39 */
41{
42public:
43 std::string id;
44
69
71
72 bool attach(yarp::dev::PolyDriver *d, const std::string &id);
73 void detach();
74
75 inline void setVerbose(bool _verbose) {_subDevVerbose = _verbose; }
76
78 { return attachedF; }
79
80private:
81 bool _subDevVerbose;
82 bool attachedF;
83};
84
90{
91public:
97
102};
103
105{
106public:
110 std::vector<RemappedSubControlBoard> subdevices;
111
115 std::vector<RemappedAxis> lut;
116
124 {
125 return &(subdevices[i]);
126 }
127
129 {
130 return subdevices.size();
131 }
132
133 size_t getNrOfRemappedAxes() const
134 {
135 return lut.size();
136 }
137};
138
140{
141public:
142 std::mutex mutex;
143 std::vector<int> controlBoardModes;
144 std::vector<double> dummyBuffer;
146
147};
148
157{
158public:
163 bool configure(const RemappedControlBoards & remappedControlBoards);
164
169 void fillSubControlBoardBuffersFromCompleteJointVector(const double * full, const RemappedControlBoards & remappedControlBoards);
170
171
178 const RemappedControlBoards & remappedControlBoards);
179
187 const RemappedControlBoards & remappedControlBoards);
188
193 void fillCompleteJointVectorFromSubControlBoardBuffers(double * full, const RemappedControlBoards & remappedControlBoards);
194
203 const RemappedControlBoards & remappedControlBoards);
204
213 const RemappedControlBoards & remappedControlBoards);
214
215
219 std::mutex mutex;
220
221 // Buffer to be used in MultiJoint version of the
224 std::vector< std::vector<int> > m_jointsInSubControlBoard;
225
226
227 std::vector< std::vector<double> > m_bufferForSubControlBoard;
228 std::vector< std::vector<yarp::dev::InteractionModeEnum> > m_bufferForSubControlBoardInteractionModes;
229 std::vector< std::vector<yarp::dev::SelectableControlModeEnum> > m_bufferForSubControlBoardSelectableControlModesEnum;
230 std::vector< std::vector<yarp::dev::ControlModeEnum> > m_bufferForSubControlBoardControlModesEnum;
231
232
233 std::vector<int> m_counterForControlBoard;
234};
235
246{
251 void createListOfJointsDecomposition(const int n_joints, const int *joints, const RemappedControlBoards & remappedControlBoards);
252
253public:
258 bool configure(const RemappedControlBoards & remappedControlBoards);
259
260
265 void fillSubControlBoardBuffersFromArbitraryJointVector(const double * arbitraryVec,
266 const int n_joints,
267 const int *joints,
268 const RemappedControlBoards & remappedControlBoards);
269
276 const int n_joints,
277 const int *joints,
278 const RemappedControlBoards & remappedControlBoards);
279
286 const int n_joints,
287 const int *joints,
288 const RemappedControlBoards & remappedControlBoards);
289
294 void resizeSubControlBoardBuffers(const int n_joints,
295 const int *joints,
296 const RemappedControlBoards & remappedControlBoards);
297
305 const int n_joints, const int *joints,
306 const RemappedControlBoards & remappedControlBoards);
307
316 const int n_joints, const int *joints,
317 const RemappedControlBoards & remappedControlBoards);
318
327 const int n_joints, const int *joints,
328 const RemappedControlBoards & remappedControlBoards);
329
333 std::mutex mutex;
334
335 // Total number of axes in the remapped controlboard
337
338 // Vector of size getNrOfSubControlBoards
340 std::vector< std::vector<int> > m_jointsInSubControlBoard;
341
342 // Buffers for the control board (the size of each one should
343 // match the size of m_nJointsInSubControlBoard[ctrlBoard] and
344 // the size of m_jointsInSubControlBoard[ctrlBoard].size()
345 std::vector< std::vector<double> > m_bufferForSubControlBoard;
346 std::vector< std::vector<yarp::dev::InteractionModeEnum> > m_bufferForSubControlBoardInteractionModes;
347 std::vector< std::vector<yarp::dev::SelectableControlModeEnum> > m_bufferForSubControlBoardSelectableControlModesEnum;
348 std::vector< std::vector<yarp::dev::ControlModeEnum> > m_bufferForSubControlBoardControlModesEnum;
349
350 // Counter used when converting a full vector to
351 // the subcontrolboard buffers
352 std::vector<int> m_counterForControlBoard;
353};
354
355#endif // YARP_DEV_CONTROLBOARDREMAPPER_CONTROLBOARDREMAPPERHELPERS_H
define control board standard interfaces
define control board standard interfaces
contains the definition of a Vector type
Class storing the decomposition of a subset of the total remapped axes of the remapped controlboard i...
bool configure(const RemappedControlBoards &remappedControlBoards)
Resize the buffers using the information in the RemappedControlBoards.
std::vector< std::vector< double > > m_bufferForSubControlBoard
std::vector< std::vector< yarp::dev::SelectableControlModeEnum > > m_bufferForSubControlBoardSelectableControlModesEnum
std::vector< std::vector< yarp::dev::InteractionModeEnum > > m_bufferForSubControlBoardInteractionModes
std::vector< std::vector< yarp::dev::ControlModeEnum > > m_bufferForSubControlBoardControlModesEnum
void fillSubControlBoardBuffersFromArbitraryJointVector(const double *arbitraryVec, const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Fill buffers for the SubControlBoard from a vector of joints of the RemappedControlBoards.
std::vector< std::vector< int > > m_jointsInSubControlBoard
void resizeSubControlBoardBuffers(const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Resize buffers to have the dimension of specified by the method (used for multi joint methods that re...
void fillArbitraryJointVectorFromSubControlBoardBuffers(double *arbitraryVec, const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Fill a vector of joints of the ControlBoardRemapper from the buffers of the SubControlBoard .
std::mutex mutex
Mutex to grab to use this class.
Class storing the decomposition of all the axes in the Remapped ControlBoard in the SubControlBoard,...
bool configure(const RemappedControlBoards &remappedControlBoards)
Resize the buffers using the information in the RemappedControlBoards.
std::mutex mutex
Mutex to grab to use this class.
std::vector< std::vector< int > > m_jointsInSubControlBoard
void fillCompleteJointVectorFromSubControlBoardBuffers(double *full, const RemappedControlBoards &remappedControlBoards)
Fill a vector of joints of the ControlBoardRemapper from the buffers of the SubControlBoard .
void fillSubControlBoardBuffersFromCompleteJointVector(const double *full, const RemappedControlBoards &remappedControlBoards)
Fill buffers for the SubControlBoard from a vector of joints of the RemappedControlBoards.
std::vector< std::vector< double > > m_bufferForSubControlBoard
std::vector< std::vector< yarp::dev::ControlModeEnum > > m_bufferForSubControlBoardControlModesEnum
std::vector< std::vector< yarp::dev::SelectableControlModeEnum > > m_bufferForSubControlBoardSelectableControlModesEnum
std::vector< std::vector< yarp::dev::InteractionModeEnum > > m_bufferForSubControlBoardInteractionModes
Information in how an axis is remapped on an axis of a SubControlBoard.
size_t axisIndexInSubControlBoard
The index of the remapped axis in the SubControlBoard.
size_t subControlBoardIndex
The index of the SubControlBoard of the remapped axis in the RemappedControlBoards class.
std::vector< RemappedSubControlBoard > subdevices
Vector of dimension getNrOfSubControlBoards .
std::vector< RemappedAxis > lut
Vector of dimension getNrOfRemappedAxes .
RemappedSubControlBoard * getSubControlBoard(size_t i)
Given a controlboard index between 0 and getNrOfSubControlBoards()-1, return the relative SubControlB...
yarp::dev::IPositionControl * pos
yarp::dev::IImpedanceControl * iImpedance
yarp::dev::IAmplifierControl * amp
yarp::dev::IEncodersTimed * iJntEnc
yarp::dev::IInteractionMode * iInteract
yarp::dev::IRemoteVariables * iVar
yarp::dev::ICurrentControl * iCurr
yarp::dev::ITorqueControl * iTorque
yarp::dev::IVelocityControl * vel
yarp::dev::IControlMode * iMode
yarp::dev::IJointFault * iFault
yarp::dev::IVelocityDirect * iVelDir
yarp::dev::IPositionDirect * posDir
yarp::dev::IRemoteCalibrator * remcalib
bool attach(yarp::dev::PolyDriver *d, const std::string &id)
yarp::dev::IControlLimits * lim
yarp::dev::IJointBrake * iBrake
yarp::dev::IControlCalibration * calib
yarp::dev::PolyDriver * subdevice
yarp::dev::IMotorEncoders * iMotEnc
yarp::dev::IPreciselyTimed * iTimed
Interface for control devices, amplifier commands.
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:37
Interface for control devices, calibration commands.
Interface for control devices, commands to get/set position and velocity 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 controlling a joint equipped with brakes (hardware or simulated).
Definition IJointBrake.h:23
Interface for getting info about the fault which may occur on a robot.
Definition IJointFault.h:24
Control board, encoder interface.
Control board, encoder interface.
Definition IMotor.h:95
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition IPWMControl.h:24
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.
Interface for control boards implementing direct velocity control.
A container for a device driver.
Definition PolyDriver.h:23
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:18
SelectableControlModeEnum