yarp-devices
Loading...
Searching...
No Matches
FakeJoint.hpp
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3#ifndef __FAKE_JOINT_HPP__
4#define __FAKE_JOINT_HPP__
5
6#include <string>
7
8#include <yarp/conf/version.h>
9
10#include <yarp/os/SystemClock.h>
11#include <yarp/dev/ControlBoardInterfaces.h>
12
13#include "ICanBusSharer.hpp"
14#include "FakeJoint_ParamsParser.h"
15
16#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
17constexpr auto JOINT_TYPE = yarp::dev::JointTypeEnum::VOCAB_JOINTTYPE_REVOLUTE; // yarpmotorgui can't handle VOCAB_JOINTTYPE_UNKNOWN
18#else
19constexpr auto JOINT_TYPE = yarp::dev::VOCAB_JOINTTYPE_REVOLUTE; // yarpmotorgui can't handle VOCAB_JOINTTYPE_UNKNOWN
20#endif
21
32class FakeJoint : public yarp::dev::DeviceDriver,
33 public yarp::dev::IAmplifierControlRaw,
34 public yarp::dev::IAxisInfoRaw,
35 public yarp::dev::IControlCalibrationRaw,
36 public yarp::dev::IControlLimitsRaw,
37 public yarp::dev::IControlModeRaw,
38 public yarp::dev::ICurrentControlRaw,
39 public yarp::dev::IEncodersTimedRaw,
40 public yarp::dev::IImpedanceControlRaw,
41 public yarp::dev::IInteractionModeRaw,
42 public yarp::dev::IMotorRaw,
43 public yarp::dev::IMotorEncodersRaw,
44 public yarp::dev::IPidControlRaw,
45 public yarp::dev::IPositionControlRaw,
46 public yarp::dev::IPositionDirectRaw,
47 public yarp::dev::IPWMControlRaw,
48 public yarp::dev::IRemoteVariablesRaw,
49 public yarp::dev::ITorqueControlRaw,
50 public yarp::dev::IVelocityControlRaw,
53{
54public:
55#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
56 using return_t = yarp::dev::ReturnValue;
57 constexpr static auto ret_ok = yarp::dev::ReturnValue::return_code::return_value_ok;
58#else
59 using return_t = bool;
60 constexpr static auto ret_ok = true;
61#endif
62
63 // --------- DeviceDriver declarations. Implementation in DeviceDriverImpl.cpp ---------
64
65 bool open(yarp::os::Searchable & config) override;
66
67 bool close() override
68 { return true; }
69
70 // --------- ICanBusSharer declarations ---------
71
72 unsigned int getId() override
73 { return 0; }
74 bool notifyMessage(const roboticslab::can_message & message) override
75 { return true; }
76 bool initialize() override
77 { return true; }
78 bool finalize() override
79 { return true; }
81 { return true; }
82 bool synchronize(double timestamp) override
83 { return true; }
84
85 // --------- IAmplifierControlRaw declarations ---------
86
87 return_t enableAmpRaw(int j) override
88 { return ret_ok; }
89 return_t disableAmpRaw(int j) override
90 { return ret_ok; }
91 return_t getAmpStatusRaw(int j, int * v) override
92 { *v = 0; return ret_ok; }
93 return_t getAmpStatusRaw(int * st) override
94 { *st = 0; return ret_ok; }
95 return_t getMaxCurrentRaw(int j, double * v) override
96 { *v = 0.0; return ret_ok; }
97 return_t setMaxCurrentRaw(int j, double v) override
98 { return ret_ok; }
99 return_t getNominalCurrentRaw(int m, double * val) override
100 { *val = 0.0; return ret_ok; }
101 return_t setNominalCurrentRaw(int m, double val) override
102 { return ret_ok; }
103 return_t getPeakCurrentRaw(int m, double * val) override
104 { *val = 0.0; return ret_ok; }
105 return_t setPeakCurrentRaw(int m, double val) override
106 { return ret_ok; }
107 return_t getPWMRaw(int j, double * val) override
108 { *val = 0.0; return ret_ok; }
109 return_t getPWMLimitRaw(int j, double * val) override
110 { *val = 0.0; return ret_ok; }
111 return_t setPWMLimitRaw(int j, double val) override
112 { return ret_ok; }
113 return_t getPowerSupplyVoltageRaw(int j, double * val) override
114 { *val = 0.0; return ret_ok; }
115
116 // --------- IAxisInfoRaw declarations ---------
117
118 return_t getAxisNameRaw(int axis, std::string & name) override
119 { name = m_jointName; return ret_ok; }
120 return_t getJointTypeRaw(int axis, yarp::dev::JointTypeEnum & type) override
121 { type = JOINT_TYPE; return ret_ok; }
122
123 // --------- IControlCalibrationRaw declarations ---------
124
125 return_t calibrateAxisWithParamsRaw(int axis, unsigned int type, double p1, double p2, double p3) override
126 { return ret_ok; }
127 return_t setCalibrationParametersRaw(int axis, const yarp::dev::CalibrationParameters & params) override
128 { return ret_ok; }
129 return_t calibrationDoneRaw(int j) override
130 { return ret_ok; }
131
132 // --------- IControlLimitsRaw declarations ---------
133
134#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
135 return_t setPosLimitsRaw(int axis, double min, double max) override
136 { return ret_ok; }
137 return_t getPosLimitsRaw(int axis, double * min, double * max) override
138 { *min = *max = 0.0; return ret_ok; }
139#else
140 return_t setLimitsRaw(int axis, double min, double max) override
141 { return ret_ok; }
142 return_t getLimitsRaw(int axis, double * min, double * max) override
143 { *min = *max = 0.0; return ret_ok; }
144#endif
145 return_t setVelLimitsRaw(int axis, double min, double max) override
146 { return ret_ok; }
147 return_t getVelLimitsRaw(int axis, double * min, double * max) override
148 { *min = *max = 0.0; return ret_ok; }
149
150 // --------- IControlModeRaw declarations ---------
151
152#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
153 return_t getAvailableControlModesRaw(int j, std::vector<yarp::dev::SelectableControlModeEnum> & avail) override
154 { using t = yarp::dev::SelectableControlModeEnum;
155 avail = {t::VOCAB_CM_IDLE, t::VOCAB_CM_TORQUE, t::VOCAB_CM_POSITION, t::VOCAB_CM_POSITION_DIRECT, t::VOCAB_CM_VELOCITY,
156 t::VOCAB_CM_VELOCITY_DIRECT, t::VOCAB_CM_CURRENT, t::VOCAB_CM_PWM, t::VOCAB_CM_MIXED, t::VOCAB_CM_FORCE_IDLE};
157 return ret_ok; }
158 return_t getControlModeRaw(int j, yarp::dev::ControlModeEnum & mode) override
159 { mode = controlMode; return ret_ok; }
160 return_t getControlModesRaw(std::vector<yarp::dev::ControlModeEnum> & modes) override
161 { return getControlModeRaw(0, modes[0]); }
162 return_t getControlModesRaw(const std::vector<int> & joints, std::vector<yarp::dev::ControlModeEnum> & modes) override
163 { return getControlModeRaw(0, modes[0]); }
164 return_t setControlModeRaw(int j, yarp::dev::SelectableControlModeEnum mode) override
165 { controlMode = static_cast<yarp::dev::ControlModeEnum>(mode); return ret_ok; }
166 return_t setControlModesRaw(const std::vector<yarp::dev::SelectableControlModeEnum> & modes) override
167 { return setControlModeRaw(0, modes[0]); }
168 return_t setControlModesRaw(const std::vector<int> & joints, const std::vector<yarp::dev::SelectableControlModeEnum> & modes) override
169 { return setControlModeRaw(0, modes[0]); }
170#else
171 return_t getControlModeRaw(int j, int * mode) override
172 { *mode = controlMode; return ret_ok; }
173 return_t getControlModesRaw(int * modes) override
174 { return getControlModeRaw(0, &modes[0]); }
175 return_t getControlModesRaw(int n_joint, const int * joints, int * modes) override
176 { return getControlModeRaw(0, &modes[0]); }
177 return_t setControlModeRaw(int j, int mode) override
178 { controlMode = mode; return ret_ok; }
179 return_t setControlModesRaw(int * modes) override
180 { return setControlModeRaw(0, modes[0]); }
181 return_t setControlModesRaw(int n_joint, const int * joints, int * modes) override
182 { return setControlModeRaw(0, modes[0]); }
183#endif
184
185 // --------- ICurrentControlRaw declarations ---------
186
187 return_t getCurrentRaw(int m, double * curr) override
188 { *curr = 0.0; return ret_ok; }
189 return_t getCurrentsRaw(double * currs) override
190 { return getCurrentRaw(0, &currs[0]); }
191 return_t getCurrentRangeRaw(int m, double * min, double * max) override
192 { *min = *max = 0.0; return ret_ok; }
193 return_t getCurrentRangesRaw(double * mins, double * maxs) override
194 { return getCurrentRangeRaw(0, &mins[0], &maxs[0]); }
195 return_t setRefCurrentRaw(int m, double curr) override
196 { return ret_ok; }
197 return_t setRefCurrentsRaw(const double * currs) override
198 { return ret_ok; }
199 return_t setRefCurrentsRaw(int n_motor, const int * motors, const double * currs) override
200 { return ret_ok; }
201 return_t getRefCurrentRaw(int m, double * curr) override
202 { *curr = 0.0; return ret_ok; }
203 return_t getRefCurrentsRaw(double * currs) override
204 { return getRefCurrentRaw(0, &currs[0]); }
205
206 // ---------- IEncodersRaw declarations ----------.
207
208#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
209 return_t getAxes(std::size_t & ax) override
210 { ax = 1; return ret_ok; }
211#else
212 return_t getAxes(int * ax) override
213 { *ax = 1; return ret_ok; }
214#endif
215 return_t resetEncoderRaw(int j) override
216 { return ret_ok; }
217 return_t resetEncodersRaw() override
218 { return ret_ok; }
219 return_t setEncoderRaw(int j, double val) override
220 { return ret_ok; }
221 return_t setEncodersRaw(const double * vals) override
222 { return ret_ok; }
223 return_t getEncoderRaw(int j, double * v) override
224 { *v = 0.0; return ret_ok; }
225 return_t getEncodersRaw(double * encs) override
226 { return getEncoderRaw(0, &encs[0]); }
227 return_t getEncoderSpeedRaw(int j, double * spd) override
228 { *spd = 0.0; return ret_ok; }
229 return_t getEncoderSpeedsRaw(double * spds) override
230 { return getEncoderRaw(0, &spds[0]); }
231 return_t getEncoderAccelerationRaw(int j, double * acc) override
232 { *acc = 0.0; return ret_ok; }
233 return_t getEncoderAccelerationsRaw(double * accs) override
234 { return getEncoderAccelerationRaw(0, &accs[0]); }
235
236 // ---------- IEncodersTimedRaw declarations ----------
237
238 return_t getEncoderTimedRaw(int j, double * enc, double * time) override
239 { *enc = 0.0; *time = yarp::os::SystemClock::nowSystem(); return ret_ok; }
240 return_t getEncodersTimedRaw(double * encs, double * times) override
241 { return getEncoderTimedRaw(0, &encs[0], &times[0]); }
242
243 // --------- IImpedanceControlRaw declarations ---------
244
245 return_t getImpedanceRaw(int j, double * stiffness, double * damping) override
246 { *stiffness = *damping = 0.0; return ret_ok; }
247 return_t setImpedanceRaw(int j, double stiffness, double damping) override
248 { return ret_ok; }
249 return_t setImpedanceOffsetRaw(int j, double offset) override
250 { return ret_ok; }
251 return_t getImpedanceOffsetRaw(int j, double * offset) override
252 { *offset = 0.0; return ret_ok; }
253 return_t getCurrentImpedanceLimitRaw(int j, double * min_stiff, double * max_stiff, double * min_damp, double * max_damp) override
254 { *min_stiff = *max_stiff = *min_damp = *max_damp = 0.0; return ret_ok; }
255
256 // ------- IInteractionModeRaw declarations -------
257
258#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
259 return_t getInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum & mode) override
260 { mode = interactionMode; return ret_ok; }
261 return_t getInteractionModesRaw(std::vector<yarp::dev::InteractionModeEnum> & modes) override
262 { return getInteractionModeRaw(0, modes[0]); }
263 return_t getInteractionModesRaw(const std::vector<int> & joints, std::vector<yarp::dev::InteractionModeEnum> & modes) override
264 { return getInteractionModeRaw(0, modes[0]); }
265 return_t setInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum mode) override
266 { interactionMode = mode; return ret_ok; }
267 return_t setInteractionModesRaw(const std::vector<yarp::dev::InteractionModeEnum> & modes) override
268 { return ret_ok; }
269 return_t setInteractionModesRaw(const std::vector<int> & joints, const std::vector<yarp::dev::InteractionModeEnum> & modes) override
270 { return ret_ok; }
271#else
272 return_t getInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum * mode) override
273 { *mode = interactionMode; return ret_ok; }
274 return_t getInteractionModesRaw(yarp::dev::InteractionModeEnum * modes) override
275 { return getInteractionModeRaw(0, &modes[0]); }
276 return_t getInteractionModesRaw(int n_joints, int * joints, yarp::dev::InteractionModeEnum * modes) override
277 { return getInteractionModeRaw(0, &modes[0]); }
278 return_t setInteractionModeRaw(int axis, yarp::dev::InteractionModeEnum mode) override
279 { interactionMode = mode; return ret_ok; }
280 return_t setInteractionModesRaw(yarp::dev::InteractionModeEnum * modes) override
281 { return ret_ok; }
282 return_t setInteractionModesRaw(int n_joints, int * joints, yarp::dev::InteractionModeEnum * modes) override
283 { return ret_ok; }
284#endif
285
286 // --------- IMotorRaw declarations ---------
287
288 return_t getNumberOfMotorsRaw(int * num) override
289#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
290 { std::size_t ax; auto ret = getAxes(ax); *num = static_cast<int>(ax); return ret; }
291#else
292 { return getAxes(num); }
293#endif
294 return_t getTemperatureRaw(int m, double * val) override
295 { *val = 0.0; return ret_ok; }
296 return_t getTemperaturesRaw(double * vals) override
297 { return getTemperatureRaw(0, &vals[0]); }
298 return_t getTemperatureLimitRaw(int m, double * temp) override
299 { *temp = 0.0; return ret_ok; }
300 return_t setTemperatureLimitRaw(int m, double temp) override
301 { return ret_ok; }
302 return_t getGearboxRatioRaw(int m, double * val) override
303 { *val = 0.0; return ret_ok; }
304 return_t setGearboxRatioRaw(int m, double val) override
305 { return ret_ok; }
306
307 // --------- IMotorEncodersRaw declarations ---------
308
309 return_t getNumberOfMotorEncodersRaw(int * num) override
310#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
311 { std::size_t ax; auto ret = getAxes(ax); *num = static_cast<int>(ax); return ret; }
312#else
313 { return getAxes(num); }
314#endif
315 return_t resetMotorEncoderRaw(int m) override
316 { return ret_ok; }
317 return_t resetMotorEncodersRaw() override
318 { return ret_ok; }
319 return_t setMotorEncoderCountsPerRevolutionRaw(int m, double cpr) override
320 { return ret_ok; }
321 return_t getMotorEncoderCountsPerRevolutionRaw(int m, double * cpr) override
322 { *cpr = 0.0; return ret_ok; }
323 return_t setMotorEncoderRaw(int m, double val) override
324 { return ret_ok; }
325 return_t setMotorEncodersRaw(const double * vals) override
326 { return ret_ok; }
327 return_t getMotorEncoderRaw(int m, double * v) override
328 { *v = 0.0; return ret_ok; }
329 return_t getMotorEncodersRaw(double * encs) override
330 { return getMotorEncoderRaw(0, &encs[0]); }
331 return_t getMotorEncoderTimedRaw(int m, double * enc, double * stamp) override
332 { *enc = 0.0; *stamp = yarp::os::SystemClock::nowSystem(); return ret_ok; }
333 return_t getMotorEncodersTimedRaw(double * encs, double * stamps) override
334 { return getMotorEncoderTimedRaw(0, &encs[0], &stamps[0]); }
335 return_t getMotorEncoderSpeedRaw(int m, double * sp) override
336 { *sp = 0.0; return ret_ok; }
337 return_t getMotorEncoderSpeedsRaw(double *spds) override
338 { return getMotorEncoderSpeedRaw(0, &spds[0]); }
339 return_t getMotorEncoderAccelerationRaw(int m, double * acc) override
340 { *acc = 0.0; return ret_ok; }
341 return_t getMotorEncoderAccelerationsRaw(double * accs) override
342 { return getMotorEncoderAccelerationRaw(0, &accs[0]); }
343
344 // --------- IPidControlRaw declarations ---------
345
346#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
347 return_t getAvailablePidsRaw(int j, std::vector<yarp::dev::PidControlTypeEnum> & avail) override
348 { /* too many to list them all here */ return ret_ok; }
349#endif
350 return_t setPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, const yarp::dev::Pid & pid) override
351 { return ret_ok; }
352 return_t setPidsRaw(const yarp::dev::PidControlTypeEnum & pidtype, const yarp::dev::Pid * pids) override
353 { return ret_ok; }
354 return_t setPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double ref) override
355 { return ret_ok; }
356 return_t setPidReferencesRaw(const yarp::dev::PidControlTypeEnum & pidtype, const double * refs) override
357 { return ret_ok; }
358 return_t setPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double limit) override
359 { return ret_ok; }
360 return_t setPidErrorLimitsRaw(const yarp::dev::PidControlTypeEnum & pidtype, const double * limits) override
361 { return ret_ok; }
362 return_t setPidOffsetRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double v) override
363 { return ret_ok; }
364#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
365 return_t setPidFeedforwardRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double v) override
366 { return ret_ok; }
367#endif
368 return_t getPidErrorRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * err) override
369 { *err = 0.0; return ret_ok; }
370 return_t getPidErrorsRaw(const yarp::dev::PidControlTypeEnum & pidtype, double * errs) override
371 { return getPidErrorRaw(pidtype, 0, &errs[0]); }
372 return_t getPidOutputRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * out) override
373 { *out = 0.0; return ret_ok; }
374 return_t getPidOutputsRaw(const yarp::dev::PidControlTypeEnum & pidtype, double * outs) override
375 { return getPidOutputRaw(pidtype, 0, &outs[0]); }
376 return_t getPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, yarp::dev::Pid * pid) override
377 { return ret_ok; }
378 return_t getPidsRaw(const yarp::dev::PidControlTypeEnum & pidtype, yarp::dev::Pid * pids) override
379 { return ret_ok; }
380 return_t getPidReferenceRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * ref) override
381 { *ref = 0.0; return ret_ok; }
382 return_t getPidReferencesRaw(const yarp::dev::PidControlTypeEnum & pidtype, double * refs) override
383 { return getPidReferenceRaw(pidtype, 0, &refs[0]); }
384 return_t getPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double * limit) override
385 { *limit = 0.0; return ret_ok; }
386 return_t getPidErrorLimitsRaw(const yarp::dev::PidControlTypeEnum & pidtype, double * limits) override
387 { return getPidErrorLimitRaw(pidtype, 0, &limits[0]); }
388 return_t resetPidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override
389 { return ret_ok; }
390 return_t disablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override
391 { return ret_ok; }
392 return_t enablePidRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j) override
393 { return ret_ok; }
394#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
395 return_t getPidOffsetRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double & v) override
396 { v = 0.0; return ret_ok; }
397 return_t getPidFeedforwardRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, double & v) override
398 { return ret_ok; }
399 return_t isPidEnabledRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, bool & enabled) override
400 { enabled = true; return ret_ok; }
401 return_t getPidExtraInfoRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, yarp::dev::PidExtraInfo & info) override
402 { return ret_ok; }
403 return_t getPidExtraInfosRaw(const yarp::dev::PidControlTypeEnum & pidtype, std::vector<yarp::dev::PidExtraInfo> & info) override
404 { return ret_ok; }
405#else
406 return_t isPidEnabledRaw(const yarp::dev::PidControlTypeEnum & pidtype, int j, bool * enabled) override
407 { *enabled = true; return ret_ok; }
408#endif
409
410 // ------- IPositionControlRaw declarations -------
411
412 //return_t getAxesRaw(int * ax) override;
413 return_t positionMoveRaw(int j, double ref) override
414 { return ret_ok; }
415 return_t positionMoveRaw(const double * refs) override
416 { return ret_ok; }
417 return_t positionMoveRaw(int n_joint, const int * joints, const double * refs) override
418 { return ret_ok; }
419 return_t relativeMoveRaw(int j, double delta) override
420 { return ret_ok; }
421 return_t relativeMoveRaw(const double * deltas) override
422 { return ret_ok; }
423 return_t relativeMoveRaw(int n_joint, const int * joints, const double * deltas) override
424 { return ret_ok; }
425#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
426 return_t checkMotionDoneRaw(int j, bool & flag) override
427 { flag = true; return ret_ok; }
428 return_t checkMotionDoneRaw(bool & flag) override
429 { return checkMotionDoneRaw(0, flag); }
430 return_t checkMotionDoneRaw(const std::vector<int> & joints, bool & flag) override
431 { return checkMotionDoneRaw(0, flag); }
432 return_t setTrajSpeedRaw(int j, double sp) override
433 { return ret_ok; }
434 return_t setTrajSpeedsRaw(const double * spds) override
435 { return ret_ok; }
436 return_t setTrajSpeedsRaw(int n_joint, const int * joints, const double * spds) override
437 { return ret_ok; }
438 return_t setTrajAccelerationRaw(int j, double acc) override
439 { return ret_ok; }
440 return_t setTrajAccelerationsRaw(const double * accs) override
441 { return ret_ok; }
442 return_t setTrajAccelerationsRaw(int n_joint, const int * joints, const double * accs) override
443 { return ret_ok; }
444 return_t getTrajSpeedRaw(int j, double * spd) override
445 { *spd = 0.0; return ret_ok; }
446 return_t getTrajSpeedsRaw(double * spds) override
447 { return getTrajSpeedRaw(0, &spds[0]); }
448 return_t getTrajSpeedsRaw(int n_joint, const int * joints, double * spds) override
449 { return getTrajSpeedRaw(0, &spds[0]); }
450 return_t getTrajAccelerationRaw(int j, double * acc) override
451 { *acc = 0.0; return ret_ok; }
452 return_t getTrajAccelerationsRaw(double * accs) override
453 { return getTrajAccelerationRaw(0, &accs[0]); }
454 return_t getTrajAccelerationsRaw(int n_joint, const int * joints, double * accs) override
455 { return getTrajAccelerationRaw(0, &accs[0]); }
456#else
457 return_t checkMotionDoneRaw(int j, bool * flag) override
458 { *flag = true; return ret_ok; }
459 return_t checkMotionDoneRaw(bool * flag) override
460 { return checkMotionDoneRaw(0, flag); }
461 return_t checkMotionDoneRaw(int n_joint, const int * joints, bool * flag) override
462 { return checkMotionDoneRaw(0, flag); }
463 return_t setRefSpeedRaw(int j, double sp) override
464 { return ret_ok; }
465 return_t setRefSpeedsRaw(const double * spds) override
466 { return ret_ok; }
467 return_t setRefSpeedsRaw(int n_joint, const int * joints, const double * spds) override
468 { return ret_ok; }
469 return_t setRefAccelerationRaw(int j, double acc) override
470 { return ret_ok; }
471 return_t setRefAccelerationsRaw(const double * accs) override
472 { return ret_ok; }
473 return_t setRefAccelerationsRaw(int n_joint, const int * joints, const double * accs) override
474 { return ret_ok; }
475 return_t getRefSpeedRaw(int j, double * spd) override
476 { *spd = 0.0; return ret_ok; }
477 return_t getRefSpeedsRaw(double * spds) override
478 { return getRefSpeedRaw(0, &spds[0]); }
479 return_t getRefSpeedsRaw(int n_joint, const int * joints, double * spds) override
480 { return getRefSpeedRaw(0, &spds[0]); }
481 return_t getRefAccelerationRaw(int j, double * acc) override
482 { *acc = 0.0; return ret_ok; }
483 return_t getRefAccelerationsRaw(double * accs) override
484 { return getRefAccelerationRaw(0, &accs[0]); }
485 return_t getRefAccelerationsRaw(int n_joint, const int * joints, double * accs) override
486 { return getRefAccelerationRaw(0, &accs[0]); }
487#endif
488 return_t stopRaw(int j) override
489 { return ret_ok; }
490 return_t stopRaw() override
491 { return ret_ok; }
492 return_t stopRaw(int n_joint, const int *joints) override
493 { return ret_ok; }
494 return_t getTargetPositionRaw(int joint, double * ref) override
495 { *ref = 0.0; return ret_ok; }
496 return_t getTargetPositionsRaw(double * refs) override
497 { return getTargetPositionRaw(0, &refs[0]); }
498 return_t getTargetPositionsRaw(int n_joint, const int * joints, double * refs) override
499 { return getTargetPositionRaw(0, &refs[0]); }
500
501 // ------- IPositionDirectRaw declarations -------
502
503 return_t setPositionRaw(int j, double ref) override
504 { return ret_ok; }
505 return_t setPositionsRaw(const double * refs) override
506 { return ret_ok; }
507 return_t setPositionsRaw(int n_joint, const int * joints, const double * refs) override
508 { return ret_ok; }
509 return_t getRefPositionRaw(int joint, double * ref) override
510 { *ref = 0.0; return ret_ok; }
511 return_t getRefPositionsRaw(double * refs) override
512 { return getRefPositionRaw(0, &refs[0]); }
513 return_t getRefPositionsRaw(int n_joint, const int * joints, double * refs) override
514 { return getRefPositionRaw(0, &refs[0]); }
515
516 // --------- IPWMControl declarations ---------
517
518 return_t setRefDutyCycleRaw(int m, double ref) override
519 { return ret_ok; }
520 return_t setRefDutyCyclesRaw(const double * refs) override
521 { return ret_ok; }
522 return_t getRefDutyCycleRaw(int m, double * ref) override
523 { *ref = 0.0; return ret_ok; }
524 return_t getRefDutyCyclesRaw(double * refs) override
525 { return getRefDutyCycleRaw(0, &refs[0]); }
526 return_t getDutyCycleRaw(int m, double * val) override
527 { *val = 0.0; return ret_ok; }
528 return_t getDutyCyclesRaw(double * vals) override
529 { return getDutyCycleRaw(0, &vals[0]); }
530
531 // ------- IRemoteVariablesRaw declarations -------
532
533 return_t getRemoteVariableRaw(std::string key, yarp::os::Bottle & val) override
534 { return ret_ok; }
535 return_t setRemoteVariableRaw(std::string key, const yarp::os::Bottle & val) override
536 { return ret_ok; }
537 return_t getRemoteVariablesListRaw(yarp::os::Bottle * listOfKeys) override
538 { return ret_ok; }
539
540 // -------- ITorqueControlRaw declarations --------
541
542 return_t getRefTorqueRaw(int j, double * t) override
543 { *t = 0.0; return ret_ok; }
544 return_t getRefTorquesRaw(double * t) override
545 { return getRefTorqueRaw(0, &t[0]); }
546 return_t setRefTorqueRaw(int j, double t) override
547 { return ret_ok; }
548 return_t setRefTorquesRaw(const double * t) override
549 { return ret_ok; }
550 return_t setRefTorquesRaw(int n_joint, const int * joints, const double * t) override
551 { return ret_ok; }
552 return_t getMotorTorqueParamsRaw(int j, yarp::dev::MotorTorqueParameters * params) override
553 { return ret_ok; }
554 return_t setMotorTorqueParamsRaw(int j, const yarp::dev::MotorTorqueParameters params) override
555 { return ret_ok; }
556 return_t getTorqueRaw(int j, double * t) override
557 { *t = 0.0; return ret_ok; }
558 return_t getTorquesRaw(double * t) override
559 { return getTorqueRaw(0, &t[0]); }
560 return_t getTorqueRangeRaw(int j, double * min, double * max) override
561 { *min = *max = 0.0; return ret_ok; }
562 return_t getTorqueRangesRaw(double * mins, double * maxs) override
563 { return getTorqueRangeRaw(0, &mins[0], &maxs[0]); }
564
565 // --------- IVelocityControl declarations ---------
566
567 return_t velocityMoveRaw(int j, double spd) override
568 { return ret_ok; }
569 return_t velocityMoveRaw(const double * spds) override
570 { return ret_ok; }
571 return_t velocityMoveRaw(int n_joint, const int * joints, const double * spds) override
572 { return ret_ok; }
573#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
574 return_t getTargetVelocityRaw(int joint, double * vel) override
575 { *vel = 0.0; return ret_ok; }
576 return_t getTargetVelocitiesRaw(double * vels) override
577 { return getTargetVelocityRaw(0, &vels[0]); }
578 return_t getTargetVelocitiesRaw(int n_joint, const int * joints, double * vels) override
579 { return getTargetVelocityRaw(0, &vels[0]); }
580#else
581 return_t getRefVelocityRaw(int joint, double * vel) override
582 { *vel = 0.0; return ret_ok; }
583 return_t getRefVelocitiesRaw(double * vels) override
584 { return getRefVelocityRaw(0, &vels[0]); }
585 return_t getRefVelocitiesRaw(int n_joint, const int * joints, double * vels) override
586 { return getRefVelocityRaw(0, &vels[0]); }
587#endif
588
589private:
590#if YARP_VERSION_COMPARE(>=, 4, 0, 0)
591 yarp::dev::ControlModeEnum controlMode {VOCAB_CM_CONFIGURED};
592#else
593 int controlMode {VOCAB_CM_CONFIGURED};
594#endif
595 yarp::dev::InteractionModeEnum interactionMode {yarp::dev::VOCAB_IM_UNKNOWN};
596};
597
598#endif // __FAKE_JOINT_HPP__
Definition FakeJoint_ParamsParser.h:42
Implementation for a fake joint (instant movement) as a single CAN bus joint (control board raw inter...
Definition FakeJoint.hpp:53
bool finalize() override
Finalize CAN node communications.
Definition FakeJoint.hpp:78
bool notifyMessage(const roboticslab::can_message &message) override
Notify observers that a new CAN message has arrived.
Definition FakeJoint.hpp:74
unsigned int getId() override
Retrieve CAN node ID.
Definition FakeJoint.hpp:72
bool initialize() override
Perform CAN node initialization.
Definition FakeJoint.hpp:76
bool synchronize(double timestamp) override
Perform synchronized action on CAN master's request.
Definition FakeJoint.hpp:82
bool registerSender(roboticslab::ICanSenderDelegate *sender) override
Pass a handle to a CAN sender delegate instance.
Definition FakeJoint.hpp:80
Abstract base for a CAN bus sharer.
Definition ICanBusSharer.hpp:25
Implementation-agnostic consumer for TX CAN transfers.
Definition ICanSenderDelegate.hpp:22
Proxy CAN message structure.
Definition CanMessage.hpp:20