OpenRoberta / openroberta-lab

The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based application, the platform can be used without prior installation of specific software but runs in any popular browser, independent of operating system and device.
Apache License 2.0
124 stars 121 forks source link

steer wont run motors backwards on NXT #1642

Open Andy1978 opened 7 months ago

Andy1978 commented 7 months ago

If you change direction of the steer block, the motors don't turn backwards when speeds are different for left and right. The simulation shows the robot moving as expected.

robot configuration grafik

program NEPOprog grafik

Although the documentation for the "steer" block isn't very detailed I would expect to reverse the movement with either the dropdown field "forward/backwards", by inverting both speed setting or inverting the distance. These three work is both speeds are equal. As soon as they slightly differ (for example 29% and 30%), moving backwards no longer works and results in an endless waiting state.

NXT Firmware 1.29.2

Andy1978 commented 7 months ago

The problem is in https://github.com/OpenRoberta/ora-cc-rsc/blob/master/RobotNXT/NEPODefs.h#L120 where OnFwdRegEx is called with powerLeft and powerRight with floats and not chars. Explicitly copying to char before calling OnFwdRegEx fixes it, although I think this is a dirty hack

    char tmp_powerLeft = powerLeft;
    char tmp_powerRight = powerRight;
    if (absPowerLeft < absPowerRight) {
        OnFwdRegEx(portLeft, tmp_powerLeft, OUT_REGMODE_SPEED, RESET_ALL);
        OnFwdRegEx(portRight, tmp_powerRight, OUT_REGMODE_SPEED, RESET_ALL);
...
bjost2s commented 7 months ago

Thank you very much, for the issue and for the solution! Do you have any timing issues with this solution? School or workshop dates, etc? If not, we plan to update the ora-cc-rsc repo at the end of this month. Until then, we will integrate the fix on one of our test servers so that it can be tested. I will let you know here which test server the fix is on as soon as it is possible.

Andy1978 commented 7 months ago

Thank you for your reply. In the meantime I forked ora-cc-rsc and patched it there (using char instead of floats like the underlying NXC call) https://github.com/OpenRoberta/ora-cc-rsc/compare/master...Andy1978:ora-cc-rsc:master

Since then I'm running my own openroberta instance with own fork so I don't have any timing issues. Can you point me to the tests? Obviously they weren't able to detect the problem, perhaps I'm able to help fixing or extending the regression tests.

SteerDrive has the same problem and won't drive backwards (I'll add a patch for it soon)

Is there there a recommended NXT firmware for Open Roberta Lab? I can't find a hint in the wiki but since it uses NXC I guess an enhanced 1.32 firmware from https://bricxcc.sourceforge.net/test_releases might be best?

Andy1978 commented 6 months ago

I made various tests with different NXT firmwares:

So, finally back to this bug report.

I would understand if OpenRoberta took the position that their software must only work with the original Lego firmware but I would welcome an implementation that also runs on the free firmwares based on LEGOs latest released sourcecode.

@BeateJ What do you think?

schodet commented 5 months ago

Hi, I am the maintainer of NXT Improved firmware. The bug is fixed with version 1.29.6.

But the NXT Enhanced Firmware, which is quite popular, is no longer maintained, so I think that having the @Andy1978 fix would be valuable.

Thanks.