Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibration type 14 update on calibration value parser #885

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conf/iCubFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ checkandset_dependency(OpenCV)
checkandset_dependency(Qt5)

if(icub_firmware_shared_FOUND AND ICUB_USE_icub_firmware_shared)
if(icub_firmware_shared_VERSION VERSION_LESS 1.34.2)
message(FATAL_ERROR "An old version of icub-firmware-shared has been detected: at least 1.34.2 is required")
if(icub_firmware_shared_VERSION VERSION_LESS 1.34.3)
message(FATAL_ERROR "An old version of icub-firmware-shared has been detected: at least 1.34.3 is required")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/libraries/icubmod/embObjLib/serviceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@ bool ServiceParser::parse_encoder_port(std::string const &fromstring, eObrd_etht

if(len > 15)
{
yWarning() << "SServiceParser::parse_encoder_port():" << t << "is not a legal string for a encoder port because it is too long with size =" << len;
yWarning() << "ServiceParser::parse_encoder_port():" << t << "is not a legal string for a encoder port because it is too long with size =" << len;
formaterror = true;
return false;
}
Expand Down
34 changes: 21 additions & 13 deletions src/libraries/icubmod/embObjMotionControl/embObjMotionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,14 +2093,20 @@ bool embObjMotionControl::setCalibrationParametersRaw(int j, const CalibrationPa
calib.params.type14.pwmlimit = (int32_t)S_32(params.param1);
calib.params.type14.final_pos = (int32_t)S_32(params.param2);
calib.params.type14.invertdirection = (uint8_t)U_32(params.param3);
calib.params.type14.rotation = (int32_t)S_32(params.param4);

eoas_pos_ROT_t rotationparam;
if(!convertCalib14RotationParam(params.param4, rotationparam))
if (calib.params.type14.invertdirection != 0 && calib.params.type14.invertdirection != 1)
{
yError() << "Error in param4 of calibartion type 14 for joint " << j << "Admitted values are: 0.0, 180.0, 90.0, -90.0";
yError() << "Error in param3 of calibartion type 14 for joint " << j << "Admitted values are: 0=FALSE and 1=TRUE";
return false;
}


if(!checkCalib14RotationParam(calib.params.type14.rotation))
{
yError() << "Error in param4 of calibartion type 14 for joint " << j << "Admitted values are: 0, 32768, 16384, -16384 [0, 180, 90, -90] in iCubDegree";
return false;
}
calib.params.type14.rotation = (uint8_t)rotationparam;
calib.params.type14.offset = (int32_t)S_32(params.param5);
calib.params.type14.calibrationZero = (int32_t)S_32(_measureConverter->posA2E(params.paramZero, j));

Expand Down Expand Up @@ -2128,17 +2134,19 @@ bool embObjMotionControl::setCalibrationParametersRaw(int j, const CalibrationPa

return true;
}
bool embObjMotionControl::convertCalib14RotationParam(double calib_param4, eoas_pos_ROT_t & rotationparam)

bool embObjMotionControl::checkCalib14RotationParam(int32_t calib_param4)
{
if(calib_param4 == 0.0)
{rotationparam = eoas_pos_ROT_zero; return true;}
if(calib_param4 == 180.0)
{rotationparam = eoas_pos_ROT_plus180; return true;}
if(calib_param4 == 90.0)
{rotationparam = eoas_pos_ROT_plus090; return true;}
if(calib_param4 == -90.0)
{rotationparam = eoas_pos_ROT_minus090; return true;}
eOmc_calib14_ROT_t urotation = eomc_int2calib14_ROT(calib_param4);

if (urotation == eOmc_calib14_ROT_zero ||
urotation == eOmc_calib14_ROT_plus180 ||
urotation == eOmc_calib14_ROT_plus090 ||
urotation == eOmc_calib14_ROT_minus090)
{
return true;
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class yarp::dev::embObjMotionControl: public DeviceDriver,
bool helper_setSpdPidRaw(int j, const Pid &pid);
bool helper_getSpdPidRaw(int j, Pid *pid);
bool helper_getSpdPidsRaw(Pid *pid);

bool convertCalib14RotationParam(double calib_param4, eoas_pos_ROT_t & rotationparam);
bool checkCalib14RotationParam(int32_t calib_param4);

public:

Expand Down