jrl-umi3218 / mc_rtc

mc_rtc is an interface for simulated and real robotic systems suitable for real-time control
BSD 2-Clause "Simplified" License
122 stars 37 forks source link

[bugfix/FSM] Fix missed iteration at the start of Meta states #257

Closed arntanguy closed 2 years ago

arntanguy commented 2 years ago

Working with @wyqsnddd on a complex demo involving some (very) fast trajectories, I noticed a discontinuity issue when using the Meta state. Namely the creation of the Meta state's first state in the transition map is delayed by one iteration.

That is because the state's creation (and thus the call to start()) is only done in Executor::run() which is only called from Meta::run().

Here is a simple example, transitioning from a Meta state to another identical Meta state. This Meta state uses a state that adds a value to the logger in the start() function of the state. This value starts at 0 and is then incremented for the next 20 iterations before transitioning to the next state doing the same thing (TestInitial -> TestInitial2).

Before: As you can see, before the start of the first state (TestInitial) there is one void iteration (see the blank 5ms break between the two Meta states). Note that there seems to also be a bug of mc_log_ui here as the first value of the state should not appear instead of being displayed as 0 (I checked in the log and it is indeed a null value and not a zero here) test_meta_bug

After: No more missed iteration test_meta_fix :

arntanguy commented 2 years ago

Could you also introduce a test similar to the one you ran to identify the issue?

Yes, I'll do that as soon as possible :)

arntanguy commented 2 years ago

Not sure why the tests are failing on windows, but I added the continuity check for the Meta state.

gergondet commented 2 years ago

Not sure why the tests are failing on windows, but I added the continuity check for the Meta state.

I think that's a path issue in the multi-configuration build. This should be fixed. If so I will merge when the CI lands :)

gergondet commented 2 years ago

I finally figured out the CI issue.

Some time ago, the Fortran compiler on Windows started being picked up from chocolatey’s mingw installation rather than the « raw » mingw installation. It went unseen for a while because the required dll was still in the path but since a few days/weeks they are not anymore. I have added them in our CI script (see https://github.com/jrl-umi3218/github-actions/commit/5f3ce258dce1581ea3ac5fa92cce4e3038c75fc9) and everything is well again.

Merging this PR right away. Thanks @arntanguy