YARP CiA-402 EtherCAT Device 0.6.0
YARP device plugin for EtherCAT CiA-402 drives
Loading...
Searching...
No Matches
CiA402MotionControl.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef YARP_DEV_CIA402_MOTION_CONTROL_H
5#define YARP_DEV_CIA402_MOTION_CONTROL_H
6
7#include <memory>
8#include <string>
9
10#include <yarp/dev/DeviceDriver.h>
11#include <yarp/dev/IAxisInfo.h>
12#include <yarp/dev/IControlLimits.h>
13#include <yarp/dev/IControlMode.h>
14#include <yarp/dev/ICurrentControl.h>
15#include <yarp/dev/IEncodersTimed.h>
16#include <yarp/dev/IInteractionMode.h>
17#include <yarp/dev/IJointFault.h>
18#include <yarp/dev/IMotor.h>
19#include <yarp/dev/IMotorEncoders.h>
20#include <yarp/dev/IPositionControl.h>
21#include <yarp/dev/IPositionDirect.h>
22#include <yarp/dev/ITorqueControl.h>
23#include <yarp/dev/IVelocityControl.h>
24#include <yarp/os/PeriodicThread.h>
25
26namespace yarp
27{
28namespace dev
29{
30
31/**
32 * @brief Minimal CiA‑402 motion‑control driver based on SOEM.
33 *
34 * This class owns the EtherCAT master cycle via yarp::os::PeriodicThread.
35 */
36class CiA402MotionControl : public yarp::dev::DeviceDriver,
37 public yarp::os::PeriodicThread,
38 public yarp::dev::IMotorEncoders,
39 public yarp::dev::IEncodersTimed,
40 public yarp::dev::IAxisInfo,
41 public yarp::dev::IControlMode,
42 public yarp::dev::ITorqueControl,
43 public yarp::dev::IVelocityControl,
44 public yarp::dev::IPositionControl,
45 public yarp::dev::IPositionDirect,
46 public yarp::dev::ICurrentControl,
47 public yarp::dev::IJointFault,
48 public yarp::dev::IMotor,
49 public yarp::dev::IControlLimits,
50 public yarp::dev::IInteractionMode
51{
52public:
53 /**
54 * @brief Constructor.
55 *
56 * @param period The period of the thread in seconds.
57 * @param useSystemClock Whether to use the system clock for timing.
58 */
59 explicit CiA402MotionControl(double period,
60 yarp::os::ShouldUseSystemClock useSystemClock
61 = yarp::os::ShouldUseSystemClock::Yes);
62 /**
63 * @brief Default constructor.
64 *
65 * This constructor sets the period to 0.01 seconds and uses the system clock.
66 */
68
69 /**
70 * @brief Destructor.
71 *
72 * Cleans up the resources used by the driver.
73 */
75
76 // clang-format off
77 /**
78 * @brief Opens the device driver.
79 *
80 * @param config The configuration parameters for the driver.
81 * @note The configuration parameters should include:
82 * | Parameter Name | Type | Description | Is Mandatory? |
83 * |:----------------------:|:--------:|-----------------------------------------------|:-------------:|
84 * | ifname | string | Name of the network interface to use | Yes |
85 * | num_axes | int | Number of axes to control | Yes |
86 * | first_slave | int | Index of the slave to start from (default: 1) | No |
87 * | expected_slave_name | string | Expected name of the slave | No |
88 * @return true if the driver was opened successfully, false otherwise.
89 */
90 bool open(yarp::os::Searchable& config) override;
91 // clang-format on
92
93 /**
94 * @brief Closes the device driver.
95 *
96 * @return true if the driver was closed successfully, false otherwise.
97 */
98 bool close() override;
99
100 // ---------------- PeriodicThread --------------
101 /**
102 * @brief Runs the periodic thread.
103 *
104 * This function is called periodically at the specified interval.
105 */
106 void run() override;
107
108 // ---------------- IMotorEncoders --------------
109
110 /**
111 * @brief Gets the number of motor encoders.
112 * @param num Pointer to an integer where the number of encoders will be stored.
113 * @return true if successful, false otherwise.
114 */
115 bool getNumberOfMotorEncoders(int* num) override;
116
117 /**
118 * @brief Resets the specified motor encoder to zero.
119 * @param m Index of the motor encoder to reset.
120 * @return true if successful, false otherwise.
121 */
122 bool resetMotorEncoder(int m) override;
123
124 /**
125 * @brief Resets all motor encoders to zero.
126 * @return true if successful, false otherwise.
127 */
128 bool resetMotorEncoders() override;
129
130 /**
131 * @brief Sets the counts per revolution for a specific motor encoder.
132 * @param m Index of the motor encoder.
133 * @param cpr Counts per revolution value to set.
134 * @return true if successful, false otherwise.
135 */
136 bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override;
137
138 /**
139 * @brief Gets the counts per revolution for a specific motor encoder.
140 * @param m Index of the motor encoder.
141 * @param cpr Pointer to store the counts per revolution value.
142 * @return true if successful, false otherwise.
143 */
144 bool getMotorEncoderCountsPerRevolution(int m, double* cpr) override;
145
146 /**
147 * @brief Sets the value of a specific motor encoder.
148 * @param m Index of the motor encoder.
149 * @param val Value to set.
150 * @return true if successful, false otherwise.
151 */
152 bool setMotorEncoder(int m, const double val) override;
153
154 /**
155 * @brief Sets the values of all motor encoders.
156 * @param vals Array of values to set for each encoder.
157 * @return true if successful, false otherwise.
158 */
159 bool setMotorEncoders(const double* vals) override;
160
161 /**
162 * @brief Gets the value of a specific motor encoder.
163 * @param m Index of the motor encoder.
164 * @param v Pointer to store the encoder value.
165 * @return true if successful, false otherwise.
166 */
167 bool getMotorEncoder(int m, double* v) override;
168
169 /**
170 * @brief Gets the values of all motor encoders.
171 * @param encs Array to store the encoder values.
172 * @return true if successful, false otherwise.
173 */
174 bool getMotorEncoders(double* encs) override;
175
176 /**
177 * @brief Gets the values and timestamps of all motor encoders.
178 * @param encs Array to store the encoder values.
179 * @param time Array to store the timestamps.
180 * @return true if successful, false otherwise.
181 */
182 bool getMotorEncodersTimed(double* encs, double* time) override;
183
184 /**
185 * @brief Gets the value and timestamp of a specific motor encoder.
186 * @param m Index of the motor encoder.
187 * @param encs Pointer to store the encoder value.
188 * @param time Pointer to store the timestamp.
189 * @return true if successful, false otherwise.
190 */
191 bool getMotorEncoderTimed(int m, double* encs, double* time) override;
192
193 /**
194 * @brief Gets the speed of a specific motor encoder.
195 * @param m Index of the motor encoder.
196 * @param sp Pointer to store the speed value.
197 * @return true if successful, false otherwise.
198 */
199 bool getMotorEncoderSpeed(int m, double* sp) override;
200
201 /**
202 * @brief Gets the speeds of all motor encoders.
203 * @param spds Array to store the speed values.
204 * @return true if successful, false otherwise.
205 */
206 bool getMotorEncoderSpeeds(double* spds) override;
207
208 /**
209 * @brief Gets the acceleration of a specific motor encoder.
210 * @param m Index of the motor encoder.
211 * @param acc Pointer to store the acceleration value.
212 * @return true if successful, false otherwise.
213 */
214 bool getMotorEncoderAcceleration(int m, double* acc) override;
215
216 /**
217 * @brief Gets the accelerations of all motor encoders.
218 * @param accs Array to store the acceleration values.
219 * @return true if successful, false otherwise.
220 */
221 bool getMotorEncoderAccelerations(double* accs) override;
222
223 // ---------------- IEncoderTimed --------------
224
225 /**
226 * @brief Gets the values and timestamps of all encoders.
227 * @param encs Array to store the encoder values.
228 * @param time Array to store the timestamps (in seconds).
229 * @return true if successful, false otherwise.
230 */
231 bool getEncodersTimed(double* encs, double* time) override;
232
233 /**
234 * @brief Gets the value and timestamp of a specific encoder.
235 * @param j Index of the encoder.
236 * @param encs Pointer to store the encoder value.
237 * @param time Pointer to store the timestamp (in seconds).
238 * @return true if successful, false otherwise.
239 */
240 bool getEncoderTimed(int j, double* encs, double* time) override;
241
242 /**
243 * @brief Gets the number of axes (encoders).
244 * @param ax Pointer to store the number of axes.
245 * @return true if successful, false otherwise.
246 */
247 bool getAxes(int* ax) override;
248
249 /**
250 * @brief Resets the specified encoder to zero.
251 * @param j Index of the encoder to reset.
252 * @return true if successful, false otherwise.
253 */
254 bool resetEncoder(int j) override;
255
256 /**
257 * @brief Resets all encoders to zero.
258 * @return true if successful, false otherwise.
259 */
260 bool resetEncoders() override;
261
262 /**
263 * @brief Sets the value of a specific encoder.
264 * @param j Index of the encoder.
265 * @param val Value to set.
266 * @return true if successful, false otherwise.
267 */
268 bool setEncoder(int j, double val) override;
269
270 /**
271 * @brief Sets the values of all encoders.
272 * @param vals Array of values to set for each encoder.
273 * @return true if successful, false otherwise.
274 */
275 bool setEncoders(const double* vals) override;
276
277 /**
278 * @brief Gets the value of a specific encoder.
279 * @param j Index of the encoder.
280 * @param v Pointer to store the encoder value.
281 * @return true if successful, false otherwise.
282 */
283 bool getEncoder(int j, double* v) override;
284
285 /**
286 * @brief Gets the values of all encoders.
287 * @param encs Array to store the encoder values.
288 * @return true if successful, false otherwise.
289 */
290 bool getEncoders(double* encs) override;
291
292 /**
293 * @brief Gets the speed of a specific encoder.
294 * @param j Index of the encoder.
295 * @param sp Pointer to store the speed value.
296 * @return true if successful, false otherwise.
297 */
298 bool getEncoderSpeed(int j, double* sp) override;
299
300 /**
301 * @brief Gets the speeds of all encoders.
302 * @param spds Array to store the speed values.
303 * @return true if successful, false otherwise.
304 */
305 bool getEncoderSpeeds(double* spds) override;
306
307 /**
308 * @brief Gets the acceleration of a specific encoder.
309 * @param j Index of the encoder.
310 * @param spds Pointer to store the acceleration value.
311 * @return true if successful, false otherwise.
312 */
313 bool getEncoderAcceleration(int j, double* spds) override;
314
315 /**
316 * @brief Gets the accelerations of all encoders.
317 * @param accs Array to store the acceleration values.
318 * @return true if successful, false otherwise.
319 */
320 bool getEncoderAccelerations(double* accs) override;
321
322 // ---------------- IAxisInfo ------------------
323
324 /**
325 * @brief Gets the name of a specific axis.
326 * @param axis Index of the axis.
327 * @param name Reference to a string to store the axis name.
328 * @return true if successful, false otherwise.
329 */
330 bool getAxisName(int axis, std::string& name) override;
331
332 /**
333 * @brief Gets the type of a specific axis.
334 * @param axis Index of the axis.
335 * @param type Reference to a JointTypeEnum to store the axis type.
336 * @return true if successful, false otherwise.
337 * @note For the time being, this function always returns
338 * JointTypeEnum::VOCAB_JOINTTYPE_REVOLUTE.
339 */
340 bool getJointType(int axis, yarp::dev::JointTypeEnum& type) override;
341
342 // ---------------- IControlMode ----------------
343
344 /**
345 * @brief Gets the control mode of a specific joint.
346 * @param j Index of the joint.
347 * @param mode Pointer to store the control mode.
348 * @return true if successful, false otherwise.
349 */
350 bool getControlMode(int j, int* mode) override;
351
352 /**
353 * @brief Gets the control modes of all joints.
354 * @param modes Array to store the control modes.
355 * @return true if successful, false otherwise.
356 */
357 bool getControlModes(int* modes) override;
358
359 /**
360 * @brief Gets the control modes of a subset of joints.
361 * @param n Number of joints.
362 * @param joints Array of joint indices.
363 * @param modes Array to store the control modes.
364 * @return true if successful, false otherwise.
365 */
366 bool getControlModes(const int n, const int* joints, int* modes) override;
367
368 /**
369 * @brief Sets the control mode of a specific joint.
370 * @param j Index of the joint.
371 * @param mode Control mode to set.
372 * @return true if successful, false otherwise.
373 */
374 bool setControlMode(const int j, const int mode) override;
375
376 /**
377 * @brief Sets the control modes of a subset of joints.
378 * @param n Number of joints.
379 * @param joints Array of joint indices.
380 * @param modes Array of control modes to set.
381 * @return true if successful, false otherwise.
382 */
383 bool setControlModes(const int n, const int* joints, int* modes) override;
384
385 /**
386 * @brief Sets the control modes of all joints.
387 * @param modes Array of control modes to set.
388 * @return true if successful, false otherwise.
389 */
390 bool setControlModes(int* modes) override;
391
392 // ---------------- ITorqueControl --------------
393
394 /**
395 * @brief Gets the reference torques for all joints.
396 * @param t Array to store the reference torques.
397 * @return true if successful, false otherwise.
398 */
399 bool getRefTorques(double* t) override;
400
401 /**
402 * @brief Gets the reference torque for a specific joint.
403 * @param j Index of the joint.
404 * @param t Pointer to store the reference torque.
405 * @return true if successful, false otherwise.
406 */
407 bool getRefTorque(int j, double* t) override;
408
409 /**
410 * @brief Sets the reference torques for all joints.
411 * @param t Array of reference torques to set.
412 * @return true if successful, false otherwise.
413 */
414 bool setRefTorques(const double* t) override;
415
416 /**
417 * @brief Sets the reference torques for a subset of joints.
418 * @param n_joint Number of joints.
419 * @param joints Array of joint indices.
420 * @param t Array of reference torques to set.
421 * @return true if successful, false otherwise.
422 */
423 bool setRefTorques(const int n_joint, const int* joints, const double* t) override;
424
425 /**
426 * @brief Sets the reference torque for a specific joint.
427 * @param j Index of the joint.
428 * @param t Reference torque to set.
429 * @return true if successful, false otherwise.
430 */
431 bool setRefTorque(int j, double t) override;
432
433 /**
434 * @brief Gets the measured torque for a specific joint.
435 * @param j Index of the joint.
436 * @param t Pointer to store the measured torque.
437 * @return true if successful, false otherwise.
438 */
439 bool getTorque(int j, double* t) override;
440
441 /**
442 * @brief Gets the measured torques for all joints.
443 * @param t Array to store the measured torques.
444 * @return true if successful, false otherwise.
445 */
446 bool getTorques(double* t) override;
447
448 /**
449 * @brief Gets the torque range for a specific joint.
450 * @param j Index of the joint.
451 * @param min Pointer to store the minimum torque.
452 * @param max Pointer to store the maximum torque.
453 * @return true if successful, false otherwise.
454 */
455 bool getTorqueRange(int j, double* min, double* max) override;
456
457 /**
458 * @brief Gets the torque ranges for all joints.
459 * @param min Array to store the minimum torques.
460 * @param max Array to store the maximum torques.
461 * @return true if successful, false otherwise.
462 */
463 bool getTorqueRanges(double* min, double* max) override;
464
465 // ---------------- IVelocityControl --------------
466
467 /**
468 * @brief Commands a velocity move for a specific joint.
469 *
470 * @param j Index of the joint.
471 * @param sp Desired velocity setpoint (units: deg/s or rad/s, depending on configuration).
472 * @return true if successful, false otherwise.
473 *
474 * @note This interface implements Cyclic Synchronous Velocity Mode (CSV), so the command is
475 * sent cyclically.
476 */
477 bool velocityMove(int j, double sp) override;
478
479 /**
480 * @brief Commands velocity moves for all joints.
481 *
482 * @param sp Array of desired velocity setpoints for each joint.
483 * @return true if successful, false otherwise.
484 *
485 * @note This interface implements Cyclic Synchronous Velocity Mode (CSV), so the command is
486 * sent cyclically.
487 */
488 bool velocityMove(const double* sp) override;
489
490 /**
491 * @brief Gets the reference velocity for a specific joint.
492 *
493 * @param joint Index of the joint.
494 * @param vel Pointer to store the reference velocity.
495 * @return true if successful, false otherwise.
496 */
497 bool getRefVelocity(const int joint, double* vel) override;
498
499 /**
500 * @brief Gets the reference velocities for all joints.
501 *
502 * @param vels Array to store the reference velocities.
503 * @return true if successful, false otherwise.
504 */
505 bool getRefVelocities(double* vels) override;
506
507 /**
508 * @brief Gets the reference velocity for a subset of joints.
509 *
510 * @param n_joint Number of joints.
511 * @param joints Array of joint indices.
512 * @param vels Array to store the reference velocities.
513 * @return true if successful, false otherwise.
514 */
515 bool getRefVelocities(const int n_joint, const int* joints, double* vels) override;
516
517 /**
518 * @brief (Unused in CSV mode) Sets the reference acceleration for a specific joint.
519 *
520 * @param j Index of the joint.
521 * @param acc Reference acceleration (ignored).
522 * @return Always returns false. Not used in Cyclic Synchronous Velocity Mode.
523 */
524 bool setRefAcceleration(int j, double acc) override;
525
526 /**
527 * @brief (Unused in CSV mode) Sets the reference accelerations for all joints.
528 *
529 * @param accs Array of reference accelerations (ignored).
530 * @return Always returns false. Not used in Cyclic Synchronous Velocity Mode.
531 */
532 bool setRefAccelerations(const double* accs) override;
533
534 /**
535 * @brief (Unused in CSV mode) Gets the reference acceleration for a specific joint.
536 *
537 * @param j Index of the joint.
538 * @param acc Pointer to store the reference acceleration (ignored).
539 * @return Always returns false. Not used in Cyclic Synchronous Velocity Mode.
540 */
541 bool getRefAcceleration(int j, double* acc) override;
542
543 /**
544 * @brief (Unused in CSV mode) Gets the reference accelerations for all joints.
545 *
546 * @param accs Array to store the reference accelerations (ignored).
547 * @return Always returns false. Not used in Cyclic Synchronous Velocity Mode.
548 */
549 bool getRefAccelerations(double* accs) override;
550
551 /**
552 * @brief Stops motion for a specific joint.
553 *
554 * @param j Index of the joint.
555 * @return true if successful, false otherwise.
556 *
557 * @note In CSV mode, this typically sets the velocity setpoint to zero for the specified joint.
558 */
559 bool stop(int j) override;
560
561 /**
562 * @brief Stops motion for all joints.
563 *
564 * @return true if successful, false otherwise.
565 *
566 * @note In CSV mode, this typically sets all velocity setpoints to zero.
567 */
568 bool stop() override;
569
570 /**
571 * @brief Commands velocity moves for a subset of joints.
572 *
573 * @param n_joint Number of joints.
574 * @param joints Array of joint indices.
575 * @param spds Array of desired velocity setpoints for the specified joints.
576 * @return true if successful, false otherwise.
577 *
578 * @note This interface implements Cyclic Synchronous Velocity Mode (CSV), so the command is
579 * sent cyclically.
580 */
581 bool velocityMove(const int n_joint, const int* joints, const double* spds) override;
582
583 /**
584 * @brief Sets the reference accelerations for a subset of joints.
585 *
586 * @param n_joint Number of joints.
587 * @param joints Array of joint indices.
588 * @param accs Array of reference accelerations (ignored).
589 * @note This function is not used in Cyclic Synchronous Velocity Mode (CSV).
590 * @note If the driver is switched to Profile Position Mode (PP), this function call a SDO write
591 * and set the reference acceleration (0x6083).
592 *
593 * @return True in case of success, false otherwise.
594 */
595 bool setRefAccelerations(const int n_joint, const int* joints, const double* accs) override;
596
597 /**
598 * @brief Gets the reference accelerations for a subset of joints.
599 *
600 * @param n_joint Number of joints.
601 * @param joints Array of joint indices.
602 * @param accs Array to store the reference accelerations (ignored).
603 * @note This function is not used in Cyclic Synchronous Velocity Mode (CSV).
604 * @note If the driver is switched to Profile Position Mode (PP), this function call a SDO read
605 * and get the reference acceleration (0x6083).
606 * @return True in case of success, false otherwise.
607 */
608 bool getRefAccelerations(const int n_joint, const int* joints, double* accs) override;
609
610 /**
611 * @brief Stops motion for a subset of joints.
612 *
613 * @param n_joint Number of joints.
614 * @param joints Array of joint indices.
615 * @return true if successful, false otherwise.
616 *
617 * @note In CSV mode, this typically sets the velocity setpoints to zero for the specified
618 * joints.
619 * @note If the driver is switched to Profile Position Mode (PP), this function call a SDO write
620 * and set the "Halt Position" command (0x6040, 0x0006) for each specified joint.
621 */
622 bool stop(const int n_joint, const int* joints) override;
623
624 // ---------------- IJointFault ----------------
625 /**
626 * @brief Gets the last joint fault for a specific joint.
627 * @param j Index of the joint.
628 * @param fault Reference to an integer to store the fault code.
629 * @param message Reference to a string to store the fault message.
630 * @return true if successful, false otherwise.
631 */
632 bool getLastJointFault(int j, int& fault, std::string& message) override;
633
634 // ---------------- IPositionControl --------------
635
636 /**
637 * @brief Commands an absolute position move for a specific joint using Profile Position Mode
638 * (PP).
639 *
640 * This function initiates a trapezoidal position trajectory from the current position
641 * to the specified target position. The motion profile is governed by the configured
642 * profile velocity (0x6081) and profile acceleration (0x6083).
643 *
644 * @param j Index of the joint to move (0-based).
645 * @param ref Target position in joint coordinates (degrees or radians, depending on
646 * configuration).
647 * @return true if the command was successfully sent, false otherwise.
648 *
649 * @note This function uses CiA-402 Profile Position Mode. The actual motion execution
650 * depends on the drive's state machine being in "Operation Enabled" state.
651 * @note The motion is non-blocking. Use checkMotionDone() to verify completion.
652 * @note Position units depend on the encoder configuration and gear ratios.
653 */
654 bool positionMove(int j, double ref) override;
655
656 /**
657 * @brief Commands absolute position moves for all joints simultaneously.
658 *
659 * This function initiates coordinated trapezoidal position trajectories for all joints.
660 * Each joint moves from its current position to the corresponding target position in
661 * the refs array using individual profile parameters.
662 *
663 * @param refs Array of target positions for all joints (size must equal number of axes).
664 * @return true if all commands were successfully sent, false otherwise.
665 *
666 * @note Joints move simultaneously but independently - no trajectory synchronization.
667 * @note Array size must match the number of configured axes.
668 * @note Use checkMotionDone() to verify when all motions are complete.
669 */
670 bool positionMove(const double* refs) override;
671
672 /**
673 * @brief Commands absolute position moves for a subset of joints.
674 *
675 * This function allows selective position control of specific joints while leaving
676 * others unaffected. Each specified joint moves to its target position using
677 * Profile Position Mode.
678 *
679 * @param n_joint Number of joints to move (must be > 0).
680 * @param joints Array of joint indices to move (each must be valid joint index).
681 * @param refs Array of target positions corresponding to the specified joints.
682 * @return true if all commands were successfully sent, false otherwise.
683 *
684 * @note joints and refs arrays must have the same size (n_joint elements).
685 * @note Non-specified joints remain in their current control state.
686 * @note Joint indices must be valid (0 to num_axes-1).
687 */
688 bool positionMove(const int n_joint, const int* joints, const double* refs) override;
689
690 /**
691 * @brief Commands a relative position move for a specific joint.
692 *
693 * This function moves the joint by the specified delta amount from its current
694 * position. The motion uses Profile Position Mode with a calculated target
695 * position = current_position + delta.
696 *
697 * @param j Index of the joint to move (0-based).
698 * @param delta Relative displacement in joint coordinates (degrees or radians).
699 * @return true if the command was successfully sent, false otherwise.
700 *
701 * @note The current position is read at command time to calculate the absolute target.
702 * @note Positive delta values move in the positive joint direction.
703 * @note Motion profile follows the same trapezoidal trajectory as absolute moves.
704 */
705 bool relativeMove(int j, double delta) override;
706
707 /**
708 * @brief Commands relative position moves for all joints simultaneously.
709 *
710 * This function moves all joints by their respective delta amounts from their
711 * current positions. Each joint's target is calculated as current_position + delta.
712 *
713 * @param deltas Array of relative displacements for all joints (size must equal number of
714 * axes).
715 * @return true if all commands were successfully sent, false otherwise.
716 *
717 * @note Current positions are sampled at command time for target calculation.
718 * @note All joints move simultaneously but independently.
719 * @note Zero delta values result in no motion for those joints.
720 */
721 bool relativeMove(const double* deltas) override;
722
723 /**
724 * @brief Commands relative position moves for a subset of joints.
725 *
726 * This function moves specific joints by their respective delta amounts while
727 * leaving other joints unaffected. Targets are calculated from current positions.
728 *
729 * @param n_joint Number of joints to move (must be > 0).
730 * @param joints Array of joint indices to move (each must be valid joint index).
731 * @param deltas Array of relative displacements corresponding to the specified joints.
732 * @return true if all commands were successfully sent, false otherwise.
733 *
734 * @note joints and deltas arrays must have the same size (n_joint elements).
735 * @note Current positions are read for target calculation at command time.
736 * @note Non-specified joints are not affected by this command.
737 */
738 bool relativeMove(const int n_joint, const int* joints, const double* deltas) override;
739
740 /**
741 * @brief Checks if a specific joint has completed its motion.
742 *
743 * This function queries the CiA-402 Status Word (0x6041) to determine if the
744 * joint has reached its target position. The check includes both position
745 * tolerance and velocity settling criteria.
746 *
747 * @param j Index of the joint to check (0-based).
748 * @param flag Pointer to store the motion status (true if motion complete, false if still
749 * moving).
750 * @return true if the status was successfully retrieved, false on error.
751 *
752 * @note Motion is considered complete when the drive reports "Target Reached" status.
753 * @note This includes both position accuracy and velocity settling requirements.
754 * @note The function checks the drive's internal motion status, not just position error.
755 */
756 bool checkMotionDone(int j, bool* flag) override;
757
758 /**
759 * @brief Checks if all joints have completed their motions.
760 *
761 * This function checks the motion completion status for all configured joints
762 * and returns true only when all joints have reached their targets.
763 *
764 * @param flag Pointer to store the overall motion status (true if all motions complete).
765 * @return true if the status check was successful, false on error.
766 *
767 * @note Returns true in flag only when ALL joints report "Target Reached".
768 * @note Useful for coordinated motion sequences where all axes must complete.
769 * @note Individual joint errors will cause this function to return false.
770 */
771 bool checkMotionDone(bool* flag) override;
772
773 /**
774 * @brief Checks if specific joints have completed their motions.
775 *
776 * This function checks motion completion status for a subset of joints,
777 * returning true only when all specified joints have reached their targets.
778 *
779 * @param n_joint Number of joints to check (must be > 0).
780 * @param joints Array of joint indices to check (each must be valid joint index).
781 * @param flag Pointer to store the motion status (true if all specified motions complete).
782 * @return true if the status check was successful, false on error.
783 *
784 * @note Returns true in flag only when ALL specified joints report "Target Reached".
785 * @note Non-specified joints are ignored in the completion check.
786 * @note Joint indices must be valid (0 to num_axes-1).
787 */
788 bool checkMotionDone(const int n_joint, const int* joints, bool* flag) override;
789
790 /**
791 * @brief Sets the reference speed (profile velocity) for a specific joint.
792 *
793 * This function configures the maximum velocity used during position moves
794 * by writing to CiA-402 object 0x6081 (Profile Velocity) via SDO communication.
795 * This speed affects all subsequent position moves for the joint.
796 *
797 * @param j Index of the joint (0-based).
798 * @param sp Profile velocity in joint coordinates per second (deg/s or rad/s).
799 * @return true if the parameter was successfully written, false otherwise.
800 *
801 * @note This sets the maximum velocity for trapezoidal motion profiles.
802 * @note The actual motion speed may be lower due to acceleration limits.
803 * @note Changes take effect for subsequent position commands, not current motions.
804 * @note SDO communication may introduce latency compared to PDO-based commands.
805 */
806 bool setRefSpeed(int j, double sp) override;
807
808 /**
809 * @brief Sets the reference speeds (profile velocities) for all joints.
810 *
811 * This function configures the profile velocities for all joints simultaneously
812 * by writing to each joint's 0x6081 object via SDO communication.
813 *
814 * @param spds Array of profile velocities for all joints (size must equal number of axes).
815 * @return true if all parameters were successfully written, false otherwise.
816 *
817 * @note Array size must match the number of configured axes.
818 * @note All SDO writes are performed sequentially, which may take time.
819 * @note Settings apply to subsequent position moves, not current motions.
820 * @note If any single joint fails, the entire operation may be marked as failed.
821 */
822 bool setRefSpeeds(const double* spds) override;
823
824 /**
825 * @brief Sets the reference speeds (profile velocities) for specific joints.
826 *
827 * This function allows selective configuration of profile velocities for
828 * a subset of joints while leaving others unchanged.
829 *
830 * @param n_joint Number of joints to configure (must be > 0).
831 * @param joints Array of joint indices to configure (each must be valid joint index).
832 * @param spds Array of profile velocities corresponding to the specified joints.
833 * @return true if all parameters were successfully written, false otherwise.
834 *
835 * @note joints and spds arrays must have the same size (n_joint elements).
836 * @note SDO writes are performed only for specified joints.
837 * @note Non-specified joints retain their current profile velocity settings.
838 * @note Joint indices must be valid (0 to num_axes-1).
839 */
840 bool setRefSpeeds(const int n_joint, const int* joints, const double* spds) override;
841
842 /**
843 * @brief Gets the current reference speed (profile velocity) for a specific joint.
844 *
845 * This function reads the currently configured profile velocity from
846 * CiA-402 object 0x6081 via SDO communication.
847 *
848 * @param j Index of the joint (0-based).
849 * @param ref Pointer to store the current profile velocity value.
850 * @return true if the parameter was successfully read, false otherwise.
851 *
852 * @note This reads the configured maximum velocity for position profiles.
853 * @note SDO communication may introduce latency for real-time applications.
854 * @note The returned value reflects the drive's internal configuration.
855 */
856 bool getRefSpeed(int j, double* ref) override;
857
858 /**
859 * @brief Gets the current reference speeds (profile velocities) for all joints.
860 *
861 * This function reads the configured profile velocities from all joints
862 * by querying each joint's 0x6081 object via SDO communication.
863 *
864 * @param spds Array to store the profile velocities for all joints (size must equal number of
865 * axes).
866 * @return true if all parameters were successfully read, false otherwise.
867 *
868 * @note Array size must match the number of configured axes.
869 * @note All SDO reads are performed sequentially, which may take time.
870 * @note If any single joint read fails, the entire operation may fail.
871 * @note Values reflect the drives' current internal configuration.
872 */
873 bool getRefSpeeds(double* spds) override;
874
875 /**
876 * @brief Gets the current reference speeds (profile velocities) for specific joints.
877 *
878 * This function reads the profile velocity configuration for a subset of
879 * joints, allowing selective monitoring of profile parameters.
880 *
881 * @param n_joint Number of joints to query (must be > 0).
882 * @param joints Array of joint indices to query (each must be valid joint index).
883 * @param spds Array to store the profile velocities corresponding to the specified joints.
884 * @return true if all parameters were successfully read, false otherwise.
885 *
886 * @note joints and spds arrays must have the same size (n_joint elements).
887 * @note SDO reads are performed only for specified joints.
888 * @note Joint indices must be valid (0 to num_axes-1).
889 * @note Values reflect the drives' current profile velocity settings.
890 */
891 bool getRefSpeeds(const int n_joint, const int* joints, double* spds) override;
892
893 /**
894 * @brief Gets the target position for a specific joint.
895 *
896 * This function reads the target position that was last commanded
897 * to the specified joint. The value reflects the last positionMove()
898 * or relativeMove() command issued.
899 *
900 * @param j Index of the joint (0-based).
901 * @param ref Pointer to store the target position value.
902 * @return true if the parameter was successfully read, false otherwise.
903 *
904 * @note The target position is in joint coordinates (degrees or radians).
905 * @note If no position command has been issued, the value may be undefined.
906 * @note This function does not read the actual current position.
907 */
908 bool getTargetPosition(int j, double* ref) override;
909
910 /**
911 * @brief Gets the target positions for all joints.
912 *
913 * This function reads the target positions that were last commanded
914 * to all joints. The values reflect the last positionMove() or
915 * relativeMove() commands issued.
916 *
917 * @param refs Array to store the target positions for all joints (size must equal number of
918 * axes).
919 * @return true if all parameters were successfully read, false otherwise.
920 *
921 * @note Target positions are in joint coordinates (degrees or radians).
922 * @note If no position commands have been issued, values may be undefined.
923 * @note This function does not read the actual current positions.
924 */
925 bool getTargetPositions(double* refs) override;
926
927 /**
928 * @brief Gets the target positions for specific joints.
929 *
930 * This function reads the target positions that were last commanded
931 * to a subset of joints. The values reflect the last positionMove()
932 * or relativeMove() commands issued for those joints.
933 *
934 * @param n_joint Number of joints to query (must be > 0).
935 * @param joints Array of joint indices to query (each must be valid joint index).
936 * @param refs Array to store the target positions corresponding to the specified joints.
937 * @return true if all parameters were successfully read, false otherwise.
938 *
939 * @note joints and refs arrays must have the same size (n_joint elements).
940 * @note Target positions are in joint coordinates (degrees or radians).
941 * @note If no position commands have been issued for a joint, its value may be undefined.
942 * @note This function does not read the actual current positions.
943 */
944 bool getTargetPositions(const int n_joint, const int* joints, double* refs) override;
945
946 // ---------------- IPositionDirect --------------
947
948 /**
949 * @brief Streams a single joint reference in Cyclic Synchronous Position mode.
950 *
951 * Sends an immediate target position for the selected joint using the
952 * IPositionDirect interface. The reference is expressed in joint units and is
953 * consumed on the next PDO cycle while the joint is in VOCAB_CM_POSITION_DIRECT.
954 *
955 * @param j Index of the joint to command (0-based).
956 * @param ref Absolute position target in joint coordinates.
957 * @return true if the reference was accepted, false otherwise.
958 */
959 bool setPosition(int j, double ref) override;
960
961 /**
962 * @brief Streams references for a subset of joints.
963 *
964 * Allows updating multiple joints at once while leaving others untouched. Each
965 * joint listed in @p joints receives the corresponding value in @p refs during
966 * the next EtherCAT cycle.
967 *
968 * @param n_joint Number of joints to update.
969 * @param joints Array of joint indices to command (size = n_joint).
970 * @param refs Array of absolute position targets (size = n_joint).
971 * @return true if all references were queued, false otherwise.
972 */
973 bool setPositions(const int n_joint, const int* joints, const double* refs) override;
974
975 /**
976 * @brief Streams references for every configured joint.
977 *
978 * Writes a full vector of position targets that will be consumed in the next
979 * PDO exchange. All joints must already be in position-direct control mode.
980 *
981 * @param refs Array of absolute position targets for all joints.
982 * @return true if the reference vector was queued, false otherwise.
983 */
984 bool setPositions(const double* refs) override;
985
986 /**
987 * @brief Returns the most recent position-direct command for a joint.
988 *
989 * Mirrors the last value pushed via setPosition* APIs, ignoring commands sent
990 * through IPositionControl or other interfaces.
991 *
992 * @param joint Index of the joint.
993 * @param ref Pointer to store the last position-direct reference.
994 * @return true if a cached value is available, false otherwise.
995 */
996 bool getRefPosition(const int joint, double* ref) override;
997
998 /**
999 * @brief Returns the position-direct references for all joints.
1000 *
1001 * Copies the cached values last sent with setPositions(const double*). Values
1002 * produced by other motion interfaces are intentionally ignored.
1003 *
1004 * @param refs Array to store the last position-direct references for all joints.
1005 * @return true if all cached values were retrieved, false otherwise.
1006 */
1007 bool getRefPositions(double* refs) override;
1008
1009 /**
1010 * @brief Returns the position-direct references for a subset of joints.
1011 *
1012 * Fills @p refs with the cached values previously streamed for the provided
1013 * joint indices.
1014 *
1015 * @param n_joint Number of joints to query.
1016 * @param joints Array of joint indices (size = n_joint).
1017 * @param refs Array to store the corresponding cached references.
1018 * @return true if all requested values were available, false otherwise.
1019 */
1020 bool getRefPositions(const int n_joint, const int* joints, double* refs) override;
1021
1022 // ---------------- ICurrentControl --------------
1023 /**
1024 * @brief Gets the measured current of a specific motor.
1025 *
1026 * Retrieves the instantaneous motor current as reported by the drive
1027 * (typically q‑axis current or equivalent depending on vendor).
1028 *
1029 * @param m Index of the motor (0-based).
1030 * @param curr Pointer to store the measured current (Amperes).
1031 * @return true if the value was successfully read, false otherwise.
1032 *
1033 * @note Units are Amperes (A). Sign follows the drive convention.
1034 * @note Value is measured, not the commanded reference.
1035 */
1036 bool getCurrent(int m, double* curr) override;
1037
1038 /**
1039 * @brief Gets the measured currents of all motors.
1040 *
1041 * @param currs Array to store the measured currents for all motors (A).
1042 * Size must equal the number of motors/axes.
1043 * @return true if all values were successfully read, false otherwise.
1044 */
1045 bool getCurrents(double* currs) override;
1046
1047 /**
1048 * @brief Gets the allowable current range for a specific motor.
1049 *
1050 * Returns the minimum and maximum current the drive will accept or report
1051 * for this motor.
1052 *
1053 * @param m Index of the motor (0-based).
1054 * @param min Pointer to store the minimum allowable current (A).
1055 * @param max Pointer to store the maximum allowable current (A).
1056 * @return true if the range was successfully read, false otherwise.
1057 *
1058 * @note Ranges may reflect rated/peak limits configured on the drive.
1059 */
1060 bool getCurrentRange(int m, double* min, double* max) override;
1061
1062 /**
1063 * @brief Gets the allowable current ranges for all motors.
1064 *
1065 * @param min Array to store the minimum allowable currents (A).
1066 * @param max Array to store the maximum allowable currents (A).
1067 * Arrays must have size equal to the number of motors/axes.
1068 * @return true if all ranges were successfully read, false otherwise.
1069 */
1070 bool getCurrentRanges(double* min, double* max) override;
1071
1072 /**
1073 * @brief Sets the reference currents for all motors.
1074 *
1075 * Commands current references for all motors in one call. Values outside
1076 * the allowable range may be saturated by the driver or rejected by the drive.
1077 *
1078 * @param currs Array of reference currents for all motors (A).
1079 * Size must equal the number of motors/axes.
1080 * @return true if all references were successfully applied, false otherwise.
1081 *
1082 * @note Effective only when the underlying operation mode accepts current
1083 * commands (e.g., current/torque-related modes as configured).
1084 */
1085 bool setRefCurrents(const double* currs) override;
1086
1087 /**
1088 * @brief Sets the reference current for a specific motor.
1089 *
1090 * @param m Index of the motor (0-based).
1091 * @param curr Reference current to command (A).
1092 * @return true if the reference was successfully applied, false otherwise.
1093 *
1094 * @note The command may be clamped to the motor's allowable current range.
1095 * @note Effective only when the configured mode accepts current commands.
1096 */
1097 bool setRefCurrent(int m, double curr) override;
1098
1099 /**
1100 * @brief Sets the reference currents for a subset of motors.
1101 *
1102 * Allows updating a selected set of motors while leaving others unchanged.
1103 *
1104 * @param n_motor Number of motors to command (must be > 0).
1105 * @param motors Array of motor indices to command (each must be valid index).
1106 * @param currs Array of reference currents (A) corresponding to the specified motors.
1107 * @return true if all references were successfully applied, false otherwise.
1108 *
1109 * @note motors and currs must have n_motor elements.
1110 * @note Values may be clamped to each motor's allowable range.
1111 */
1112 bool setRefCurrents(const int n_motor, const int* motors, const double* currs) override;
1113
1114 /**
1115 * @brief Gets the last commanded reference currents for all motors.
1116 *
1117 * Returns the references previously set with setRefCurrent(s). These are
1118 * the commanded values, not the measured currents.
1119 *
1120 * @param currs Array to store the reference currents for all motors (A).
1121 * Size must equal the number of motors/axes.
1122 * @return true if all values were retrieved, false otherwise.
1123 */
1124 bool getRefCurrents(double* currs) override;
1125
1126 /**
1127 * @brief Gets the last commanded reference current for a specific motor.
1128 *
1129 * Returns the reference previously set with setRefCurrent(s) for the given
1130 * motor. This is the commanded value, not the measured current.
1131 *
1132 * @param m Index of the motor (0-based).
1133 * @param curr Pointer to store the reference current (A).
1134 * @return true if the value was retrieved, false otherwise.
1135 */
1136 bool getRefCurrent(int m, double* curr) override;
1137 // ---------------- IMotor --------------
1138
1139 /**
1140 * @brief Gets the number of motors controlled by the device.
1141 *
1142 * This function retrieves the number of motors that are currently
1143 * controlled by the device.
1144 *
1145 * @param num Pointer to store the number of motors.
1146 * @return true if the parameter was successfully read, false otherwise.
1147 */
1148 bool getNumberOfMotors(int* num) override;
1149
1150 /**
1151 * @brief Gets the temperature of a specific motor.
1152 *
1153 * This function retrieves the current temperature of the specified motor.
1154 *
1155 * @param m Index of the motor (0-based).
1156 * @param val Pointer to store the temperature value.
1157 * @return true if the parameter was successfully read, false otherwise.
1158 */
1159 bool getTemperature(int m, double* val) override;
1160
1161 /**
1162 * @brief Gets the temperatures of all motors.
1163 *
1164 * This function retrieves the current temperatures of all motors.
1165 *
1166 * @param vals Array to store the temperature values (size must equal number of motors).
1167 * @return true if all parameters were successfully read, false otherwise.
1168 */
1169 bool getTemperatures(double* vals) override;
1170
1171 /**
1172 * @brief Gets the temperature limit of a specific motor.
1173 *
1174 * This function retrieves the temperature limit of the specified motor.
1175 *
1176 * @param m Index of the motor (0-based).
1177 * @param temp Pointer to store the temperature limit value.
1178 * @return true if the parameter was successfully read, false otherwise.
1179 * @note This function is not implemented so it always returns false.
1180 */
1181 bool getTemperatureLimit(int m, double* temp) override;
1182
1183 /**
1184 * @brief Sets the temperature limit of a specific motor.
1185 *
1186 * This function sets the temperature limit of the specified motor.
1187 *
1188 * @param m Index of the motor (0-based).
1189 * @param temp Temperature limit value to set.
1190 * @return true if the parameter was successfully set, false otherwise.
1191 * @note This function is not implemented so it always returns false.
1192 */
1193 bool setTemperatureLimit(int m, const double temp) override;
1194
1195 /**
1196 * @brief Gets the gearbox ratio of a specific motor.
1197 *
1198 * This function retrieves the gearbox ratio of the specified motor.
1199 *
1200 * @param m Index of the motor (0-based).
1201 * @param val Pointer to store the gearbox ratio value.
1202 * @return true if the parameter was successfully read, false otherwise.
1203 */
1204 bool getGearboxRatio(int m, double* val) override;
1205
1206 /**
1207 * @brief Sets the gearbox ratio of a specific motor.
1208 *
1209 * This function sets the gearbox ratio of the specified motor.
1210 *
1211 * @param m Index of the motor (0-based).
1212 * @param val Gearbox ratio value to set.
1213 * @return true if the parameter was successfully set, false otherwise.
1214 * @note This function is not implemented so it always returns false.
1215 */
1216 bool setGearboxRatio(int m, const double val) override;
1217
1218 // ---------------- IControlLimits --------------
1219 /**
1220 * @brief Sets the position limits for a specific axis.
1221 *
1222 * This function sets the minimum and maximum position limits for the specified axis.
1223 * The limits are enforced by the device to prevent motion beyond the defined range.
1224 *
1225 * @param axis Index of the axis (0-based).
1226 * @param min Minimum position limit (in joint units, e.g., degrees).
1227 * @param max Maximum position limit (in joint units, e.g., degrees).
1228 * @return true if the limits were successfully set, false otherwise.
1229 */
1230 bool setLimits(int axis, double min, double max) override;
1231
1232 /**
1233 * @brief Gets the position limits for a specific axis.
1234 *
1235 * This function retrieves the minimum and maximum position limits for the specified axis.
1236 *
1237 * @param axis Index of the axis (0-based).
1238 * @param min Pointer to store the minimum position limit (in joint units, e.g., degrees).
1239 * @param max Pointer to store the maximum position limit (in joint units, e.g., degrees).
1240 * @return true if the limits were successfully retrieved, false otherwise.
1241 */
1242 bool getLimits(int axis, double* min, double* max) override;
1243
1244 /**
1245 * @brief Sets the velocity limits for a specific axis.
1246 *
1247 * This function sets the minimum and maximum velocity limits for the specified axis.
1248 * The limits are enforced by the device to prevent motion beyond the defined range.
1249 *
1250 * @param axis Index of the axis (0-based).
1251 * @param min Minimum velocity limit (in joint units per second, e.g., degrees/s).
1252 * @param max Maximum velocity limit (in joint units per second, e.g., degrees/s).
1253 * @return true if the limits were successfully set, false otherwise.
1254 * @note The velocity limits is not implemented in this driver, so it always returns false.
1255 */
1256 bool setVelLimits(int axis, double min, double max) override;
1257
1258 /**
1259 * @brief Gets the velocity limits for a specific axis.
1260 *
1261 * This function retrieves the minimum and maximum velocity limits for the specified axis.
1262 *
1263 * @param axis Index of the axis (0-based).
1264 * @param min Pointer to store the minimum velocity limit (in joint units per second, e.g.,
1265 * degrees/s).
1266 * @param max Pointer to store the maximum velocity limit (in joint units per second, e.g.,
1267 * degrees/s).
1268 * @return true if the limits were successfully retrieved, false otherwise.
1269 * @note The velocity limits is not implemented in this driver, so it always returns false.
1270 */
1271 bool getVelLimits(int axis, double* min, double* max) override;
1272
1273 /**
1274 * @brief Gets the interaction mode of a specific axis.
1275 * @param axis Index of the axis (0-based).
1276 * @param mode Pointer to store the interaction mode.
1277 * @return true if the mode was successfully retrieved, false otherwise.
1278 * @note The interaction mode is not implemented in this driver, it always returns stiff.
1279 */
1280 bool getInteractionMode(int axis, yarp::dev::InteractionModeEnum* mode) override;
1281
1282 /**
1283 * @brief Gets the interaction modes of a subset of joints.
1284 * @param n_joints Number of joints.
1285 * @param joints Array of joint indices.
1286 * @param modes Array to store the interaction modes.
1287 * @return true if the modes were successfully retrieved, false otherwise.
1288 */
1289 bool
1290 getInteractionModes(int n_joints, int* joints, yarp::dev::InteractionModeEnum* modes) override;
1291
1292 /**
1293 * @brief Gets the interaction modes of all joints.
1294 * @param modes Array to store the interaction modes.
1295 * @return true if the modes were successfully retrieved, false otherwise.
1296 */
1297 bool getInteractionModes(yarp::dev::InteractionModeEnum* modes) override;
1298
1299 /**
1300 * @brief Sets the interaction mode of a specific axis.
1301 * @param axis Index of the axis (0-based).
1302 * @param mode Interaction mode to set.
1303 * @return true if the mode was successfully set, false otherwise.
1304 * @note The interaction mode is not implemented in this driver, so it always returns false.
1305 */
1306 bool setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode) override;
1307
1308 /**
1309 * @brief Sets the interaction modes of a subset of joints.
1310 * @param n_joints Number of joints.
1311 * @param joints Array of joint indices.
1312 * @param modes Array of interaction modes to set.
1313 * @return true if the modes were successfully set, false otherwise.
1314 * @note The interaction mode is not implemented in this driver, so it always returns false.
1315 */
1316 bool
1317 setInteractionModes(int n_joints, int* joints, yarp::dev::InteractionModeEnum* modes) override;
1318
1319 /**
1320 * @brief Sets the interaction modes of all joints.
1321 * @param modes Array of interaction modes to set.
1322 * @return true if the modes were successfully set, false otherwise.
1323 * @note The interaction mode is not implemented in this driver, so it always returns false.
1324 */
1325 bool setInteractionModes(yarp::dev::InteractionModeEnum* modes) override;
1326
1327private:
1328 struct Impl;
1329 std::unique_ptr<Impl> m_impl;
1330};
1331
1332} // namespace dev
1333} // namespace yarp
1334
1335#endif // YARP_DEV_CIA402_MOTION_CONTROL_H
bool setGearboxRatio(int m, const double val) override
Sets the gearbox ratio of a specific motor.
bool setRefAcceleration(int j, double acc) override
(Unused in CSV mode) Sets the reference acceleration for a specific joint.
bool getTargetPosition(int j, double *ref) override
Gets the target position for a specific joint.
bool getCurrentRange(int m, double *min, double *max) override
Gets the allowable current range for a specific motor.
bool resetMotorEncoders() override
Resets all motor encoders to zero.
bool setRefCurrent(int m, double curr) override
Sets the reference current for a specific motor.
bool setEncoder(int j, double val) override
Sets the value of a specific encoder.
bool getVelLimits(int axis, double *min, double *max) override
Gets the velocity limits for a specific axis.
void run() override
Runs the periodic thread.
bool setMotorEncoder(int m, const double val) override
Sets the value of a specific motor encoder.
bool getRefVelocity(const int joint, double *vel) override
Gets the reference velocity for a specific joint.
bool setMotorEncoders(const double *vals) override
Sets the values of all motor encoders.
bool getNumberOfMotors(int *num) override
Gets the number of motors controlled by the device.
bool getEncoderAcceleration(int j, double *spds) override
Gets the acceleration of a specific encoder.
bool getEncoderSpeed(int j, double *sp) override
Gets the speed of a specific encoder.
bool getEncoders(double *encs) override
Gets the values of all encoders.
bool getEncoderSpeeds(double *spds) override
Gets the speeds of all encoders.
bool setVelLimits(int axis, double min, double max) override
Sets the velocity limits for a specific axis.
bool positionMove(int j, double ref) override
Commands an absolute position move for a specific joint using Profile Position Mode (PP).
bool getMotorEncoder(int m, double *v) override
Gets the value of a specific motor encoder.
bool getEncoderTimed(int j, double *encs, double *time) override
Gets the value and timestamp of a specific encoder.
bool getAxisName(int axis, std::string &name) override
Gets the name of a specific axis.
bool setPosition(int j, double ref) override
Streams a single joint reference in Cyclic Synchronous Position mode.
bool relativeMove(int j, double delta) override
Commands a relative position move for a specific joint.
bool getLastJointFault(int j, int &fault, std::string &message) override
Gets the last joint fault for a specific joint.
bool getJointType(int axis, yarp::dev::JointTypeEnum &type) override
Gets the type of a specific axis.
bool getRefPosition(const int joint, double *ref) override
Returns the most recent position-direct command for a joint.
bool getMotorEncoderCountsPerRevolution(int m, double *cpr) override
Gets the counts per revolution for a specific motor encoder.
~CiA402MotionControl() override
Destructor.
bool resetEncoders() override
Resets all encoders to zero.
bool getTargetPositions(double *refs) override
Gets the target positions for all joints.
bool setRefCurrents(const double *currs) override
Sets the reference currents for all motors.
bool getTorques(double *t) override
Gets the measured torques for all joints.
bool getRefCurrent(int m, double *curr) override
Gets the last commanded reference current for a specific motor.
CiA402MotionControl(double period, yarp::os::ShouldUseSystemClock useSystemClock=yarp::os::ShouldUseSystemClock::Yes)
Constructor.
bool getRefCurrents(double *currs) override
Gets the last commanded reference currents for all motors.
bool stop() override
Stops motion for all joints.
bool setRefTorques(const double *t) override
Sets the reference torques for all joints.
bool getControlMode(int j, int *mode) override
Gets the control mode of a specific joint.
bool getEncoderAccelerations(double *accs) override
Gets the accelerations of all encoders.
bool getRefSpeed(int j, double *ref) override
Gets the current reference speed (profile velocity) for a specific joint.
bool setLimits(int axis, double min, double max) override
Sets the position limits for a specific axis.
bool setInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Sets the interaction modes of a subset of joints.
bool setTemperatureLimit(int m, const double temp) override
Sets the temperature limit of a specific motor.
bool getTorque(int j, double *t) override
Gets the measured torque for a specific joint.
bool getRefPositions(double *refs) override
Returns the position-direct references for all joints.
bool getLimits(int axis, double *min, double *max) override
Gets the position limits for a specific axis.
bool velocityMove(int j, double sp) override
Commands a velocity move for a specific joint.
bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets the counts per revolution for a specific motor encoder.
bool getRefVelocities(double *vels) override
Gets the reference velocities for all joints.
bool getEncodersTimed(double *encs, double *time) override
Gets the values and timestamps of all encoders.
bool getTorqueRanges(double *min, double *max) override
Gets the torque ranges for all joints.
bool getControlModes(int *modes) override
Gets the control modes of all joints.
bool resetEncoder(int j) override
Resets the specified encoder to zero.
bool setControlModes(const int n, const int *joints, int *modes) override
Sets the control modes of a subset of joints.
bool getMotorEncoderSpeed(int m, double *sp) override
Gets the speed of a specific motor encoder.
bool getMotorEncoders(double *encs) override
Gets the values of all motor encoders.
bool setPositions(const int n_joint, const int *joints, const double *refs) override
Streams references for a subset of joints.
bool setRefSpeed(int j, double sp) override
Sets the reference speed (profile velocity) for a specific joint.
bool getMotorEncoderAcceleration(int m, double *acc) override
Gets the acceleration of a specific motor encoder.
bool getEncoder(int j, double *v) override
Gets the value of a specific encoder.
bool getMotorEncoderTimed(int m, double *encs, double *time) override
Gets the value and timestamp of a specific motor encoder.
bool getCurrentRanges(double *min, double *max) override
Gets the allowable current ranges for all motors.
bool setControlMode(const int j, const int mode) override
Sets the control mode of a specific joint.
bool getTemperatureLimit(int m, double *temp) override
Gets the temperature limit of a specific motor.
bool getInteractionMode(int axis, yarp::dev::InteractionModeEnum *mode) override
Gets the interaction mode of a specific axis.
bool getRefAcceleration(int j, double *acc) override
(Unused in CSV mode) Gets the reference acceleration for a specific joint.
bool getCurrents(double *currs) override
Gets the measured currents of all motors.
bool checkMotionDone(int j, bool *flag) override
Checks if a specific joint has completed its motion.
bool getGearboxRatio(int m, double *val) override
Gets the gearbox ratio of a specific motor.
bool open(yarp::os::Searchable &config) override
Opens the device driver.
bool getTemperature(int m, double *val) override
Gets the temperature of a specific motor.
bool setRefSpeeds(const double *spds) override
Sets the reference speeds (profile velocities) for all joints.
bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Gets the interaction modes of a subset of joints.
bool setRefAccelerations(const double *accs) override
(Unused in CSV mode) Sets the reference accelerations for all joints.
bool getMotorEncodersTimed(double *encs, double *time) override
Gets the values and timestamps of all motor encoders.
bool getMotorEncoderAccelerations(double *accs) override
Gets the accelerations of all motor encoders.
bool getRefTorque(int j, double *t) override
Gets the reference torque for a specific joint.
bool setEncoders(const double *vals) override
Sets the values of all encoders.
bool close() override
Closes the device driver.
bool getNumberOfMotorEncoders(int *num) override
Gets the number of motor encoders.
bool getCurrent(int m, double *curr) override
Gets the measured current of a specific motor.
bool getAxes(int *ax) override
Gets the number of axes (encoders).
bool setRefTorque(int j, double t) override
Sets the reference torque for a specific joint.
bool getTemperatures(double *vals) override
Gets the temperatures of all motors.
bool getMotorEncoderSpeeds(double *spds) override
Gets the speeds of all motor encoders.
bool resetMotorEncoder(int m) override
Resets the specified motor encoder to zero.
bool getRefTorques(double *t) override
Gets the reference torques for all joints.
bool setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode) override
Sets the interaction mode of a specific axis.
bool getTorqueRange(int j, double *min, double *max) override
Gets the torque range for a specific joint.
bool getRefAccelerations(double *accs) override
(Unused in CSV mode) Gets the reference accelerations for all joints.
bool getRefSpeeds(double *spds) override
Gets the current reference speeds (profile velocities) for all joints.