aseba-community / thymio-vpl2

Next generation VPL for Thymio using Qt Quick from Qt 5.x
GNU Lesser General Public License v3.0
2 stars 5 forks source link

Generated code in simple mode cannot follow line as VPL1 does #26

Closed stephanemagnenat closed 7 years ago

stephanemagnenat commented 7 years ago

The following program in VPL1 works perfectly, both in simulation and in the real robot:

vpl1-line-following

The corresponding code being:

onevent prox
    when prox.ground.delta[0] <= 400 and prox.ground.delta[1] <= 400 do
        motor.left.target = 200
        motor.right.target = 200
        emit pair_run 0
    end
    when prox.ground.delta[0] >= 450 and prox.ground.delta[1] <= 400 do
        motor.left.target = 200
        motor.right.target = 0
        emit pair_run 1
    end
    when prox.ground.delta[0] <= 400 and prox.ground.delta[1] >= 450 do
        motor.left.target = 0
        motor.right.target = 200
        emit pair_run 2
    end

However, the corresponding code in VPL2:

vpl2-line-following

easily losses the track.

From the behaviour of the robot, it seems that the sensors are under-sampled, although the tests are made in the onevent prox handler.

marvelous commented 7 years ago

Generated code 26.txt

stephanemagnenat commented 7 years ago

The bug is in the generated return statements if a transition is taken, the first being in line 127. It is a problem because the transitions for the other threads are not tested, and therefore they cannot be re-initilaized.

A solution to this problem is to put the test of the transitions in a subroutine.

marvelous commented 7 years ago

New generated code, please test in asebastudio with event "transition" (2 arguments) 26.txt

stephanemagnenat commented 7 years ago

With this code, the robot works correctly and never gets out of the track.