Skip to content

Commit

Permalink
Merge pull request #3049 from randaz81/improved_log
Browse files Browse the repository at this point in the history
Improved tests coverage
  • Loading branch information
randaz81 authored Nov 20, 2023
2 parents b3ea632 + 877b8fe commit 0c036e9
Show file tree
Hide file tree
Showing 24 changed files with 709 additions and 68 deletions.
53 changes: 46 additions & 7 deletions src/devices/RemoteControlBoard/tests/RemoteControlBoard_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,31 @@
#include <yarp/dev/IVelocityControl.h>
#include <yarp/dev/ITorqueControl.h>
#include <yarp/dev/IControlMode.h>
#include <yarp/dev/IEncodersTimed.h>
#include <yarp/dev/IAxisInfo.h>
#include <yarp/dev/IInteractionMode.h>
#include <yarp/dev/IMotorEncoders.h>
#include <yarp/dev/IMotor.h>
#include <yarp/dev/IPidControl.h>
#include <yarp/dev/IPWMControl.h>
#include <yarp/dev/ICurrentControl.h>
#include <yarp/dev/IRemoteCalibrator.h>
#include <yarp/os/Network.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperSingle.h>
#include <yarp/dev/tests/IPositionControlTest.h>
#include <yarp/dev/tests/ITorqueControlTest.h>
#include <yarp/dev/tests/IAxisInfoTest.h>
#include <yarp/dev/tests/IEncodersTimedTest.h>
#include <yarp/dev/tests/IVelocityControlTest.h>
#include <yarp/dev/tests/IAxisInfoTest.h>
#include <yarp/dev/tests/IControlModeTest.h>
#include <yarp/dev/tests/IInteractionModeTest.h>
#include <yarp/dev/tests/ICurrentControlTest.h>
#include <yarp/dev/tests/IPWMControlTest.h>
#include <yarp/dev/tests/IPidControlTest.h>
#include <yarp/dev/tests/IMotorTest.h>
#include <yarp/dev/tests/IMotorEncodersTest.h>
#include <yarp/dev/tests/IRemoteCalibratorTest.h>

#include <catch2/catch_amalgamated.hpp>
#include <harness.h>
Expand Down Expand Up @@ -43,6 +59,13 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
IAxisInfo* iinfo = nullptr;
IEncodersTimed* ienc = nullptr;
IControlMode* icmd = nullptr;
IInteractionMode* iint = nullptr;
IMotor* imot = nullptr;
IMotorEncoders* imotenc = nullptr;
IPidControl* ipid = nullptr;
IPWMControl* ipwm = nullptr;
ICurrentControl* icurr = nullptr;
//IRemoteCalibrator* iremotecalib = nullptr;

////////"Checking opening fakeMotionControl and controlBoard_nws_yarp polydrivers"
{
Expand Down Expand Up @@ -82,17 +105,33 @@ TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
yarp::os::Time::delay(0.1);

//test
ddnwc.view(ipos); REQUIRE(ipos);
ddnwc.view(ivel); REQUIRE(ivel);
ddnwc.view(itrq); REQUIRE(itrq);
ddnwc.view(iinfo); REQUIRE(iinfo);
ddnwc.view(ienc); REQUIRE(ienc);
ddnwc.view(icmd); REQUIRE(icmd);
ddnwc.view(ipos); REQUIRE(ipos);
ddnwc.view(ivel); REQUIRE(ivel);
ddnwc.view(itrq); REQUIRE(itrq);
ddnwc.view(iinfo); REQUIRE(iinfo);
ddnwc.view(ienc); REQUIRE(ienc);
ddnwc.view(icmd); REQUIRE(icmd);
ddnwc.view(iint); REQUIRE(iint);
ddnwc.view(imot); REQUIRE(imot);
ddnwc.view(imotenc); REQUIRE(imotenc);
ddnwc.view(ipid); REQUIRE(ipid);
ddnwc.view(ipwm); REQUIRE(ipwm);
ddnwc.view(icurr); REQUIRE(icurr);
//ddnwc.view(icalib); REQUIRE(iremotecalib);

yarp::dev::tests::exec_iPositionControl_test_1(ipos,icmd);
yarp::dev::tests::exec_iVelocityControl_test_1(ivel,icmd);
yarp::dev::tests::exec_iTorqueControl_test_1(itrq,icmd);
yarp::dev::tests::exec_iAxisInfo_test_1(iinfo);
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
yarp::dev::tests::exec_iControlMode_test_1(icmd, iinfo);
yarp::dev::tests::exec_iInteractionMode_test_1(iint);
yarp::dev::tests::exec_iMotor_test_1(imot);
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
yarp::dev::tests::exec_iPidControl_test_1(ipid);
yarp::dev::tests::exec_iPwmControl_test_1(ipwm,icmd);
yarp::dev::tests::exec_iCurrentControl_test_1(icurr,icmd);
//yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);

//"Close all polydrivers and check"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,31 @@
#include <yarp/dev/IPositionControl.h>
#include <yarp/dev/IVelocityControl.h>
#include <yarp/dev/ITorqueControl.h>
#include <yarp/dev/IEncodersTimed.h>
#include <yarp/dev/IAxisInfo.h>
#include <yarp/dev/IInteractionMode.h>
#include <yarp/dev/IMotorEncoders.h>
#include <yarp/dev/IMotor.h>
#include <yarp/dev/IPidControl.h>
#include <yarp/dev/IPWMControl.h>
#include <yarp/dev/ICurrentControl.h>
#include <yarp/dev/IRemoteCalibrator.h>
#include <yarp/os/Network.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperMultiple.h>
#include <yarp/dev/tests/IPositionControlTest.h>
#include <yarp/dev/tests/IVelocityControlTest.h>
#include <yarp/dev/tests/ITorqueControlTest.h>
#include <yarp/dev/tests/IEncodersTimedTest.h>
#include <yarp/dev/tests/IAxisInfoTest.h>
#include <yarp/dev/tests/IControlModeTest.h>
#include <yarp/dev/tests/IInteractionModeTest.h>
#include <yarp/dev/tests/ICurrentControlTest.h>
#include <yarp/dev/tests/IPWMControlTest.h>
#include <yarp/dev/tests/IPidControlTest.h>
#include <yarp/dev/tests/IMotorTest.h>
#include <yarp/dev/tests/IMotorEncodersTest.h>
#include <yarp/dev/tests/IRemoteCalibratorTest.h>

#include <catch2/catch_amalgamated.hpp>
#include <harness.h>
Expand All @@ -32,11 +50,20 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]")
{
PolyDriver ddmc;
PolyDriver ddremapper;

IPositionControl* ipos = nullptr;
IVelocityControl* ivel = nullptr;
ITorqueControl* itrq = nullptr;
IAxisInfo* iinfo = nullptr;
IEncodersTimed* ienc = nullptr;
IControlMode* icmd = nullptr;
IInteractionMode* iint = nullptr;
IMotor* imot = nullptr;
IMotorEncoders* imotenc = nullptr;
IPidControl* ipid = nullptr;
IPWMControl* ipwm = nullptr;
ICurrentControl* icurr = nullptr;
//IRemoteCalibrator* iremotecalib = nullptr;

////////"Checking opening map2DServer and map2DClient polydrivers"
{
Expand All @@ -61,20 +88,33 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]")
REQUIRE(result_att);
}

ddremapper.view(ipos);
REQUIRE(ipos);
ddremapper.view(ivel);
REQUIRE(ivel);
ddremapper.view(itrq);
REQUIRE(itrq);
ddremapper.view(iinfo);
REQUIRE(iinfo);
ddremapper.view(icmd);
REQUIRE(icmd);
ddremapper.view(ipos); REQUIRE(ipos);
ddremapper.view(ivel); REQUIRE(ivel);
ddremapper.view(itrq); REQUIRE(itrq);
ddremapper.view(iinfo); REQUIRE(iinfo);
ddremapper.view(ienc); REQUIRE(ienc);
ddremapper.view(icmd); REQUIRE(icmd);
ddremapper.view(iint); REQUIRE(iint);
ddremapper.view(imot); REQUIRE(imot);
ddremapper.view(imotenc); REQUIRE(imotenc);
ddremapper.view(ipid); REQUIRE(ipid);
ddremapper.view(ipwm); REQUIRE(ipwm);
ddremapper.view(icurr); REQUIRE(icurr);
//ddremapper.view(iremotecalib); REQUIRE(iremotecalib);

yarp::dev::tests::exec_iPositionControl_test_1(ipos, icmd);
yarp::dev::tests::exec_iVelocityControl_test_1(ivel, icmd);
yarp::dev::tests::exec_iTorqueControl_test_1(itrq, icmd);
yarp::dev::tests::exec_iAxisInfo_test_1(iinfo);
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
yarp::dev::tests::exec_iControlMode_test_1(icmd, iinfo);
yarp::dev::tests::exec_iInteractionMode_test_1(iint);
yarp::dev::tests::exec_iMotor_test_1(imot);
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
yarp::dev::tests::exec_iPidControl_test_1(ipid);
yarp::dev::tests::exec_iPwmControl_test_1(ipwm, icmd);
yarp::dev::tests::exec_iCurrentControl_test_1(icurr, icmd);
//yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib);

//"Close all polydrivers and check"
{
Expand Down
66 changes: 29 additions & 37 deletions src/devices/fakeMotionControl/fakeMotionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void FakeMotionControl::run()

static inline bool NOT_YET_IMPLEMENTED(const char *txt)
{
yCError(FAKEMOTIONCONTROL) << txt << "is not yet implemented for FakeMotionControl";
yCDebug(FAKEMOTIONCONTROL) << txt << "is not yet implemented for FakeMotionControl";
return true;
}

Expand Down Expand Up @@ -1928,9 +1928,7 @@ bool FakeMotionControl::calibrateAxisWithParamsRaw(int j, unsigned int type, dou

bool FakeMotionControl::calibrationDoneRaw(int axis)
{
bool result = false;

return result;
return NOT_YET_IMPLEMENTED("calibrationDoneRaw");
}

////////////////////////////////////////
Expand Down Expand Up @@ -2316,11 +2314,6 @@ bool FakeMotionControl::getControlModesRaw(const int n_joint, const int *joints,
return ret;
}



// marco.accame: con alberto cardellino abbiamo parlato della correttezza di effettuare la verifica di quanto imposto (in setControlModeRaw() ed affini)
// andando a rileggere il valore nella scheda eth fino a che esso non sia quello atteso. si deve fare oppure no?
// con il control mode il can ora lo fa ma e' giusto? era cosi' anche in passato?
bool FakeMotionControl::setControlModeRaw(const int j, const int _mode)
{
if (verbose >= VERY_VERBOSE) {
Expand Down Expand Up @@ -2705,68 +2698,72 @@ bool FakeMotionControl::getLimitsRaw(int j, double *min, double *max)

bool FakeMotionControl::getGearboxRatioRaw(int j, double *gearbox)
{
return true;
return NOT_YET_IMPLEMENTED("getGearboxRatioRaw");
}

bool FakeMotionControl::setGearboxRatioRaw(int m, const double val)
{
return NOT_YET_IMPLEMENTED("setGearboxRatioRaw");
}

bool FakeMotionControl::getTorqueControlFilterType(int j, int& type)
{
return true;
return NOT_YET_IMPLEMENTED("getTorqueControlFilterType");
}

bool FakeMotionControl::getRotorEncoderResolutionRaw(int j, double &rotres)
{
return true;
return NOT_YET_IMPLEMENTED("getRotorEncoderResolutionRaw");
}

bool FakeMotionControl::getJointEncoderResolutionRaw(int j, double &jntres)
{
return true;
return NOT_YET_IMPLEMENTED("getJointEncoderResolutionRaw");
}

bool FakeMotionControl::getJointEncoderTypeRaw(int j, int &type)
{
return true;
return NOT_YET_IMPLEMENTED("getJointEncoderTypeRaw");
}

bool FakeMotionControl::getRotorEncoderTypeRaw(int j, int &type)
{
return true;
return NOT_YET_IMPLEMENTED("getRotorEncoderTypeRaw");
}

bool FakeMotionControl::getKinematicMJRaw(int j, double &rotres)
{
yCError(FAKEMOTIONCONTROL, "getKinematicMJRaw not yet implemented");
return false;
return NOT_YET_IMPLEMENTED("getKinematicMJRaw");
}

bool FakeMotionControl::getHasTempSensorsRaw(int j, int& ret)
{
return true;
return NOT_YET_IMPLEMENTED("getHasTempSensorsRaw");
}

bool FakeMotionControl::getHasHallSensorRaw(int j, int& ret)
{
return true;
return NOT_YET_IMPLEMENTED("getHasHallSensorRaw");
}

bool FakeMotionControl::getHasRotorEncoderRaw(int j, int& ret)
{
return true;
return NOT_YET_IMPLEMENTED("getHasRotorEncoderRaw");
}

bool FakeMotionControl::getHasRotorEncoderIndexRaw(int j, int& ret)
{
return true;
return NOT_YET_IMPLEMENTED("getHasRotorEncoderIndexRaw");
}

bool FakeMotionControl::getMotorPolesRaw(int j, int& poles)
{
return true;
return NOT_YET_IMPLEMENTED("getMotorPolesRaw");
}

bool FakeMotionControl::getRotorIndexOffsetRaw(int j, double& rotorOffset)
{
return true;
return NOT_YET_IMPLEMENTED("getRotorIndexOffsetRaw");
}

bool FakeMotionControl::getAxisNameRaw(int axis, std::string& name)
Expand Down Expand Up @@ -2863,7 +2860,7 @@ bool FakeMotionControl::setRefTorqueRaw(int j, double t)

bool FakeMotionControl::setRefTorquesRaw(const int n_joint, const int *joints, const double *t)
{
return false;
return NOT_YET_IMPLEMENTED("setRefTorquesRaw");
}

bool FakeMotionControl::getRefTorquesRaw(double *t)
Expand All @@ -2885,27 +2882,27 @@ bool FakeMotionControl::getRefTorqueRaw(int j, double *t)

bool FakeMotionControl::getImpedanceRaw(int j, double *stiffness, double *damping)
{
return false;
return NOT_YET_IMPLEMENTED("getImpedanceRaw");
}

bool FakeMotionControl::setImpedanceRaw(int j, double stiffness, double damping)
{
return false;
return NOT_YET_IMPLEMENTED("setImpedanceRaw");
}

bool FakeMotionControl::setImpedanceOffsetRaw(int j, double offset)
{
return false;
return NOT_YET_IMPLEMENTED("setImpedanceOffsetRaw");
}

bool FakeMotionControl::getImpedanceOffsetRaw(int j, double *offset)
{
return false;
return NOT_YET_IMPLEMENTED("getImpedanceOffsetRaw");
}

bool FakeMotionControl::getCurrentImpedanceLimitRaw(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)
{
return false;
return NOT_YET_IMPLEMENTED("getCurrentImpedanceLimitRaw");
}

bool FakeMotionControl::getMotorTorqueParamsRaw(int j, MotorTorqueParameters *params)
Expand Down Expand Up @@ -3168,7 +3165,7 @@ bool FakeMotionControl::getNumberOfMotorsRaw(int* num)

bool FakeMotionControl::getTemperatureRaw(int m, double* val)
{
return false;
return NOT_YET_IMPLEMENTED("getTemperatureRaw");
}

bool FakeMotionControl::getTemperaturesRaw(double *vals)
Expand All @@ -3183,12 +3180,12 @@ bool FakeMotionControl::getTemperaturesRaw(double *vals)

bool FakeMotionControl::getTemperatureLimitRaw(int m, double *temp)
{
return false;
return NOT_YET_IMPLEMENTED("getTemperatureLimitRaw");
}

bool FakeMotionControl::setTemperatureLimitRaw(int m, const double temp)
{
return false;
return NOT_YET_IMPLEMENTED("setTemperatureLimitRaw");
}

//PWM interface
Expand Down Expand Up @@ -3312,11 +3309,6 @@ bool FakeMotionControl::getRefCurrentRaw(int j, double *t)
return true;
}

// bool FakeMotionControl::checkRemoteControlModeStatus(int joint, int target_mode)
// {
// return false;
// }

yarp::dev::VAS_status FakeMotionControl::getVirtualAnalogSensorStatusRaw(int ch)
{
return yarp::dev::VAS_status::VAS_OK;
Expand Down
3 changes: 2 additions & 1 deletion src/devices/fakeMotionControl/fakeMotionControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ class FakeMotionControl :
///////////////////////// END IAxisInfo Interface

//Internal use, not exposed by YARP (yet)
bool getGearboxRatioRaw(int m, double *gearbox) override;
virtual bool getRotorEncoderResolutionRaw(int m, double &rotres);
virtual bool getJointEncoderResolutionRaw(int m, double &jntres);
virtual bool getJointEncoderTypeRaw(int j, int &type);
Expand Down Expand Up @@ -480,6 +479,8 @@ class FakeMotionControl :
bool getTemperaturesRaw(double *vals) override;
bool getTemperatureLimitRaw(int m, double *temp) override;
bool setTemperatureLimitRaw(int m, const double temp) override;
bool getGearboxRatioRaw(int m, double* gearbox) override;
bool setGearboxRatioRaw(int m, const double val) override;

// PWM interface
bool setRefDutyCycleRaw(int j, double v) override;
Expand Down
Loading

0 comments on commit 0c036e9

Please sign in to comment.