Page 1 of 1

LEGO NXT: The problem with normal motor control

PostPosted: Tue May 03, 2011 10:51 am
by one_eddie
I built the basic tribot robot (equipped with two motors). I use AForge 2.1.5 to communicate with the NXT brick ( FW1.31 ) via bluetooth. During the program operation using the existing API set following state (1):

B: ON+REGULATED+SYNC+BREAK, POWER=70, TURN=100, TACH_LIMIT=720 // full turn
C: ON+REGULATED+SYNC+BREAK, POWER=70, TURN=100, TACH_LIMIT=720

Just to make to robot turn left. Waiting until then it will be recreated by checking whether RUNSTATE is still RUNNING. Once again change the state (2) to

B: ON+REGULATED+SYNC+BREAK, POWER=70, TURN=0
C: ON+REGULATED+SYNC+BREAK, POWER=70, TURN=0

To make it move forward.

The main problem is that after I set to state (2) the robot turns RIGHT at full speed and then forward. It seems like it is undoing the LEFT turn. Can anyone help me understand this behavior? What is wrong in my solution? Is there any documentation which I could read to understand motor behavior?

I have a program which you could use to test this behavior. If anyone is interested please let me know.

Re: LEGO NXT: The problem with normal motor control

PostPosted: Mon May 16, 2011 9:14 pm
by linusa
one_eddie wrote:The main problem is that after I set to state (2) the robot turns RIGHT at full speed and then forward. It seems like it is undoing the LEFT turn. Can anyone help me understand this behavior? What is wrong in my solution? Is there any documentation which I could read to understand motor behavior?

Unfortunately, this is the LEGO firmware's "automatic error correction" in action. Google it, or read about it here: http://www.mindstorms.rwth-aachen.de/do ... ing.html#7

In this case, you can work around this issue. Try the following steps, and see, if you maybe can omit one of them:

1. Stop both motors, by using SetOutputState, and setting everything to 0, OFF, IDLE, etc.
2. Reset both "block tacho counts". Do it with the command ResetMotorPosition and the flag for "relative" set to true. See LEGO documentation.

After this, you can issue synced commands again. Maybe for the long term, this is an alternative for you? http://www.mindstorms.rwth-aachen.de/tr ... torControl

I also posted more about syncing motors here: viewtopic.php?f=2&t=2071&start=10#p5389

Re: LEGO NXT: The problem with normal motor control

PostPosted: Tue May 17, 2011 8:42 am
by one_eddie
Thank you for the detailed information you provided. Some time ago I finished my project but maybe will start another one and will use those information again. Of course after some time I found same solution as described (BREAK+RESET). I even sent a small patch in order to make that fix (issue #212).

Described behavior is a workaround and can be a big issue when you trying to implement smooth moves. Of course, there's no problem if you use the built program.
I wonder if someone managed to implement a smooth movement using remote communication?

Re: LEGO NXT: The problem with normal motor control

PostPosted: Tue Aug 02, 2011 4:26 pm
by linusa
Hi, sorry for reviving this old thread, but now there's ready-to-use support for MotorControl in .net. The MindSqualls framework has just added this feature, see http://www.mindsqualls.net/MotorControl.aspx . Maybe you can directly use / include this?

Re: LEGO NXT: The problem with normal motor control

PostPosted: Tue Aug 02, 2011 5:56 pm
by one_eddie
For me this is great news. I've implemented my robot behavior using few design patterns which allow me to swap communication protocol without any changes. Will try this on my implementation hope it works :D
But even this is released I will try include (propose to Andrew) few improvements (higher abstraction to existing AForge interfaces) I made while building my implementation. Hope someone wil lfind it useful. Just need some time to prepare it.