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

Wrong initialization of stepTime in the ControlBoardDriver #475

Closed
nunoguedelha opened this issue Mar 30, 2020 · 3 comments · Fixed by #478
Closed

Wrong initialization of stepTime in the ControlBoardDriver #475

nunoguedelha opened this issue Mar 30, 2020 · 3 comments · Fixed by #478

Comments

@nunoguedelha
Copy link
Contributor

nunoguedelha commented Mar 30, 2020

While analyzing another issue and looking into a trace of the code executed in GazeboYarpControlBoardDriver::onUpdate, I noticed a bug in the initialization of the stepTime variable.

More precisely, the bug is in the block:

//TODO: how to properly reset the initial time?
static bool firstTime = true;
if (firstTime) {
firstTime = false;
m_previousTime = _info.simTime;
}

The first time computation should be applied to all controlboards, but is only applied to the first one (torso) because we use here a "static" variable which is static to the class method but not separately for each object.
So the computed stepTime is correct for the first updated controlboard, but wrong for the others. this issue has little or no consequence on the behavior except if we use Derivative (Kv) or Integral (Ki) gains.

I still have to check if this is true in the last commit, so I left the issue in [WIP].

CC @traversaro

@nunoguedelha
Copy link
Contributor Author

nunoguedelha commented Apr 7, 2020

I've checked, it's still the case in master and devel branches, actually the file didn't change since commit 2839964.

@nunoguedelha nunoguedelha changed the title WIP: Wrong initialization of stepTime in the ControlBoardDriver Wrong initialization of stepTime in the ControlBoardDriver Apr 7, 2020
@nunoguedelha
Copy link
Contributor Author

The fix is quite simple:
Use a flag, defined as a class property (private and non static), for initializing the simulation time to Gazebo simTime on the first call to onUpdate().

@nunoguedelha
Copy link
Contributor Author

nunoguedelha commented Apr 7, 2020

Fixed by #478.

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