25#define NEW_JSTATUS_STRUCT 1
26#define VELOCITY_WATCHDOG 0.1
27#define OPENLOOP_WATCHDOG 0.1
28#define PWM_CONSTANT 0.1
36 std::lock_guard lock(_mutex);
40 for (
int i=0;i <_njoints ;i++)
45 if (this->_command_speeds[i]!=0)
55 this->_command_speeds[i]=0.0;
61 if (this->refpwm[i]!=0)
76 pos[i] = _posDir_references[i];
80 pos[i] = _posCtrl_references[i];
137 std::ostringstream oss;
178 nominalCurrent.
resize(_njoints);
179 maxCurrent.
resize(_njoints);
180 peakCurrent.
resize(_njoints);
183 pwmLimit.
resize(_njoints);
184 supplyVoltage.
resize(_njoints);
185 last_velocity_command.
resize(_njoints);
186 last_pwm_command.
resize(_njoints);
197 nominalCurrent.
zero();
204 supplyVoltage.
zero();
260 _axisName =
new std::string[nj];
303bool FakeMotionControl::dealloc()
420 _angleToEncoder(nullptr),
421 _encodersStamp (nullptr),
422 _ampsToSensor (nullptr),
423 _dutycycleToPWM(nullptr),
424 _DEPRECATED_encoderconversionfactor (nullptr),
425 _DEPRECATED_encoderconversionoffset (nullptr),
426 _jointEncoderRes (nullptr),
427 _rotorEncoderRes (nullptr),
429 _hasHallSensor (nullptr),
430 _hasTempSensor (nullptr),
431 _hasRotorEncoder (nullptr),
432 _hasRotorEncoderIndex (nullptr),
433 _rotorIndexOffset (nullptr),
434 _motorPoles (nullptr),
435 _rotorlimits_max (nullptr),
436 _rotorlimits_min (nullptr),
441 _ppids_ena (nullptr),
442 _tpids_ena (nullptr),
443 _cpids_ena (nullptr),
444 _vpids_ena (nullptr),
445 _ppids_lim (nullptr),
446 _tpids_lim (nullptr),
447 _cpids_lim (nullptr),
448 _vpids_lim (nullptr),
449 _ppids_ref (nullptr),
450 _tpids_ref (nullptr),
451 _cpids_ref (nullptr),
452 _vpids_ref (nullptr),
454 _jointType (nullptr),
455 _limitsMin (nullptr),
456 _limitsMax (nullptr),
457 _kinematic_mj (nullptr),
458 _maxJntCmdVelocity (nullptr),
459 _maxMotorVelocity (nullptr),
460 _velocityShifts (nullptr),
461 _velocityTimeout (nullptr),
464 _kbemf_scale (nullptr),
465 _ktau_scale (nullptr),
466 _viscousPos (nullptr),
467 _viscousNeg (nullptr),
468 _coulombPos (nullptr),
469 _coulombNeg (nullptr),
470 _velocityThres (nullptr),
471 _filterType (nullptr),
472 _torqueSensorId (nullptr),
473 _torqueSensorChan (nullptr),
474 _maxTorque (nullptr),
475 _newtonsToSensor (nullptr),
476 checking_motiondone (nullptr),
477 _last_position_move_time(nullptr),
478 _motorPwmLimits (nullptr),
480 useRawEncoderData (
false),
481 _pwmIsLimited (
false),
482 _torqueControlEnabled (
false),
483 _torqueControlUnits (T_MACHINE_UNITS),
484 _positionControlUnits (P_MACHINE_UNITS),
487 verbose (VERY_VERBOSE)
491 verbosewhenok = (
tmp !=
"") ? (
bool)yarp::conf::numeric::from_string<int>(
tmp) :
509 for(
int i=0; i<_njoints; i++)
512 pwmLimit[i] = (33+i)*10;
513 current[i] = (33+i)*100;
514 maxCurrent[i] = (33+i)*1000;
515 peakCurrent[i] = (33+i)*2;
516 nominalCurrent[i] = (33+i)*20;
517 supplyVoltage[i] = (33+i)*200;
518 last_velocity_command[i] = -1;
519 last_pwm_command[i] = -1;
521 _maxJntCmdVelocity[i]=50.0;
549 for (
int i = 0; i < _njoints; i++) {
550 _newtonsToSensor[i] = 1;
564 for (
size_t i = 0; i < _njoints; i++) {
bemfToRaw [i] = _newtonsToSensor[i] / _angleToEncoder[i];}
565 for (
size_t i = 0; i < _njoints; i++) {
ktauToRaw[i] = _dutycycleToPWM[i] / _newtonsToSensor[i]; }
566 ControlBoardHelper cb(_njoints, _axisMap, _angleToEncoder,
nullptr, _newtonsToSensor, _ampsToSensor, _dutycycleToPWM);
593 bool init = this->
start();
624 for (i = 0; i < _njoints; i++) {
628 for (i = 0; i < _njoints; i++) {
yDebug() <<
"_axisMap: " << _axisMap[i] <<
" "; }
639 for (i = 0; i < _njoints; i++) {
640 _axisName[_axisMap[i]] =
"joint" +
toString(i);
643 for (i = 0; i < _njoints; i++) {
yDebug() <<
"_axisName: " << _axisName[_axisMap[i]] <<
" "; }
668 for (i = 0; i < _njoints; i++) {
683 for (i = 0; i < _njoints; i++) {
684 _ampsToSensor[i] = 1;
699 for (i = 0; i < _njoints; i++) {
700 _dutycycleToPWM[i] = 1;
714 for (i = 0; i < _njoints; i++) {
715 _angleToEncoder[i] = 1; }
728 for (i = 0; i < _njoints; i++) {
742 for (i = 0; i < _njoints; i++) {
753 std::lock_guard lock(_mutex);
783void FakeMotionControl::cleanup()
818 for(
int j=0; j< _njoints; j++)
850 for(
int j=0, index=0; j< _njoints; j++, index++)
882 for(
int j=0, index=0; j< _njoints; j++, index++)
914 for(
int j=0; j< _njoints; j++)
950 for(
int j=0, index=0; j<_njoints; j++, index++)
985 for(
int j=0; j< _njoints; j++)
997 *
limit=_ppids_lim[j];
1000 *
limit=_vpids_lim[j];
1003 *
limit=_cpids_lim[j];
1006 *
limit=_tpids_lim[j];
1017 for(
int j=0, index=0; j<_njoints; j++, index++)
1034 _ppids_ena[j]=
false;
1037 _vpids_ena[j]=
false;
1040 _cpids_ena[j]=
false;
1043 _tpids_ena[j]=
false;
1101 *enabled=_ppids_ena[j];
1104 *enabled=_vpids_ena[j];
1107 *enabled=_cpids_ena[j];
1110 *enabled=_tpids_ena[j];
1144 for(
int j=0; j< _njoints; j++)
1164 yCError(
FAKEMOTIONCONTROL) <<
"velocityMoveRaw: skipping command because board " <<
" joint " << j <<
" is not in VOCAB_CM_VELOCITY mode";
1166 _command_speeds[j] =
sp;
1175 for (
int i = 0; i < _njoints; i++) {
1216 if (verbose >= VERY_VERBOSE) {
1233 yCError(
FAKEMOTIONCONTROL) <<
"positionMoveRaw: skipping command because joint " << j <<
" is not in VOCAB_CM_POSITION mode";
1235 _posCtrl_references[j] = ref;
1241 if (verbose >= VERY_VERBOSE) {
1246 for(
int j=0, index=0; j< _njoints; j++, index++)
1255 if (verbose >= VERY_VERBOSE) {
1271 yCError(
FAKEMOTIONCONTROL) <<
"relativeMoveRaw: skipping command because joint " << j <<
" is not in VOCAB_CM_POSITION mode";
1273 _posCtrl_references[j] +=
delta;
1279 if (verbose >= VERY_VERBOSE) {
1284 for(
int j=0, index=0; j< _njoints; j++, index++)
1294 if (verbose >= VERY_VERBOSE) {
1304 if (verbose >= VERY_VERBOSE) {
1311 for(
int j=0, index=0; j< _njoints; j++, index++)
1325 _ref_speeds[index] =
sp;
1333 for(
int j=0, index=0; j< _njoints; j++, index++)
1335 _ref_speeds[index] =
spds[index];
1347 _ref_accs[j ] = 1
e6;
1349 else if (acc < -1
e6)
1351 _ref_accs[j ] = -1
e6;
1355 _ref_accs[j ] = acc;
1365 for(
int j=0, index=0; j< _njoints; j++, index++)
1369 _ref_accs[index] = 1
e6;
1373 _ref_accs[index] = -1
e6;
1377 _ref_accs[index] =
accs[j];
1385 *
spd = _ref_speeds[j];
1391 memcpy(
spds, _ref_speeds,
sizeof(
double) * _njoints);
1397 *acc = _ref_accs[j];
1403 memcpy(
accs, _ref_accs,
sizeof(
double) * _njoints);
1416 for(
int j=0; j< _njoints; j++)
1430 if (verbose >= VERY_VERBOSE) {
1449 if (verbose >= VERY_VERBOSE) {
1463 if (verbose >= VERY_VERBOSE) {
1482 if (verbose >= VERY_VERBOSE) {
1496 if (verbose >= VERY_VERBOSE) {
1510 if (verbose >= VERY_VERBOSE) {
1524 if (verbose >= VERY_VERBOSE) {
1538 if (verbose >= VERY_VERBOSE) {
1557 if (verbose > VERY_VERY_VERBOSE) {
1561 *v = _controlModes[j];
1569 for(
int j=0; j< _njoints; j++)
1588 if (verbose >= VERY_VERBOSE) {
1598 _controlModes[j] =
_mode;
1600 _posCtrl_references[j] = pos[j];
1607 if (verbose >= VERY_VERBOSE) {
1621 if (verbose >= VERY_VERBOSE) {
1626 for(
int i=0; i<_njoints; i++)
1670 for(
int j=0; j< _njoints; j++)
1689 for(
int j=0; j< _njoints; j++)
1707 for(
int j=0; j< _njoints; j++)
1720 for (
int i = 0; i < _njoints; i++) {
1721 stamps[i] = _encodersStamp[i] = _cycleTimestamp;
1731 *stamp = _encodersStamp[j] = _cycleTimestamp;
1784 for(
int j=0; j< _njoints; j++)
1801 for(
int j=0; j< _njoints; j++)
1817 for(
int j=0; j< _njoints; j++)
1828 for (
int i = 0; i < _njoints; i++) {
1829 stamps[i] = _encodersStamp[i] = _cycleTimestamp;
1840 *stamp = _encodersStamp[
m] = _cycleTimestamp;
1862 *value = current[j];
1870 for(
int j=0; j< _njoints; j++)
1879 maxCurrent[
m] = val;
1885 *val = maxCurrent[
m];
1891 (_enabledAmp[j ]) ? *
st = 1 : *
st = 0;
1898 for(
int j=0; j<_njoints; j++)
1900 sts[j] = _enabledAmp[j];
1907 *val = peakCurrent[
m];
1913 peakCurrent[
m] = val;
1919 *val = nominalCurrent[
m];
1925 nominalCurrent[
m] = val;
1949 *val = supplyVoltage[
m];
1963 *min = _limitsMin[j];
1964 *max = _limitsMax[j];
2042 name = _axisName[
axis];
2056 type = _jointType[
axis];
2074 *max = _maxJntCmdVelocity[
axis];
2088 for (
int i = 0; i < _njoints; i++)
2105 for (
int j = 0; j < _njoints &&
ret; j++) {
2114 for (
int j = 0; j < _njoints &&
ret; j++) {
2125 if (t>1.0 || t< -1.0)
2128 _hwfault_code[j] = 1;
2129 _hwfault_message[j] =
"test" + std::to_string(j) +
" torque";
2144 for (
int j = 0; j < _njoints &&
ret; j++) {
2153 *t = _ref_torques[j];
2161 *stiffness = _stiffness[j];
2162 *damping = _damping[j];
2170 _stiffness[j] = stiffness;
2171 _damping[j] = damping;
2179 _force_offset[j] = offset;
2187 *offset = _force_offset[j];
2203 params->
bemf = _kbemf[j];
2205 params->
ktau = _ktau[j];
2226 _kbemf[j] = params.
bemf;
2227 _ktau[j] = params.
ktau;
2261 _posDir_references[j] = ref;
2276 for(
int i=0; i< _njoints; i++)
2278 _posDir_references[i] =
refs[i];
2286 if (verbose >= VERY_VERBOSE) {
2297 "this call is for reference only and may not reflect the actual behaviour of the motor/firmware.";
2299 *ref = _posCtrl_references[
axis];
2306 for (
int i = 0; i < _njoints; i++) {
2315 for (
int i = 0; i<nj; i++)
2324 *ref = _command_speeds[
axis];
2331 for (
int i = 0; i<_njoints; i++)
2341 for (
int i = 0; i<nj; i++)
2358 this call is for reference only and may not reflect the actual behaviour of the motor/firmware.";
2361 *ref = _posDir_references[
axis];
2369 for (
int i = 0; i<_njoints; i++)
2379 for (
int i = 0; i<nj; i++)
2390 if (verbose > VERY_VERY_VERBOSE) {
2400 for(
int j=0; j< n_joints; j++)
2411 for (
int j = 0; j < _njoints; j++) {
2422 if (verbose >= VERY_VERBOSE) {
2426 _interactMode[j] =
_mode;
2435 for(
int i=0; i<n_joints; i++)
2445 for(
int i=0; i<_njoints; i++)
2468 for(
int j=0; j< _njoints; j++)
2496 for (
int i = 0; i < _njoints; i++)
2511 for (
int i = 0; i < _njoints; i++)
2526 for (
int i = 0; i < _njoints; i++)
2556 for (
int i = 0; i < _njoints; i++)
2566 for (
int i = 0; i < _njoints; i++)
2568 _ref_currents[i] = t[i];
2569 current[i] = t[i] / 2;
2576 _ref_currents[j] = t;
2584 for (
int j = 0; j<
n_joint; j++)
2593 for (
int i = 0; i < _njoints; i++)
2595 t[i] = _ref_currents[i];
2602 *t = _ref_currents[j];
2618 for (
int i = 0; i < _njoints; i++)
2634 fault = _hwfault_code[j];
2635 message = _hwfault_message[j];
2648 _braked[j] = active;
2654 _autobraked[j] = enabled;
2660 enabled = _autobraked[j];
2675 return ReturnValue::return_code::return_value_error_method_failed;
2677 if (vel < -_maxJntCmdVelocity[
jnt] || vel > _maxJntCmdVelocity[
jnt]) {
2679 return ReturnValue::return_code::return_value_error_method_failed;
2682 _dir_vel_commands[
jnt] = vel;
2691 for (
int i = 0; i < _njoints; i++) {
2702 return ReturnValue::return_code::return_value_error_method_failed;
2705 for (
int i = 0; i < _njoints; i++) {
2716 return ReturnValue::return_code::return_value_error_method_failed;
2719 vel = _dir_vel_commands[
jnt];
2728 vels.resize(_njoints);
2729 for (
int i = 0; i < _njoints; i++) {
2740 return ReturnValue::return_code::return_value_error_method_failed;
2743 vels.resize(_njoints);
2744 for (
int i = 0; i < _njoints; i++) {
void checkAndDestroy(T *&p)
bool NOT_YET_IMPLEMENTED(const char *txt)
#define OPENLOOP_WATCHDOG
std::string toString(const T &value)
convert an arbitrary type to string.
static bool NOT_YET_IMPLEMENTED(const char *txt)
static bool DEPRECATED(const char *txt)
#define VELOCITY_WATCHDOG
constexpr yarp::conf::vocab32_t VOCAB_CM_MIXED
constexpr yarp::conf::vocab32_t VOCAB_CM_TORQUE
constexpr yarp::conf::vocab32_t VOCAB_CM_PWM
constexpr yarp::conf::vocab32_t VOCAB_CM_HW_FAULT
constexpr yarp::conf::vocab32_t VOCAB_CM_IMPEDANCE_VEL
constexpr yarp::conf::vocab32_t VOCAB_CM_VELOCITY_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_CM_IDLE
constexpr yarp::conf::vocab32_t VOCAB_CM_POSITION
constexpr yarp::conf::vocab32_t VOCAB_CM_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_CM_IMPEDANCE_POS
constexpr yarp::conf::vocab32_t VOCAB_CM_POSITION_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_CM_VELOCITY
constexpr yarp::conf::vocab32_t VOCAB_CM_FORCE_IDLE
std::vector< double > m_LIMITS_Min
std::vector< std::string > m_GENERAL_AxisName
std::vector< int > m_GENERAL_Encoder
std::vector< double > m_LIMITS_Max
std::vector< std::string > m_GENERAL_AxisType
std::vector< int > m_GENERAL_AxisMap
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::vector< double > m_GENERAL_fullscalePWM
std::vector< double > m_GENERAL_ampsToSensor
bool getPowerSupplyVoltageRaw(int j, double *val) override
bool getRefSpeedRaw(int j, double *ref) override
Get reference speed for a joint.
virtual bool getHasTempSensorsRaw(int j, int &ret)
bool setRefCurrentsRaw(const double *t) override
Set the reference value of the currents for all motors.
bool setRefTorqueRaw(int j, double t) override
Set the reference value of the torque for a given joint.
bool getCurrentsRaw(double *vals) override
bool getImpedanceOffsetRaw(int j, double *offset) override
Get current force Offset for a specific joint.
bool getTargetPositionRaw(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool getTorqueRangeRaw(int j, double *min, double *max) override
Get the full scale of the torque sensor of a given joint.
bool getCurrentImpedanceLimitRaw(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
Get the current impedandance limits for a specific joint.
bool setTemperatureLimitRaw(int m, const double temp) override
Set the temperature limit for a specific motor.
bool getPidErrorRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *err) override
Get the current error for a joint.
bool setPeakCurrentRaw(int m, const double val) override
bool velocityMoveRaw(int j, double sp) override
Start motion at a given speed, single joint.
yarp::dev::ReturnValue setAutoBrakeEnabledRaw(int j, bool enabled) override
bool checkMotionDoneRaw(bool *flag) override
Check if the current trajectory is terminated.
bool getMotorEncoderSpeedRaw(int m, double *sp) override
Read the istantaneous speed of a motor encoder.
virtual bool getJointEncoderTypeRaw(int j, int &type)
bool setRefDutyCycleRaw(int j, double v) override
Sets the reference dutycycle of a single motor.
bool getTemperatureRaw(int m, double *val) override
Get temperature of a motor.
bool getEncoderAccelerationRaw(int j, double *spds) override
Read the instantaneous acceleration of an axis.
bool getRefAccelerationRaw(int j, double *acc) override
Get reference acceleration for a joint.
bool getMotorEncoderSpeedsRaw(double *spds) override
Read the instantaneous speed of all motor encoders.
bool setPidsRaw(const yarp::dev::PidControlTypeEnum &pidtype, const yarp::dev::Pid *pids) override
Set new pid value on multiple axes.
bool setVelLimitsRaw(int axis, double min, double max) override
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type) override
bool setMotorEncoderRaw(int m, const double val) override
Set the value of the motor encoder for a given motor.
bool getPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *limit) override
Get the error limit for the controller on a specific joint.
bool getPidOutputRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *out) override
Get the output of the controller (e.g.
bool setControlModeRaw(const int j, const int mode) override
bool getMotorEncoderAccelerationRaw(int m, double *spds) override
Read the instantaneous acceleration of a motor encoder.
bool open(yarp::os::Searchable &par) override
Open the DeviceDriver.
virtual bool getHasHallSensorRaw(int j, int &ret)
bool getTemperatureLimitRaw(int m, double *temp) override
Retreives the current temperature limit for a specific motor.
bool getNumberOfMotorsRaw(int *num) override
Get the number of available motors.
bool disableAmpRaw(int j) override
Disable the amplifier on a specific joint.
bool setMotorTorqueParamsRaw(int j, const yarp::dev::MotorTorqueParameters params) override
Set the motor parameters.
bool calibrateAxisWithParamsRaw(int axis, unsigned int type, double p1, double p2, double p3) override
Start calibration, this method is very often platform specific.
bool setRefAccelerationRaw(int j, double acc) override
Set reference acceleration for a joint.
virtual bool initialised()
bool setGearboxRatioRaw(int m, const double val) override
Set the gearbox ratio for a specific motor.
bool setEncodersRaw(const double *vals) override
Set the value of all encoders.
bool getPidOutputsRaw(const yarp::dev::PidControlTypeEnum &pidtype, double *outs) override
Get the output of the controllers (e.g.
bool isPidEnabledRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, bool *enabled) override
Get the current status (enabled/disabled) of the pid controller.
bool setRefSpeedsRaw(const double *spds) override
Set reference speed on all joints.
bool getTargetPositionsRaw(double *refs) override
Get the last position reference for all axes.
bool getRefDutyCycleRaw(int j, double *v) override
Gets the last reference sent using the setRefDutyCycleRaw function.
bool setMotorEncoderCountsPerRevolutionRaw(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
bool setPidErrorLimitsRaw(const yarp::dev::PidControlTypeEnum &pidtype, const double *limits) override
Get the error limit for the controller on all joints.
bool getPidReferenceRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *ref) override
Get the current reference of the pid controller for a specific joint.
bool getNominalCurrentRaw(int m, double *val) override
bool getControlModeRaw(int j, int *v) override
bool calibrationDoneRaw(int j) override
Check if the calibration is terminated, on a particular joint.
bool threadInit() override
Initialization method.
bool getRefDutyCyclesRaw(double *v) override
Gets the last reference sent using the setRefDutyCyclesRaw function.
bool getRefVelocityRaw(const int joint, double *ref) override
Get the last reference speed set by velocityMove for single joint.
bool getEncoderTimedRaw(int j, double *encs, double *stamp) override
Read the instantaneous acceleration of all axes.
bool disablePidRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Disable the pid computation for a joint.
yarp::dev::VAS_status getVirtualAnalogSensorStatusRaw(int ch) override
Check the status of a given channel.
bool getMotorEncodersRaw(double *encs) override
Read the position of all motor encoders.
bool getTorqueRangesRaw(double *min, double *max) override
Get the full scale of the torque sensors of all joints.
bool getRefCurrentsRaw(double *t) override
Get the reference value of the currents for all motors.
bool setRefDutyCyclesRaw(const double *v) override
Sets the reference dutycycle for all motors.
bool getEncoderSpeedRaw(int j, double *sp) override
Read the instantaneous speed of an axis.
int getVirtualAnalogSensorChannelsRaw() override
Get the number of channels of the virtual sensor.
bool resetPidRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Reset the controller of a given joint, usually sets the current status of the joint as the reference ...
bool getCurrentRangesRaw(double *min, double *max) override
Get the full scale of the current measurements for all motors motor (e.g.
yarp::dev::ReturnValue getDesiredVelocityRaw(const int jnt, double &vel) override
Get the last reference velocity set by setDesiredVelocity() for a single joint.
bool getEncoderRaw(int j, double *v) override
Read the value of an encoder.
bool getPidErrorLimitsRaw(const yarp::dev::PidControlTypeEnum &pidtype, double *limits) override
Get the error limit for all controllers.
bool enableAmpRaw(int j) override
Enable the amplifier on a specific joint.
bool fromConfig(yarp::os::Searchable &config)
yarp::dev::ReturnValue setManualBrakeActiveRaw(int j, bool active) override
bool getPidsRaw(const yarp::dev::PidControlTypeEnum &pidtype, yarp::dev::Pid *pids) override
Get current pid value for a specific joint.
bool getRefPositionsRaw(double *refs) override
Get the last position reference for all axes.
bool getMotorTorqueParamsRaw(int j, yarp::dev::MotorTorqueParameters *params) override
Get the motor parameters.
bool setControlModesRaw(const int n_joint, const int *joints, int *modes) override
bool setRefSpeedRaw(int j, double sp) override
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
virtual bool getHasRotorEncoderIndexRaw(int j, int &ret)
bool updateVirtualAnalogSensorMeasureRaw(yarp::sig::Vector &measure) override
Set a vector of torque values for virtual sensor.
void resizeBuffers()
Resize previously allocated buffers.
yarp::dev::ReturnValue isJointBrakedRaw(int j, bool &braked) const override
void threadRelease() override
Release method.
bool getAmpStatusRaw(int *st) override
bool getLastJointFaultRaw(int j, int &fault, std::string &message) override
bool setImpedanceRaw(int j, double stiffness, double damping) override
Set current impedance parameters (stiffness,damping) for a specific joint.
bool setPWMLimitRaw(int j, const double val) override
bool relativeMoveRaw(int j, double delta) override
Set relative position.
virtual bool getMotorPolesRaw(int j, int &poles)
bool getPidRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, yarp::dev::Pid *pid) override
Get current pid value for a specific joint.
bool getCurrentRaw(int j, double *val) override
bool getPeakCurrentRaw(int m, double *val) override
bool getDutyCyclesRaw(double *v) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool setEncoderRaw(int j, double val) override
Set the value of the encoder for a given joint.
bool getRefPositionRaw(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool getLimitsRaw(int axis, double *min, double *max) override
Get the software limits for a particular axis.
virtual bool getRotorIndexOffsetRaw(int j, double &rotorOffset)
bool getVelLimitsRaw(int axis, double *min, double *max) override
Get the software speed limits for a particular axis.
bool setPositionsRaw(const int n_joint, const int *joints, const double *refs) override
Set new reference point for all axes.
bool setPidReferenceRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double ref) override
Set the controller reference for a given axis.
bool resetEncodersRaw() override
Reset encoders.
bool getPWMRaw(int j, double *val) override
yarp::dev::ReturnValue setDesiredVelocityRaw(int jnt, double vel) override
Set the velocity of single joint.
yarp::dev::ReturnValue getAutoBrakeEnabledRaw(int j, bool &enabled) const override
bool getAxisNameRaw(int axis, std::string &name) override
bool setCalibrationParametersRaw(int axis, const yarp::dev::CalibrationParameters ¶ms) override
Start calibration, this method is very often platform specific.
bool setPidOffsetRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double v) override
Set an offset value on the ourput of pid controller.
bool getInteractionModeRaw(int j, yarp::dev::InteractionModeEnum *_mode) override
Get the current interaction mode of the robot, values can be stiff or compliant.
bool getCurrentRangeRaw(int j, double *min, double *max) override
Get the full scale of the current measurement for a given motor (e.g.
bool stopRaw() override
Stop motion, multiple joints.
virtual bool getKinematicMJRaw(int j, double &rotres)
bool getRefSpeedsRaw(double *spds) override
Get reference speed of all joints.
bool getRefAccelerationsRaw(double *accs) override
Get reference acceleration of all joints.
virtual bool getJointEncoderResolutionRaw(int m, double &jntres)
bool getAxes(int *ax) override
Get the number of controlled axes.
bool setMaxCurrentRaw(int j, double val) override
bool alloc(int njoints)
Allocated buffers.
bool resetMotorEncodersRaw() override
Reset motor encoders.
bool setRefTorquesRaw(const double *t) override
Set the reference value of the torque for all joints.
bool getEncodersRaw(double *encs) override
Read the position of all axes.
bool setRefAccelerationsRaw(const double *accs) override
Set reference acceleration on all joints.
bool getControlModesRaw(int *v) override
bool setPidRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, const yarp::dev::Pid &pid) override
Set new pid value for a joint axis.
bool getPWMLimitRaw(int j, double *val) override
virtual bool getRotorEncoderTypeRaw(int j, int &type)
bool getRefCurrentRaw(int j, double *t) override
Get the reference value of the current for a single motor.
bool getDutyCycleRaw(int j, double *v) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool setPidErrorLimitRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j, double limit) override
Set the error limit for the controller on a specific joint.
bool getInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool positionMoveRaw(int j, double ref) override
Set new reference point for a single axis.
bool getMotorEncoderCountsPerRevolutionRaw(int m, double *v) override
Gets number of counts per revolution for motor encoder m.
bool setImpedanceOffsetRaw(int j, double offset) override
Set current force Offset for a specific joint.
bool setMotorEncodersRaw(const double *vals) override
Set the value of all motor encoders.
bool getPidErrorsRaw(const yarp::dev::PidControlTypeEnum &pidtype, double *errs) override
Get the error of all joints.
bool getGearboxRatioRaw(int m, double *gearbox) override
Get the gearbox ratio for a specific motor.
bool getMaxCurrentRaw(int j, double *val) override
Returns the maximum electric current allowed for a given motor.
bool close() override
Close the DeviceDriver.
bool getRefTorquesRaw(double *t) override
Get the reference value of the torque for all joints.
bool setRefCurrentRaw(int j, double t) override
Set the reference value of the current for a single motor.
bool getNumberOfMotorEncodersRaw(int *num) override
Get the number of available motor encoders.
bool getPidReferencesRaw(const yarp::dev::PidControlTypeEnum &pidtype, double *refs) override
Get the current reference of all pid controllers.
bool getTorqueRaw(int j, double *t) override
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
bool getImpedanceRaw(int j, double *stiffness, double *damping) override
Get current impedance parameters (stiffness,damping,offset) for a specific joint.
bool enablePidRaw(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Enable the pid computation for a joint.
bool getRefVelocitiesRaw(double *refs) override
Get the last reference speed set by velocityMove for all joints.
bool setPositionRaw(int j, double ref) override
Set new position for a single axis.
bool getEncoderAccelerationsRaw(double *accs) override
Read the instantaneous acceleration of all axes.
bool setPidReferencesRaw(const yarp::dev::PidControlTypeEnum &pidtype, const double *refs) override
Set the controller reference, multiple axes.
bool getMotorEncoderRaw(int m, double *v) override
Read the value of a motor encoder.
bool getRefTorqueRaw(int j, double *t) override
Set the reference value of the torque for a given joint.
bool getMotorEncoderAccelerationsRaw(double *accs) override
Read the instantaneous acceleration of all motor encoders.
bool setInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool getTemperaturesRaw(double *vals) override
Get temperature of all the motors.
bool resetMotorEncoderRaw(int m) override
Reset motor encoder, single motor.
bool setNominalCurrentRaw(int m, const double val) override
virtual bool getRotorEncoderResolutionRaw(int m, double &rotres)
virtual bool getHasRotorEncoderRaw(int j, int &ret)
bool getMotorEncodersTimedRaw(double *encs, double *stamps) override
Read the instantaneous position of all motor encoders.
bool resetEncoderRaw(int j) override
Reset encoder, single joint.
bool getTorquesRaw(double *t) override
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
bool setLimitsRaw(int axis, double min, double max) override
Set the software limits for a particular axis, the behavior of the control card when these limits are...
bool setInteractionModeRaw(int j, yarp::dev::InteractionModeEnum _mode) override
Set the interaction mode of the robot, values can be stiff or compliant.
void run() override
Loop function.
bool getMotorEncoderTimedRaw(int m, double *encs, double *stamp) override
Read the instantaneous position of a motor encoder.
bool getEncodersTimedRaw(double *encs, double *stamps) override
Read the instantaneous acceleration of all axes.
bool getEncoderSpeedsRaw(double *spds) override
Read the instantaneous acceleration of an axis.
virtual bool getTorqueControlFilterType(int j, int &type)
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *ampereFactor=NULL, const double *voltFactor=NULL)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
class ImplementControlLimits; class StubImplControlLimitsRaw;
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool initialize(int k, const int *amap)
bool initialize(int size, const int *amap, const double *ampsToSens)
Initialize the internal data and alloc memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *nw)
Initialize the internal data and alloc memory.
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory, smaller version.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool initialize(int size, const int *amap)
Initialize the internal data and alloc memory.
bool initialize(int k, const int *amap, const double *dutyToPWM)
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *newtons, const double *amps, const double *dutys)
Initialize the internal data and alloc memory.
bool setConversionUnits(const PidControlTypeEnum &pidtype, const PidFeedbackUnitsEnum fbk_conv_units, const PidOutputUnitsEnum out_conv_units)
Default implementation of the IPositionControl interface.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
Default implementation of the IPositionDirect interface.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *nw, const double *amps, const double *dutys, const double *bemfs, const double *ktaus)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool uninitialize()
Clean up internal data and memory.
bool initialize(int size, const int *amap, const double *enc, const double *zos)
Initialize the internal data and alloc memory.
bool initialize(int k, const int *amap, const double *userToRaw)
Contains the parameters for a PID.
double offset
pwm offset added to the pid output
double kp
proportional gain
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
void resize(size_t size) override
Resize the vector.
void zero()
Zero the elements of the vector.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
For streams capable of holding different kinds of content, check what they actually have.
@ VOCAB_JOINTTYPE_REVOLUTE
@ VOCAB_JOINTTYPE_PRISMATIC
@ VOCAB_JOINTTYPE_UNKNOWN
double now()
Return the current time in seconds, relative to an arbitrary starting point.
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.