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
125 stars 121 forks source link

[NXT] "sync" flag in NXC call leads to wrong movement #126

Closed stex closed 5 years ago

stex commented 6 years ago

Possibly a continuation of #209


Describe the bug

When moving only one motor and trying to go forward afterwards, the motor with the smaller degree count is trying to sync up with the other one resulting in a fast curve motion.

To Reproduce Steps to reproduce the behavior:

  1. Write a program like the following: image
  2. Send it to the NXT
  3. The NXT will drive forward, turn left and then turn right quickly.

Video: https://drive.google.com/file/d/1Zk5IJ0oU0fkrdMjGfX8OZlFMQtPKq9eN/view?usp=download

Generated NXC code:

#define WHEELDIAMETER 5.6
#define TRACKWIDTH 12.0
#define MAXLINES 8
#include "NEPODefs.h" // contains NEPO declarations for the NXC NXT API resources

task main() {
    SetSensor(S1, SENSOR_TOUCH);
    SetSensor(S2, SENSOR_SOUND);
    SetSensor(S3, SENSOR_LIGHT);
    SetSensor(S4, SENSOR_TOUCH);
    RotateMotorEx(OUT_BC, SpeedTest(40), (20 * 360 / (PI * WHEELDIAMETER)), 0, true, true);
    Wait(1);
    RotateMotor(OUT_B, SpeedTest(30), 360 * 1);
    RotateMotorEx(OUT_BC, SpeedTest(40), (20 * 360 / (PI * WHEELDIAMETER)), 0, true, true);
    Wait(1);
}

The problem here is the sync flag in RotateMotorEx: It leads to the motor which wasn't used in RotateMotor trying to catch up to the other one, leading to a very fast movement and therefore a curve.

Setting the sync flag to false in the second RotateMotorEx call solves the problem, but - of course - might lead to other problems again.

Expected behavior

  1. The NXT drives forward
  2. The NXT turns left
  3. The NXT drives forward
VinArt commented 5 years ago

Yes, actually drive/steer blocks are not compatible with the blocks that just rotate the specified motor. This block: image should be used when NXT is driving in order to turn it. I am not exactly sure how to deal with both blocks being used in one program, comments and suggestions are welcome

@bjost2s maybe you know?

bjost2s commented 5 years ago

Seems to be not solvable because regulated and unregulated functions influence each other when executed in the same program.