57 public yarp::dev::IAxisInfoRaw,
58 public yarp::dev::IControlLimitsRaw,
59 public yarp::dev::IControlModeRaw,
60 public yarp::dev::ICurrentControlRaw,
61 public yarp::dev::IEncodersTimedRaw,
62 public yarp::dev::IImpedanceControlRaw,
63 public yarp::dev::IInteractionModeRaw,
64 public yarp::dev::IJointFaultRaw,
65 public yarp::dev::IMotorRaw,
66 public yarp::dev::IMotorEncodersRaw,
67 public yarp::dev::IPidControlRaw,
68 public yarp::dev::IPositionControlRaw,
69 public yarp::dev::IPositionDirectRaw,
70 public yarp::dev::IRemoteVariablesRaw,
71 public yarp::dev::ITorqueControlRaw,
72 public yarp::dev::IVelocityControlRaw,
83 bool open(yarp::os::Searchable & config)
override;
84 bool close()
override;
88 unsigned int getId()
override;
97 bool getAxisNameRaw(
int axis, std::string & name)
override;
98 bool getJointTypeRaw(
int axis, yarp::dev::JointTypeEnum & type)
override;
102 bool setLimitsRaw(
int axis,
double min,
double max)
override;
103 bool getLimitsRaw(
int axis,
double * min,
double * max)
override;
104 bool setVelLimitsRaw(
int axis,
double min,
double max)
override;
105 bool getVelLimitsRaw(
int axis,
double * min,
double * max)
override;
109 bool getControlModesRaw(
int * modes)
override
110 {
return getControlModeRaw(0, &modes[0]); }
112 bool getControlModesRaw(
int n_joint,
const int * joints,
int * modes)
override
113 {
return getControlModeRaw(joints[0], &modes[0]); }
115 bool setControlModesRaw(
int * modes)
override
116 {
return setControlModeRaw(0, modes[0]); }
118 bool setControlModesRaw(
int n_joint,
const int * joints,
int * modes)
override
119 {
return setControlModeRaw(joints[0], modes[0]); }
123 bool getCurrentRaw(
int m,
double * curr)
override;
125 bool getCurrentsRaw(
double * currs)
override
126 {
return getCurrentRaw(0, &currs[0]); }
128 bool getCurrentRangeRaw(
int m,
double * min,
double * max)
override;
130 bool getCurrentRangesRaw(
double * min,
double * max)
override
131 {
return getCurrentRangeRaw(0, min, max); }
133 bool setRefCurrentRaw(
int m,
double curr)
override;
135 bool setRefCurrentsRaw(
const double * currs)
override
136 {
return setRefCurrentRaw(0, currs[0]); }
138 bool setRefCurrentsRaw(
int n_motor,
const int * motors,
const double * currs)
override
139 {
return setRefCurrentRaw(motors[0], currs[0]); }
141 bool getRefCurrentRaw(
int m,
double * curr)
override;
143 bool getRefCurrentsRaw(
double * currs)
override
144 {
return getRefCurrentRaw(0, &currs[0]); }
148 bool getAxes(
int * ax)
override;
149 bool resetEncoderRaw(
int j)
override;
151 bool resetEncodersRaw()
override
152 {
return resetEncoderRaw(0); }
154 bool setEncoderRaw(
int j,
double val)
override;
156 bool setEncodersRaw(
const double * vals)
override
157 {
return setEncoderRaw(0, vals[0]); }
159 bool getEncoderRaw(
int j,
double * v)
override;
161 bool getEncodersRaw(
double * encs)
override
162 {
return getEncoderRaw(0, &encs[0]); }
164 bool getEncoderSpeedRaw(
int j,
double * sp)
override;
166 bool getEncoderSpeedsRaw(
double * spds)
override
167 {
return getEncoderSpeedRaw(0, &spds[0]); }
169 bool getEncoderAccelerationRaw(
int j,
double * spds)
override;
171 bool getEncoderAccelerationsRaw(
double * accs)
override
172 {
return getEncoderAccelerationRaw(0, &accs[0]); }
176 bool getEncoderTimedRaw(
int j,
double * encs,
double * time)
override;
178 bool getEncodersTimedRaw(
double * encs,
double * times)
override
179 {
return getEncoderTimedRaw(0, &encs[0], ×[0]); }
183 bool getImpedanceRaw(
int j,
double * stiffness,
double * damping)
override
186 bool setImpedanceRaw(
int j,
double stiffness,
double damping)
override
189 bool setImpedanceOffsetRaw(
int j,
double offset)
override
192 bool getImpedanceOffsetRaw(
int j,
double * offset)
override
195 bool getCurrentImpedanceLimitRaw(
int j,
double * min_stiff,
double * max_stiff,
double * min_damp,
double * max_damp)
override
200 bool getInteractionModeRaw(
int axis, yarp::dev::InteractionModeEnum * mode)
override
203 bool getInteractionModesRaw(
int n_joints,
int * joints, yarp::dev::InteractionModeEnum * modes)
override
204 {
return getInteractionModeRaw(joints[0], &modes[0]); }
206 bool getInteractionModesRaw(yarp::dev::InteractionModeEnum * modes)
override
207 {
return getInteractionModeRaw(0, &modes[0]); }
209 bool setInteractionModeRaw(
int axis, yarp::dev::InteractionModeEnum mode)
override
212 bool setInteractionModesRaw(
int n_joints,
int * joints, yarp::dev::InteractionModeEnum * modes)
override
213 {
return setInteractionModeRaw(joints[0], modes[0]); }
215 bool setInteractionModesRaw(yarp::dev::InteractionModeEnum * modes)
override
216 {
return setInteractionModeRaw(0, modes[0]); }
220 bool getLastJointFaultRaw(
int j,
int & fault, std::string & message)
override;
224 bool getNumberOfMotorsRaw(
int * num)
override;
225 bool getTemperatureRaw(
int m,
double * val)
override;
226 bool getTemperaturesRaw(
double * vals)
override;
227 bool getTemperatureLimitRaw(
int m,
double * temp)
override;
228 bool setTemperatureLimitRaw(
int m,
double temp)
override;
229 bool getGearboxRatioRaw(
int m,
double * val)
override;
230 bool setGearboxRatioRaw(
int m,
double val)
override;
234 bool getNumberOfMotorEncodersRaw(
int * num)
override;
235 bool resetMotorEncoderRaw(
int m)
override;
237 bool resetMotorEncodersRaw()
override
238 {
return resetMotorEncoderRaw(0); }
240 bool setMotorEncoderCountsPerRevolutionRaw(
int m,
double cpr)
override;
241 bool getMotorEncoderCountsPerRevolutionRaw(
int m,
double * cpr)
override;
242 bool setMotorEncoderRaw(
int m,
double val)
override;
244 bool setMotorEncodersRaw(
const double * vals)
override
245 {
return setMotorEncoderRaw(0, vals[0]); }
247 bool getMotorEncoderRaw(
int m,
double * v)
override;
249 bool getMotorEncodersRaw(
double * encs)
override
250 {
return getMotorEncoderSpeedRaw(0, &encs[0]); }
252 bool getMotorEncoderTimedRaw(
int m,
double * encs,
double * stamp)
override;
254 bool getMotorEncodersTimedRaw(
double * encs,
double * stamps)
override
255 {
return getMotorEncoderTimedRaw(0, &encs[0], &stamps[0]); }
257 bool getMotorEncoderSpeedRaw(
int m,
double * sp)
override;
259 bool getMotorEncoderSpeedsRaw(
double * spds)
override
260 {
return getMotorEncoderSpeedRaw(0, &spds[0]); }
262 bool getMotorEncoderAccelerationRaw(
int m,
double * spds)
override;
264 bool getMotorEncoderAccelerationsRaw(
double * accs)
override
265 {
return getMotorEncoderAccelerationRaw(0, &accs[0]); }
269 bool setPidRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
const yarp::dev::Pid & pid)
override
272 bool setPidsRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
const yarp::dev::Pid * pids)
override
273 {
return setPidRaw(pidtype, 0, pids[0]); }
275 bool setPidReferenceRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double ref)
override
278 bool setPidReferencesRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
const double * refs)
override
279 {
return setPidReferenceRaw(pidtype, 0, refs[0]); }
281 bool setPidErrorLimitRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double limit)
override
284 bool setPidErrorLimitsRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
const double * limits)
override
285 {
return setPidErrorLimitRaw(pidtype, 0, limits[0]); }
287 bool getPidErrorRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double * err)
override
290 bool getPidErrorsRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
double * errs)
override
291 {
return getPidErrorRaw(pidtype, 0, &errs[0]); }
293 bool getPidOutputRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double * out)
override
296 bool getPidOutputsRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
double * outs)
override
297 {
return getPidOutputRaw(pidtype, 0, &outs[0]); }
299 bool getPidRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j, yarp::dev::Pid * pid)
override
302 bool getPidsRaw(
const yarp::dev::PidControlTypeEnum & pidtype, yarp::dev::Pid * pids)
override
303 {
return getPidRaw(pidtype, 0, &pids[0]); }
305 bool getPidReferenceRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double * ref)
override
308 bool getPidReferencesRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
double * refs)
override
309 {
return getPidReferenceRaw(pidtype, 0, &refs[0]); }
311 bool getPidErrorLimitRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double * limit)
override
314 bool getPidErrorLimitsRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
double * limits)
override
315 {
return getPidErrorLimitRaw(pidtype, 0, &limits[0]); }
317 bool resetPidRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j)
override
320 bool disablePidRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j)
override
323 bool enablePidRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j)
override
326 bool setPidOffsetRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
double v)
override
329 bool isPidEnabledRaw(
const yarp::dev::PidControlTypeEnum & pidtype,
int j,
bool * enabled)
override
334 using yarp::dev::IPositionControlRaw::positionMoveRaw;
336 bool positionMoveRaw(
const double * refs)
override
337 {
return positionMoveRaw(0, refs[0]); }
339 bool positionMoveRaw(
int n_joint,
const int * joints,
const double * refs)
override
340 {
return positionMoveRaw(joints[0], refs[0]); }
342 using yarp::dev::IPositionControlRaw::relativeMoveRaw;
344 bool relativeMoveRaw(
const double * deltas)
override
345 {
return relativeMoveRaw(0, deltas[0]); }
347 bool relativeMoveRaw(
int n_joint,
const int * joints,
const double * deltas)
override
348 {
return relativeMoveRaw(joints[0], deltas[0]); }
350 using yarp::dev::IPositionControlRaw::checkMotionDoneRaw;
352 bool checkMotionDoneRaw(
bool * flag)
override
353 {
return checkMotionDoneRaw(0, flag); }
355 bool checkMotionDoneRaw(
int n_joint,
const int * joints,
bool * flag)
override
356 {
return checkMotionDoneRaw(joints[0], flag); }
358 bool setRefSpeedsRaw(
const double * spds)
override
359 {
return setRefSpeedRaw(0, spds[0]); }
361 bool setRefSpeedsRaw(
int n_joint,
const int * joints,
const double * spds)
override
362 {
return setRefSpeedRaw(joints[0], spds[0]); }
364 using yarp::dev::IPositionControlRaw::setRefAccelerationRaw;
366 bool setRefAccelerationsRaw(
const double * accs)
override
367 {
return setRefAccelerationRaw(0, accs[0]); }
369 bool setRefAccelerationsRaw(
int n_joint,
const int * joints,
const double * accs)
override
370 {
return setRefAccelerationRaw(joints[0], accs[0]); }
372 bool getRefSpeedsRaw(
double * spds)
override
373 {
return getRefSpeedRaw(0, &spds[0]); }
375 bool getRefSpeedsRaw(
int n_joint,
const int * joints,
double * spds)
override
376 {
return getRefSpeedRaw(joints[0], &spds[0]); }
378 using yarp::dev::IPositionControlRaw::getRefAccelerationRaw;
380 bool getRefAccelerationsRaw(
double * accs)
override
381 {
return getRefAccelerationRaw(0, &accs[0]); }
383 bool getRefAccelerationsRaw(
int n_joint,
const int * joints,
double * accs)
override
384 {
return getRefAccelerationRaw(joints[0], &accs[0]); }
386 using yarp::dev::IPositionControlRaw::stopRaw;
388 bool stopRaw()
override
389 {
return stopRaw(0); }
391 bool stopRaw(
int n_joint,
const int * joints)
override
392 {
return stopRaw(joints[0]); }
394 bool getTargetPositionsRaw(
double * refs)
override
395 {
return getTargetPositionRaw(0, &refs[0]); }
397 bool getTargetPositionsRaw(
int n_joint,
const int * joints,
double * refs)
override
398 {
return getTargetPositionRaw(joints[0], &refs[0]); }
402 bool setPositionsRaw(
const double * refs)
override
403 {
return setPositionRaw(0, refs[0]); }
405 bool setPositionsRaw(
int n_joint,
const int * joints,
const double * refs)
override
406 {
return setPositionRaw(joints[0], refs[0]); }
408 bool getRefPositionsRaw(
double * refs)
override
409 {
return getRefPositionRaw(0, &refs[0]); }
411 bool getRefPositionsRaw(
int n_joint,
const int * joints,
double * refs)
override
412 {
return getRefPositionRaw(joints[0], &refs[0]); }
416 bool getRefTorqueRaw(
int j,
double * t)
override;
418 bool getRefTorquesRaw(
double * t)
override
419 {
return getRefTorqueRaw(0, &t[0]); }
421 bool setRefTorqueRaw(
int j,
double t)
override;
423 bool setRefTorquesRaw(
int n_joint,
const int * joints,
const double * t)
override
424 {
return setRefTorqueRaw(joints[0], t[0]); }
426 bool setRefTorquesRaw(
const double * t)
override
427 {
return setRefTorqueRaw(0, t[0]); }
429 bool getTorqueRaw(
int j,
double * t)
override;
431 bool getTorquesRaw(
double * t)
override
432 {
return getTorqueRaw(0, &t[0]); }
434 bool getTorqueRangeRaw(
int j,
double * min,
double * max)
override;
436 bool getTorqueRangesRaw(
double * min,
double * max)
override
437 {
return getTorqueRangeRaw(0, &min[0], &max[0]); }
439 bool getMotorTorqueParamsRaw(
int j, yarp::dev::MotorTorqueParameters * params)
override;
440 bool setMotorTorqueParamsRaw(
int j,
const yarp::dev::MotorTorqueParameters params)
override;
444 using yarp::dev::IVelocityControlRaw::velocityMoveRaw;
446 bool velocityMoveRaw(
const double * sp)
override
447 {
return velocityMoveRaw(0, sp[0]); }
449 bool velocityMoveRaw(
int n_joint,
const int * joints,
const double * spds)
override
450 {
return velocityMoveRaw(joints[0], spds[0]); }
452 bool getRefVelocitiesRaw(
double * vels)
override
453 {
return getRefVelocityRaw(0, &vels[0]); }
455 bool getRefVelocitiesRaw(
int n_joint,
const int * joints,
double * vels)
override
456 {
return getRefVelocityRaw(joints[0], &vels[0]); }
460 enum report_level { NONE, INFO, WARN, FAULT };
461 enum limit_switch { POSITIVE, NEGATIVE, INACTIVE };
466 const std::bitset<16> & actual;
467 const std::bitset<16> & stored;
470 bool reportBitToggle(
report_storage report,
int level, std::size_t pos,
const char * msgSet,
const char * msgReset =
nullptr);
472 virtual void interpretModesOfOperation(std::int8_t modesOfOperation) = 0;
473 virtual void interpretIpStatus(std::uint16_t ipStatus) {}
474 virtual void onPositionLimitTriggered() = 0;
475 virtual void reset() = 0;
502 CommandBuffer commandBuffer;
504 std::unique_ptr<StateObserver> controlModeObserverPtr {
new StateObserver(1.0)};
505 std::unique_ptr<EncoderRead> lastEncoderRead {
nullptr};
512 std::bitset<16> der2;
515 std::int8_t modesOfOperation {0};
519 bool configuredOnce {
false};
523 std::atomic<std::int16_t> lastCurrentRead {0};
525 std::atomic<yarp::conf::vocab32_t> actualControlMode {0};
526 std::atomic<yarp::conf::vocab32_t> requestedcontrolMode {0};
528 std::atomic<double> tr {0.0};
529 std::atomic<double> k {0.0};
530 std::atomic<int> encoderPulses {0};
532 std::atomic<double> maxVel {0.0};
533 std::atomic<double> min {0.0};
534 std::atomic<double> max {0.0};
535 std::atomic<double> refSpeed {0.0};
536 std::atomic<double> refAcceleration {0.0};
538 std::atomic<double> lastHeartbeat {0.0};
539 std::atomic<std::uint8_t> lastNmtState {0};
540 std::atomic<std::uint16_t> lastFaultCode {0};
541 std::atomic<const char *> lastFaultMessage;
543 std::atomic<limit_switch> limitSwitchState {INACTIVE};
547 yarp::conf::vocab32_t initialControlMode {0};
548 yarp::conf::vocab32_t jointType {0};
550 PdoConfiguration tpdo1Conf;
551 PdoConfiguration tpdo2Conf;
552 PdoConfiguration tpdo3Conf;
561 void interpretMsr(std::uint16_t msr);
562 void interpretMer(std::uint16_t mer);
563 void interpretDer(std::uint16_t der);
564 void interpretDer2(std::uint16_t der2);
565 void interpretCer(std::uint16_t cer);
566 void interpretStatusword(std::uint16_t statusword);
568 void handleTpdo1(std::uint16_t statusword, std::uint16_t msr, std::int8_t modesOfOperation);
569 void handleTpdo2(std::uint16_t mer, std::uint16_t der);
570 void handleTpdo3(std::int32_t position, std::int16_t current);
574 bool monitorWorker(
const yarp::os::YarpTimerEvent & event);
576 bool setLimitRaw(
double limit,
bool isMin);
577 bool getLimitRaw(
double * limit,
bool isMin);
579 yarp::dev::PolyDriver externalEncoderDevice;
580 yarp::dev::IEncodersTimedRaw * iEncodersTimedRawExternal {
nullptr};
583 yarp::os::Timer * monitorThread {
nullptr};