4#ifndef YARP_DEV_CIA402_MOTION_CONTROL_H
5#define YARP_DEV_CIA402_MOTION_CONTROL_H
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>
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
60 yarp::os::ShouldUseSystemClock useSystemClock
61 = yarp::os::ShouldUseSystemClock::Yes);
90 bool open(yarp::os::Searchable& config)
override;
98 bool close()
override;
247 bool getAxes(
int* ax)
override;
340 bool getJointType(
int axis, yarp::dev::JointTypeEnum& type)
override;
366 bool getControlModes(
const int n,
const int* joints,
int* modes)
override;
383 bool setControlModes(
const int n,
const int* joints,
int* modes)
override;
423 bool setRefTorques(
const int n_joint,
const int* joints,
const double* t)
override;
439 bool getTorque(
int j,
double* t)
override;
515 bool getRefVelocities(
const int n_joint,
const int* joints,
double* vels)
override;
559 bool stop(
int j)
override;
568 bool stop()
override;
581 bool velocityMove(
const int n_joint,
const int* joints,
const double* spds)
override;
595 bool setRefAccelerations(
const int n_joint,
const int* joints,
const double* accs)
override;
622 bool stop(
const int n_joint,
const int* joints)
override;
688 bool positionMove(
const int n_joint,
const int* joints,
const double* refs)
override;
738 bool relativeMove(
const int n_joint,
const int* joints,
const double* deltas)
override;
788 bool checkMotionDone(
const int n_joint,
const int* joints,
bool* flag)
override;
840 bool setRefSpeeds(
const int n_joint,
const int* joints,
const double* spds)
override;
891 bool getRefSpeeds(
const int n_joint,
const int* joints,
double* spds)
override;
973 bool setPositions(
const int n_joint,
const int* joints,
const double* refs)
override;
1020 bool getRefPositions(
const int n_joint,
const int* joints,
double* refs)
override;
1036 bool getCurrent(
int m,
double* curr)
override;
1112 bool setRefCurrents(
const int n_motor,
const int* motors,
const double* currs)
override;
1230 bool setLimits(
int axis,
double min,
double max)
override;
1242 bool getLimits(
int axis,
double* min,
double* max)
override;
1256 bool setVelLimits(
int axis,
double min,
double max)
override;
1271 bool getVelLimits(
int axis,
double* min,
double* max)
override;
1290 getInteractionModes(
int n_joints,
int* joints, yarp::dev::InteractionModeEnum* modes)
override;
1317 setInteractionModes(
int n_joints,
int* joints, yarp::dev::InteractionModeEnum* modes)
override;
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.
CiA402MotionControl()
Default constructor.
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.