tools
Loading...
Searching...
No Matches
RealToSimControlBoard.hpp
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3#ifndef __REAL_TO_SIM_CONTROL_BOARD_HPP__
4#define __REAL_TO_SIM_CONTROL_BOARD_HPP__
5
6#include <vector>
7
8#include <yarp/dev/PolyDriver.h>
9#include <yarp/dev/IControlMode.h>
10#include <yarp/dev/IEncodersTimed.h>
11#include <yarp/dev/IPositionControl.h>
12#include <yarp/dev/IVelocityControl.h>
13
14#include "Transformation.hpp"
15#include "RealToSimControlBoard_ParamsParser.h"
16
17namespace roboticslab
18{
19
21{
22public:
23 ExposedJointControlledDevice(const std::string & name, yarp::dev::PolyDriver * device);
25 bool addControlledDeviceJoint(yarp::os::Searchable * parameters);
26 bool positionMove(double ref);
27private:
28 std::string name;
29 size_t axes {0}; // same as controlledDeviceJoints.size()
30 std::vector<int> controlledDeviceJoints;
31 std::vector<Transformation *> transformations;
32 yarp::dev::IPositionControl * iPositionControl {nullptr};
33};
34
36{
37public:
38 ExposedJoint(const std::string & name);
40 void addExposedJointControlledDevice(ExposedJointControlledDevice * exposedJointControlledDevice);
41 bool positionMove(double ref);
42private:
43 std::vector<ExposedJointControlledDevice *> exposedJointControlledDevices;
44 std::string name;
45};
46
47} // namespace roboticslab
48
61class RealToSimControlBoard : public yarp::dev::DeviceDriver,
62 public yarp::dev::IControlMode,
63 public yarp::dev::IEncodersTimed,
64 public yarp::dev::IPositionControl,
65 public yarp::dev::IVelocityControl,
67{
68public:
69 // -------- DeviceDriver declarations. Implementation in IDeviceImpl.cpp --------
70
71 bool open(yarp::os::Searchable & config) override;
72 bool close() override;
73
74 // --------- IControlMode declarations. Implementation in IControlModeImpl.cpp ---------
75
76 bool getControlMode(int j, int * mode) override;
77 bool getControlModes(int * modes) override;
78 bool getControlModes(int n_joint, const int * joints, int * modes) override;
79 bool setControlMode(int j, int mode) override;
80 bool setControlModes(int n_joint, const int * joints, int * modes) override;
81 bool setControlModes(int * modes) override;
82
83 // ---------- IEncodersTimed Declarations. Implementation in IEncodersTimedImpl.cpp ----------
84
85 bool getEncodersTimed(double * encs, double * time) override;
86 bool getEncoderTimed(int j, double * encs, double * time) override;
87 bool resetEncoder(int j) override;
88 bool resetEncoders() override;
89 bool setEncoder(int j, double val) override;
90 bool setEncoders(const double * vals) override;
91 bool getEncoder(int j, double * v) override;
92 bool getEncoders(double * encs) override;
93 bool getEncoderSpeed(int j, double * sp) override;
94 bool getEncoderSpeeds(double * spds) override;
95 bool getEncoderAcceleration(int j, double * spds) override;
96 bool getEncoderAccelerations(double * accs) override;
97
98 // ------- IPositionControl declarations. Implementation in IPositionControlImpl.cpp -------
99
100 bool getAxes(int * ax) override;
101 bool positionMove(int j, double ref) override;
102 bool positionMove(const double * refs) override;
103 bool relativeMove(int j, double delta) override;
104 bool relativeMove(const double * deltas) override;
105 bool checkMotionDone(int j, bool * flag) override;
106 bool checkMotionDone(bool * flag) override;
107 bool setRefSpeed(int j, double sp) override;
108 bool setRefSpeeds(const double * spds) override;
109 bool setRefAcceleration(int j, double acc) override;
110 bool setRefAccelerations(const double * accs) override;
111 bool getRefSpeed(int j, double * ref) override;
112 bool getRefSpeeds(double * spds) override;
113 bool getRefAcceleration(int j, double * acc) override;
114 bool getRefAccelerations(double *accs) override;
115 bool stop(int j) override;
116 bool stop() override;
117 bool positionMove(int n_joint, const int * joints, const double * refs) override;
118 bool relativeMove(int n_joint, const int * joints, const double * deltas) override;
119 bool checkMotionDone(int n_joint, const int * joints, bool * flags) override;
120 bool setRefSpeeds(int n_joint, const int * joints, const double * spds) override;
121 bool setRefAccelerations(int n_joint, const int *joints, const double * accs) override;
122 bool getRefSpeeds(int n_joint, const int * joints, double * spds) override;
123 bool getRefAccelerations(int n_joint, const int * joints, double * accs) override;
124 bool stop(int n_joint, const int * joints) override;
125 bool getTargetPosition(int joint, double * ref) override;
126 bool getTargetPositions(double * refs) override;
127 bool getTargetPositions(int n_joint, const int * joints, double * refs) override;
128
129 // --------- IVelocityControl Declarations. Implementation in IVelocityControlImpl.cpp ---------
130
131 bool velocityMove(int j, double sp) override;
132 bool velocityMove(const double * sp) override;
133 bool velocityMove(int n_joint, const int * joints, const double * spds) override;
134 bool getRefVelocity(int joint, double * vel) override;
135 bool getRefVelocities(double * vels) override;
136 bool getRefVelocities(int n_joint, const int *joints, double * vels) override;
137
138private:
139 enum jmc_mode { POSITION_MODE, VELOCITY_MODE, POSITION_DIRECT_MODE };
140
141 // General Joint Motion Controller parameters //
142 unsigned int axes {0};
143 jmc_mode controlMode {POSITION_MODE};
144
145 std::vector<double> storedPositions;
146 std::vector<yarp::dev::PolyDriver *> controlledDevices;
147 std::vector<roboticslab::ExposedJoint *> exposedJoints;
148};
149
150#endif // __REAL_TO_SIM_CONTROL_BOARD_HPP__
Definition RealToSimControlBoard_ParamsParser.h:46
Implements the YARP_dev IPositionControl, etc. interface class member functions.
Definition RealToSimControlBoard.hpp:67
Definition RealToSimControlBoard.hpp:21
Definition RealToSimControlBoard.hpp:36
The main, catch-all namespace for Robotics Lab UC3M.
Definition groups.dox:5