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

Warning message for position control PID when config not consistent #716

Merged
merged 8 commits into from
Feb 10, 2021

Conversation

AlexAntn
Copy link
Contributor

@AlexAntn AlexAntn commented Feb 3, 2021

This pull request introduces a warning message when the configuration of position control PID is not consistent across the different joints, resulting in wrong values for the PIDs (mismatching between machine_units and metric_units).

This PR addresses this issue.

@randaz81 : This implementation covers only position control, since the configuration for other types of control is slightly different. Should this be implemented for all different types of control?

@pattacini
Copy link
Member

cc @lrapetti

Copy link
Member

@pattacini pattacini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few hints.

src/libraries/icubmod/embObjMotionControl/eomcParser.cpp Outdated Show resolved Hide resolved
src/libraries/icubmod/embObjMotionControl/eomcParser.cpp Outdated Show resolved Hide resolved
@lrapetti
Copy link
Member

lrapetti commented Feb 4, 2021

Thanks @AlexAntn for taking care.

@randaz81 : This implementation covers only position control, since the configuration for other types of control is slightly different. Should this be implemented for all different types of control?

If I can give my opinion regarding this point, in general I think this needs to be implemented for all the control types. For example, my issue was opened after I experienced that problem in torque control mode.

@pattacini
Copy link
Member

pattacini commented Feb 4, 2021

If I can give my opinion regarding this point, in general I think this needs to be implemented for all the control types. For example, my issue was opened after I experienced that problem in torque control mode.

But the case of torque PID should have been already covered if I got it right (cc @AlexAntn).
Maybe because of the logic I pointed out here the warning wasn't generated.

@lrapetti
Copy link
Member

lrapetti commented Feb 4, 2021

If I can give my opinion regarding this point, in general I think this needs to be implemented for all the control types. For example, my issue was opened after I experienced that problem in torque control mode.

But the case of torque PID should have been already covered if I got it right (cc @AlexAntn).
Maybe because of the logic I pointed out here the warning wasn't generated.

Should it be a Warning or should it return an Error? I did't notice anything, but it could be possible I was missing the Warning.

@AlexAntn
Copy link
Contributor Author

AlexAntn commented Feb 4, 2021

If I can give my opinion regarding this point, in general I think this needs to be implemented for all the control types. For example, my issue was opened after I experienced that problem in torque control mode.

But the case of torque PID should have been already covered if I got it right (cc @AlexAntn).
Maybe because of the logic I pointed out here the warning wasn't generated.

Should it be a Warning or should it return an Error? I did't notice anything, but it could be possible I was missing the Warning.

The message is an error (for both torque and position control), not a warning, so my guess is it would be very visible if it showed up. As @pattacini mentioned, there is an error in the logic of the code (regarding the firstjoint), which would lead to no message being printed in any case. I will fix it and push.

@pattacini
Copy link
Member

which would lead to no message being printed in any case

In some cases, not all, but I think fixing this will make sure to deal with the correct joint number.

…d the previous error messages (for torque and position control)
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I introduced an error message for current control type

}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I introduced a similar message for speed control type

@@ -1246,8 +1310,6 @@ bool Parser::getCorrectPidForEachJoint(PidInfo *ppids/*, PidInfo *vpids*/, TrqPi
//eomc_ctrl_out_type_vel = 2,
//eomc_ctrl_out_type_cur = 3

return true;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We noticed there was this return before any of the error messages were printed, was this intentional or a small bug, @randaz81 ?

Copy link
Member

@pattacini pattacini Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch @AlexAntn!
Because of this, there was no hope to see error messages popping up.

firstjoint = i;
break;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced a break on the firstjoint loop, so now it correctly gets the first joint (instead of the last enabled one)

if(ppids[firstjoint].fbk_PidUnits != ppids[i].fbk_PidUnits ||
ppids[firstjoint].out_PidUnits != ppids[i].out_PidUnits)
{
yError() << "embObjMC BOARD " << _boardname << "all joints with POSITION enabled should have same controlunits type. Joint " << firstjoint << " differs from joint " << i;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally, added the error message for position control (not just torque). Also, made the origin of the messages more evident by putting in caps (e.g.: POSITION) the type of control that is reporting the error

Co-authored-by: Ugo Pattacini <ugo.pattacini@iit.it>
@pattacini pattacini requested a review from lrapetti February 5, 2021 10:19
@pattacini
Copy link
Member

@randaz81 @lrapetti the PR is somewhat ready for your reviews.

@randaz81
Copy link
Member

randaz81 commented Feb 9, 2021

Nice fix!
Just an additional question: at first glance it seems to me that the code of that performs the check is identical in all the three different cases (only the output string changes?). If this is the case, maybe a more compact solution to avoid code duplication (if in the future additional control blocks are added) could be to have a call to a common method that takes in input the pid and its name (string) and returns true/false to the upper level? Just an idea..

@pattacini
Copy link
Member

pattacini commented Feb 10, 2021

I think it's valuable feedback @randaz81 👍🏻
Thanks!

@pattacini pattacini linked an issue Feb 10, 2021 that may be closed by this pull request
@AlexAntn
Copy link
Contributor Author

As @randaz81 suggested, I put the print into a function that is now called (instead of having the same code spread all over).

Copy link
Member

@pattacini pattacini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

src/libraries/icubmod/embObjMotionControl/eomcParser.h Outdated Show resolved Hide resolved
src/libraries/icubmod/embObjMotionControl/eomcParser.cpp Outdated Show resolved Hide resolved
@pattacini
Copy link
Member

Thanks @AlexAntn 👍🏻
I'll merge the PR once checks are passed.

@pattacini pattacini merged commit 122e11a into robotology:master Feb 10, 2021
@lrapetti
Copy link
Member

Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

embObjMotionControl: issue in CONTROL configuration parsing
4 participants