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
12#include <yarp/os/Time.h>
13#include <yarp/os/Network.h>
14#include <yarp/os/Stamp.h>
15#include <yarp/os/Vocab.h>
16
20#include <yarp/dev/PolyDriver.h>
23
24
25#include <yarp/sig/Vector.h>
26
27#include <mutex>
28#include <string>
29#include <vector>
30
31
32#ifdef MSVC
33 #pragma warning(disable:4355)
34#endif
35
36/*
37 * Helper class for the ControlBoardRemapper.
38 * It contains all the data structure related
39 * to a given controlboard used by the remapper.
40 */
42{
43public:
44 std::string id;
45
70
72
73 bool attach(yarp::dev::PolyDriver *d, const std::string &id);
74 void detach();
75
76 inline void setVerbose(bool _verbose) {_subDevVerbose = _verbose; }
77
79 { return attachedF; }
80
81private:
82 bool _subDevVerbose;
83 bool attachedF;
84};
85
91{
92public:
98
103};
104
106{
107public:
111 std::vector<RemappedSubControlBoard> subdevices;
112
116 std::vector<RemappedAxis> lut;
117
125 {
126 return &(subdevices[i]);
127 }
128
130 {
131 return subdevices.size();
132 }
133
134 size_t getNrOfRemappedAxes() const
135 {
136 return lut.size();
137 }
138};
139
141{
142public:
143 std::mutex mutex;
144 std::vector<int> controlBoardModes;
145 std::vector<double> dummyBuffer;
147
148};
149
158{
159public:
164 bool configure(const RemappedControlBoards & remappedControlBoards);
165
170 void fillSubControlBoardBuffersFromCompleteJointVector(const double * full, const RemappedControlBoards & remappedControlBoards);
171
172
179 const RemappedControlBoards & remappedControlBoards);
180
188 const RemappedControlBoards & remappedControlBoards);
189
194 void fillCompleteJointVectorFromSubControlBoardBuffers(double * full, const RemappedControlBoards & remappedControlBoards);
195
204 const RemappedControlBoards & remappedControlBoards);
205
214 const RemappedControlBoards & remappedControlBoards);
215
216
220 std::mutex mutex;
221
222 // Buffer to be used in MultiJoint version of the
225 std::vector< std::vector<int> > m_jointsInSubControlBoard;
226
227
228 std::vector< std::vector<double> > m_bufferForSubControlBoard;
229 std::vector< std::vector<int> > m_bufferForSubControlBoardControlModes;
230 std::vector< std::vector<yarp::dev::InteractionModeEnum> > m_bufferForSubControlBoardInteractionModes;
231
232 std::vector<int> m_counterForControlBoard;
233};
234
245{
250 void createListOfJointsDecomposition(const int n_joints, const int *joints, const RemappedControlBoards & remappedControlBoards);
251
252public:
257 bool configure(const RemappedControlBoards & remappedControlBoards);
258
259
264 void fillSubControlBoardBuffersFromArbitraryJointVector(const double * arbitraryVec,
265 const int n_joints,
266 const int *joints,
267 const RemappedControlBoards & remappedControlBoards);
268
274 void fillSubControlBoardBuffersFromArbitraryJointVector(const int * arbitraryVec,
275 const int n_joints,
276 const int *joints,
277 const RemappedControlBoards & remappedControlBoards);
278
285 const int n_joints,
286 const int *joints,
287 const RemappedControlBoards & remappedControlBoards);
288
293 void resizeSubControlBoardBuffers(const int n_joints,
294 const int *joints,
295 const RemappedControlBoards & remappedControlBoards);
296
304 const int n_joints, const int *joints,
305 const RemappedControlBoards & remappedControlBoards);
306
315 const int n_joints, const int *joints,
316 const RemappedControlBoards & remappedControlBoards);
317
326 const int n_joints, const int *joints,
327 const RemappedControlBoards & remappedControlBoards);
328
332 std::mutex mutex;
333
334 // Total number of axes in the remapped controlboard
336
337 // Vector of size getNrOfSubControlBoards
339 std::vector< std::vector<int> > m_jointsInSubControlBoard;
340
341 // Buffers for the control board (the size of each one should
342 // match the size of m_nJointsInSubControlBoard[ctrlBoard] and
343 // the size of m_jointsInSubControlBoard[ctrlBoard].size()
344 std::vector< std::vector<double> > m_bufferForSubControlBoard;
345 std::vector< std::vector<int> > m_bufferForSubControlBoardControlModes;
346 std::vector< std::vector<yarp::dev::InteractionModeEnum> > m_bufferForSubControlBoardInteractionModes;
347
348
349 // Counter used when converting a full vector to
350 // the subcontrolboard buffers
351 std::vector<int> m_counterForControlBoard;
352};
353
354#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::InteractionModeEnum > > m_bufferForSubControlBoardInteractionModes
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...
std::vector< std::vector< int > > m_bufferForSubControlBoardControlModes
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< int > > m_bufferForSubControlBoardControlModes
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: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 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: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.
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:21