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

Bugfix in YarpRobotControl::Impl::setReferences #271

Merged
merged 5 commits into from
Apr 6, 2021

Conversation

GiulioRomualdi
Copy link
Member

This fixes #270

scaling * (jointError / this->positioningDuration));
this->positionControlRefSpeeds[i]
= std::max(maxVelocityInDegPerSeconds,
scaling * (jointError / this->positioningDuration));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure of this logic, but this is not part of what is changed by the PR.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, maxVelocityInDegPerSeconds is misleading, as it is instead the minimum velocity. Each joint is supposed to reach the desired position in the time specified by positioningDuration. If the joint is already close to the desired configuration, we don't want the joint to go too slow, so we set the desired velocity to maxVelocityInDegPerSeconds, that should be called minVelocityInDegPerSeconds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you @S-Dafarra I reneame maxVelocityInDegPerSeconds into minVelocityInDegPerSeconds

@@ -304,7 +309,7 @@ struct YarpRobotControl::Impl
this->controlModes.resize(this->actuatedDOFs);
this->controlModesYarp.resize(this->actuatedDOFs);
this->axesName.resize(this->actuatedDOFs);

this->positionControlRefSpeeds.resize(this->actuatedDOFs);
Copy link
Member

Choose a reason for hiding this comment

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

I am just checking the modification, so I might be missing something, but it seems that you are resizing this vector in two different places, in two different ways. Above I see:

this->positionControlRefSpeeds.resize(
        this->desiredJointValuesAndMode.index[IRobotControl::ControlMode::Position].size());

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @S-Dafarra, both the resize are required.

Indeed when setDriver() is called the motor control mode for each joint is retrieved.

https://github.com/dic-iit/bipedal-locomotion-framework/blob/317b86fffcbcd2f263bf76785c11269df5aa3ef7/src/RobotInterface/YarpImplementation/src/YarpRobotControl.cpp#L323

Suppose that all the joints are in position when you call

https://github.com/dic-iit/bipedal-locomotion-framework/blob/317b86fffcbcd2f263bf76785c11269df5aa3ef7/src/RobotInterface/YarpImplementation/src/YarpRobotControl.cpp#L586

You will have a segfault if this resize is missing:

https://github.com/dic-iit/bipedal-locomotion-framework/blob/317b86fffcbcd2f263bf76785c11269df5aa3ef7/src/RobotInterface/YarpImplementation/src/YarpRobotControl.cpp#L312

On the other hand

https://github.com/dic-iit/bipedal-locomotion-framework/blob/317b86fffcbcd2f263bf76785c11269df5aa3ef7/src/RobotInterface/YarpImplementation/src/YarpRobotControl.cpp#L208-L209

is required when you ask for a different control mode. (Now the number of joints in position mode may be different)


By the way, I think it is more clear to change the resize as

Suggested change
this->positionControlRefSpeeds.resize(this->actuatedDOFs);
this->positionControlRefSpeeds.resize(this->desiredJointValuesAndMode.index[IRobotControl::ControlMode::Position].size());

and call it after this line.

scaling * (jointError / this->positioningDuration));
this->positionControlRefSpeeds[i]
= std::max(maxVelocityInDegPerSeconds,
scaling * (jointError / this->positioningDuration));
Copy link
Member

Choose a reason for hiding this comment

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

Actually, maxVelocityInDegPerSeconds is misleading, as it is instead the minimum velocity. Each joint is supposed to reach the desired position in the time specified by positioningDuration. If the joint is already close to the desired configuration, we don't want the joint to go too slow, so we set the desired velocity to maxVelocityInDegPerSeconds, that should be called minVelocityInDegPerSeconds.

@GiulioRomualdi GiulioRomualdi merged commit afae4ba into master Apr 6, 2021
@GiulioRomualdi GiulioRomualdi deleted the fix/YarpRobotControl branch April 6, 2021 11:18
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.

Profile the RobotInterface::YarpRobotControl::setReferences method
3 participants