@@ -328,6 +328,7 @@ void FakeMotionControl::setInfoMPids(int j)
328
328
_torqueSensorChan= allocAndCheck<int >(nj);
329
329
_maxTorque=allocAndCheck<double >(nj);
330
330
_torques = allocAndCheck<double >(nj);
331
+ _minJntCmdVelocity = allocAndCheck<double >(nj);
331
332
_maxJntCmdVelocity = allocAndCheck<double >(nj);
332
333
_maxMotorVelocity = allocAndCheck<double >(nj);
333
334
_newtonsToSensor=allocAndCheck<double >(nj);
@@ -454,6 +455,7 @@ bool FakeMotionControl::dealloc()
454
455
checkAndDestroy (_braked);
455
456
checkAndDestroy (_autobraked);
456
457
checkAndDestroy (_maxTorque);
458
+ checkAndDestroy (_minJntCmdVelocity);
457
459
checkAndDestroy (_maxJntCmdVelocity);
458
460
checkAndDestroy (_maxMotorVelocity);
459
461
checkAndDestroy (_newtonsToSensor);
@@ -597,7 +599,6 @@ FakeMotionControl::FakeMotionControl() :
597
599
_limitsMin (nullptr ),
598
600
_limitsMax (nullptr ),
599
601
_kinematic_mj (nullptr ),
600
- _maxJntCmdVelocity (nullptr ),
601
602
_maxMotorVelocity (nullptr ),
602
603
_velocityShifts (nullptr ),
603
604
_velocityTimeout (nullptr ),
@@ -660,6 +661,7 @@ bool FakeMotionControl::threadInit()
660
661
last_velocity_command[i] = -1 ;
661
662
last_pwm_command[i] = -1 ;
662
663
_controlModes[i] = VOCAB_CM_POSITION;
664
+ _minJntCmdVelocity[i]=-50.0 ;
663
665
_maxJntCmdVelocity[i]=50.0 ;
664
666
}
665
667
prev_time = yarp::os::Time::now ();
@@ -1009,7 +1011,7 @@ ReturnValue FakeMotionControl::setPidsRaw(const PidControlTypeEnum& pidtype, con
1009
1011
return ret;
1010
1012
}
1011
1013
1012
- bool FakeMotionControl::setPidReferenceRaw (const PidControlTypeEnum& pidtype, int j, double ref)
1014
+ ReturnValue FakeMotionControl::setPidReferenceRaw (const PidControlTypeEnum& pidtype, int j, double ref)
1013
1015
{
1014
1016
size_t index = PidControlTypeEnum2Index (pidtype);
1015
1017
switch (pidtype)
@@ -1051,23 +1053,23 @@ bool FakeMotionControl::setPidReferenceRaw(const PidControlTypeEnum& pidtype, in
1051
1053
break ;
1052
1054
default :
1053
1055
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1054
- return false ;
1056
+ return ReturnValue::return_code::return_value_error_method_failed ;
1055
1057
break ;
1056
1058
}
1057
- return true ;
1059
+ return ReturnValue_ok ;
1058
1060
}
1059
1061
1060
- bool FakeMotionControl::setPidReferencesRaw (const PidControlTypeEnum& pidtype, const double *refs)
1062
+ ReturnValue FakeMotionControl::setPidReferencesRaw (const PidControlTypeEnum& pidtype, const double *refs)
1061
1063
{
1062
- bool ret = true ;
1064
+ ReturnValue ret = ReturnValue_ok ;
1063
1065
for (int j=0 , index=0 ; j< _njoints; j++, index++)
1064
1066
{
1065
1067
ret &= setPidReferenceRaw (pidtype, j, refs[index]);
1066
1068
}
1067
1069
return ret;
1068
1070
}
1069
1071
1070
- bool FakeMotionControl::setPidErrorLimitRaw (const PidControlTypeEnum& pidtype, int j, double limit)
1072
+ ReturnValue FakeMotionControl::setPidErrorLimitRaw (const PidControlTypeEnum& pidtype, int j, double limit)
1071
1073
{
1072
1074
size_t index = PidControlTypeEnum2Index (pidtype);
1073
1075
switch (pidtype)
@@ -1109,23 +1111,23 @@ bool FakeMotionControl::setPidErrorLimitRaw(const PidControlTypeEnum& pidtype, i
1109
1111
break ;
1110
1112
default :
1111
1113
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1112
- return false ;
1114
+ return ReturnValue::return_code::return_value_error_method_failed ;
1113
1115
break ;
1114
1116
}
1115
- return true ;
1117
+ return ReturnValue_ok ;
1116
1118
}
1117
1119
1118
- bool FakeMotionControl::setPidErrorLimitsRaw (const PidControlTypeEnum& pidtype, const double *limits)
1120
+ ReturnValue FakeMotionControl::setPidErrorLimitsRaw (const PidControlTypeEnum& pidtype, const double *limits)
1119
1121
{
1120
- bool ret = true ;
1122
+ ReturnValue ret = ReturnValue_ok ;
1121
1123
for (int j=0 , index=0 ; j< _njoints; j++, index++)
1122
1124
{
1123
1125
ret &= setPidErrorLimitRaw (pidtype, j, limits[index]);
1124
1126
}
1125
1127
return ret;
1126
1128
}
1127
1129
1128
- bool FakeMotionControl::getPidErrorRaw (const PidControlTypeEnum& pidtype, int j, double *err)
1130
+ ReturnValue FakeMotionControl::getPidErrorRaw (const PidControlTypeEnum& pidtype, int j, double *err)
1129
1131
{
1130
1132
switch (pidtype)
1131
1133
{
@@ -1166,15 +1168,15 @@ bool FakeMotionControl::getPidErrorRaw(const PidControlTypeEnum& pidtype, int j,
1166
1168
break ;
1167
1169
default :
1168
1170
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1169
- return false ;
1171
+ return ReturnValue::return_code::return_value_error_method_failed ;
1170
1172
break ;
1171
1173
}
1172
- return true ;
1174
+ return ReturnValue_ok ;
1173
1175
}
1174
1176
1175
- bool FakeMotionControl::getPidErrorsRaw (const PidControlTypeEnum& pidtype, double *errs)
1177
+ ReturnValue FakeMotionControl::getPidErrorsRaw (const PidControlTypeEnum& pidtype, double *errs)
1176
1178
{
1177
- bool ret = true ;
1179
+ ReturnValue ret = ReturnValue_ok ;
1178
1180
for (int j=0 ; j< _njoints; j++)
1179
1181
{
1180
1182
ret &= getPidErrorRaw (pidtype, j, &errs[j]);
@@ -1242,7 +1244,7 @@ ReturnValue FakeMotionControl::getPidsRaw(const PidControlTypeEnum& pidtype, Pid
1242
1244
return ret;
1243
1245
}
1244
1246
1245
- bool FakeMotionControl::getPidReferenceRaw (const PidControlTypeEnum& pidtype, int j, double *ref)
1247
+ ReturnValue FakeMotionControl::getPidReferenceRaw (const PidControlTypeEnum& pidtype, int j, double *ref)
1246
1248
{
1247
1249
size_t index = PidControlTypeEnum2Index (pidtype);
1248
1250
switch (pidtype)
@@ -1284,15 +1286,15 @@ bool FakeMotionControl::getPidReferenceRaw(const PidControlTypeEnum& pidtype, in
1284
1286
break ;
1285
1287
default :
1286
1288
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1287
- return false ;
1289
+ return ReturnValue::return_code::return_value_error_method_failed ;
1288
1290
break ;
1289
1291
}
1290
- return true ;
1292
+ return ReturnValue_ok ;
1291
1293
}
1292
1294
1293
- bool FakeMotionControl::getPidReferencesRaw (const PidControlTypeEnum& pidtype, double *refs)
1295
+ ReturnValue FakeMotionControl::getPidReferencesRaw (const PidControlTypeEnum& pidtype, double *refs)
1294
1296
{
1295
- bool ret = true ;
1297
+ ReturnValue ret = ReturnValue_ok ;
1296
1298
1297
1299
// just one joint at time, wait answer before getting to the next.
1298
1300
// This is because otherwise too many msg will be placed into can queue
@@ -1303,7 +1305,7 @@ bool FakeMotionControl::getPidReferencesRaw(const PidControlTypeEnum& pidtype, d
1303
1305
return ret;
1304
1306
}
1305
1307
1306
- bool FakeMotionControl::getPidErrorLimitRaw (const PidControlTypeEnum& pidtype, int j, double *limit)
1308
+ ReturnValue FakeMotionControl::getPidErrorLimitRaw (const PidControlTypeEnum& pidtype, int j, double *limit)
1307
1309
{
1308
1310
size_t index = PidControlTypeEnum2Index (pidtype);
1309
1311
switch (pidtype)
@@ -1345,15 +1347,15 @@ bool FakeMotionControl::getPidErrorLimitRaw(const PidControlTypeEnum& pidtype, i
1345
1347
break ;
1346
1348
default :
1347
1349
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1348
- return false ;
1350
+ return ReturnValue::return_code::return_value_error_method_failed ;
1349
1351
break ;
1350
1352
}
1351
- return true ;
1353
+ return ReturnValue_ok ;
1352
1354
}
1353
1355
1354
- bool FakeMotionControl::getPidErrorLimitsRaw (const PidControlTypeEnum& pidtype, double *limits)
1356
+ ReturnValue FakeMotionControl::getPidErrorLimitsRaw (const PidControlTypeEnum& pidtype, double *limits)
1355
1357
{
1356
- bool ret = true ;
1358
+ ReturnValue ret = ReturnValue_ok ;
1357
1359
for (int j=0 , index=0 ; j<_njoints; j++, index++)
1358
1360
{
1359
1361
ret &=getPidErrorLimitRaw (pidtype, j, &limits[j]);
@@ -1706,7 +1708,7 @@ ReturnValue FakeMotionControl::isPidEnabledRaw(const PidControlTypeEnum& pidtype
1706
1708
return ReturnValue_ok;
1707
1709
}
1708
1710
1709
- bool FakeMotionControl::getPidOutputRaw (const PidControlTypeEnum& pidtype, int j, double *out)
1711
+ ReturnValue FakeMotionControl::getPidOutputRaw (const PidControlTypeEnum& pidtype, int j, double *out)
1710
1712
{
1711
1713
size_t index = PidControlTypeEnum2Index (pidtype);
1712
1714
switch (pidtype)
@@ -1748,16 +1750,16 @@ bool FakeMotionControl::getPidOutputRaw(const PidControlTypeEnum& pidtype, int j
1748
1750
break ;
1749
1751
default :
1750
1752
yCError (FAKEMOTIONCONTROL) << " Invalid pid type" ;
1751
- return false ;
1753
+ return ReturnValue::return_code::return_value_error_method_failed ;
1752
1754
break ;
1753
1755
}
1754
1756
yCDebug (FAKEMOTIONCONTROL) << " getPidOutputRaw" << (yarp::conf::vocab32_t )(pidtype) << j << *out;
1755
- return true ;
1757
+ return ReturnValue_ok ;
1756
1758
}
1757
1759
1758
- bool FakeMotionControl::getPidOutputsRaw (const PidControlTypeEnum& pidtype, double *outs)
1760
+ ReturnValue FakeMotionControl::getPidOutputsRaw (const PidControlTypeEnum& pidtype, double *outs)
1759
1761
{
1760
- bool ret = true ;
1762
+ ReturnValue ret = ReturnValue_ok ;
1761
1763
for (int j=0 ; j< _njoints; j++)
1762
1764
{
1763
1765
ret &= getPidOutputRaw (pidtype, j, &outs[j]);
@@ -2569,17 +2571,18 @@ bool FakeMotionControl::getPowerSupplyVoltageRaw(int m, double* val)
2569
2571
2570
2572
2571
2573
// Limit interface
2572
- bool FakeMotionControl::setLimitsRaw (int j, double min, double max)
2574
+ ReturnValue FakeMotionControl::setPosLimitsRaw (int j, double min, double max)
2573
2575
{
2574
- bool ret = true ;
2575
- return ret;
2576
+ _limitsMin[j] = min;
2577
+ _limitsMax[j] = max;
2578
+ return ReturnValue_ok;
2576
2579
}
2577
2580
2578
- bool FakeMotionControl::getLimitsRaw (int j, double *min, double *max)
2581
+ ReturnValue FakeMotionControl::getPosLimitsRaw (int j, double *min, double *max)
2579
2582
{
2580
2583
*min = _limitsMin[j];
2581
2584
*max = _limitsMax[j];
2582
- return true ;
2585
+ return ReturnValue_ok ;
2583
2586
}
2584
2587
2585
2588
bool FakeMotionControl::getGearboxRatioRaw (int j, double *gearbox)
@@ -2680,16 +2683,18 @@ bool FakeMotionControl::getJointTypeRaw(int axis, yarp::dev::JointTypeEnum& type
2680
2683
}
2681
2684
2682
2685
// IControlLimits
2683
- bool FakeMotionControl::setVelLimitsRaw (int axis, double min, double max)
2686
+ ReturnValue FakeMotionControl::setVelLimitsRaw (int axis, double min, double max)
2684
2687
{
2685
- return NOT_YET_IMPLEMENTED (" setVelLimitsRaw" );
2688
+ _minJntCmdVelocity[axis] = min;
2689
+ _maxJntCmdVelocity[axis] = max;
2690
+ return ReturnValue_ok;
2686
2691
}
2687
2692
2688
- bool FakeMotionControl::getVelLimitsRaw (int axis, double *min, double *max)
2693
+ ReturnValue FakeMotionControl::getVelLimitsRaw (int axis, double *min, double *max)
2689
2694
{
2690
- *min = 0.0 ;
2695
+ *min = _minJntCmdVelocity[axis] ;
2691
2696
*max = _maxJntCmdVelocity[axis];
2692
- return true ;
2697
+ return ReturnValue_ok ;
2693
2698
}
2694
2699
2695
2700
0 commit comments