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

Introduce Advanceable Runner and SharedResource #272

Merged
merged 11 commits into from
Apr 9, 2021

Conversation

GiulioRomualdi
Copy link
Member

This is the latest block missing for #260.

Related PR: #256

@GiulioRomualdi GiulioRomualdi added the enhancement New feature or request label Apr 6, 2021
@GiulioRomualdi GiulioRomualdi self-assigned this Apr 6, 2021
@GiulioRomualdi GiulioRomualdi changed the title Introduce Advanceable Runner Introduce Advanceable Runner and SharedResource Apr 6, 2021
@GiulioRomualdi
Copy link
Member Author

Ubuntu 20.04 debug + Valgrind is failing. I think it is related to https://stackoverflow.com/questions/5610677/valgrind-memory-leak-errors-when-using-pthread-create

auto function = [&]() -> bool {
while (this->m_isRunning)
{
const auto wakeUpTime = BipedalLocomotion::clock().now() + m_dT;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI, this kind of implementation may lead to a drift in the execution (because the old wakeUpTime is not equal to BipedalLocomotion::clock().now()) that could problematic when doing data collection, see robotology/yarp#2515 . I think that @isorrentino already experienced something similar in one of her issues.

Copy link
Member Author

@GiulioRomualdi GiulioRomualdi Apr 6, 2021

Choose a reason for hiding this comment

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

Do you have any suggestions to avoid this problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

I understood the problem! This thread is not periodic if there are deadline misses, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

auto start = BipedalLocomotion::clock().now();
foo();
auto end = BipedalLocomotion::clock().now();

BipedalLocomotion::clock().sleepFor(m_dT - (end - start));

may solve the problem, right?

Copy link
Member Author

@GiulioRomualdi GiulioRomualdi Apr 6, 2021

Choose a reason for hiding this comment

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

or simply

 wakeUpTime += m_dt:

But this may lead to a problem if the clock is reset

Copy link
Member Author

@GiulioRomualdi GiulioRomualdi Apr 6, 2021

Choose a reason for hiding this comment

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

If I'm not mistaken @Giulero proposed something in gazebo yarp plugins

Copy link
Collaborator

Choose a reason for hiding this comment

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

On detecting clock reset and handling them, you can also check robotology/yarp#2494 and robotology/yarp#800 .

Copy link
Collaborator

@traversaro traversaro Apr 6, 2021

Choose a reason for hiding this comment

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

If I'm not mistaken @Giulero proposed something in gazebo yarp plugins

Sorry, I sent my reply but I did not saw yours, indeed my links are related to that.

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 @traversaro here I tried to implement what you suggested while taking into account possible time reset e91d6ad

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great, it seems ok!

Copy link
Collaborator

@traversaro traversaro left a comment

Choose a reason for hiding this comment

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

Minor comment.

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

Successfully merging this pull request may close these issues.

2 participants