quang-ha / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
0 stars 0 forks source link

motcont.py lacks command cancellation, or am I missing something? #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. the mocont web page mentions ways to cancel commands that are being executed 
by motors. This seems to be missing in motcont.py
It is an important functionality to implement: I am happy to do it if you give 
me advice, Marcus.

What is the expected output? What do you see instead?
I expected to see all the functionalities of Motcontrol implemented as from 
their web page.
I was expected to be able to cancel a command, like it is done in :
http://www.mindstorms.rwth-aachen.de/trac/browser/trunk/mfiles/%40NXTMotor/Stop.
m

Basically cancelling a command and stopping, without active breaking.

What version of nxt-python are you using? On what operating system?
Win7x64  nxt-python-2.2.2  bluetooth  python 2.6

Please provide any additional information below.
I am referring to:
http://www.mindstorms.rwth-aachen.de/trac/wiki/MotorControl

"
Cancelling commands

When a certain motor is running, you can always cancel the current operation by 
sending two types of "stop" commands. By "stop" I just mean a certain parameter 
combination for SetOutputState. If you want to stop multiple motors, you have 
to send a direct command to each one of them. The MotorControl program will 
recognize this "cancellation request" and stop the control algorithm.

Reference implementation: @NXTMotor/Stop.m

We've got:

Stopping (coasting)

This means turning off power to a motor, leaving it spinning freely (coasting). 
To do this, the corresping NXC-code looks like this:

SetOutput(port, Power, 0, OutputMode, OUT_MODE_COAST, RegMode, 
OUT_REGMODE_IDLE, RunState, OUT_RUNSTATE_IDLE, UpdateFlags, UF_UPDATE_MODE + 
UF_UPDATE_SPEED);
This is basically just setting a power of 0 and setting everything else to OFF 
or IDLE…

Active braking
[...]
"

Original issue reported on code.google.com by Andrea.G...@gmail.com on 15 Oct 2012 at 7:23

GoogleCodeExporter commented 9 years ago
nxt.motcont provides a wrapper for MotorControl commands. If you actually read 
the quote you posted, it directs you to send a SetOutputState command directly 
to the motor via the NXT firmware interface. This means nxt.Motor(b, 
nxt.PORT_A).idle() or .brake(). MotorControl has no command-type for canceling 
a previous command, and as a result we do not wrap it in nxt.motcont. Sorry 
about that...

Original comment by marcus@wanners.net on 15 Oct 2012 at 8:15

GoogleCodeExporter commented 9 years ago
sorry: this works. it is the command
motcont.reset_tacho(port)

Question: what is the way, in motcont, of having a car moving forward and 
turning smoothly left and right?
the motors stops after every command.
Also, when syncronized, they seem to move only forward: one can't set a ratio, 
can he?
I mean, if one gives two separate commands, how can both motors stop naturally 
at the same time (I mean, with no brutal interruptions).
thanks!

Original comment by Andrea.G...@gmail.com on 15 Oct 2012 at 10:03

GoogleCodeExporter commented 9 years ago
sorry, I did not read your reply before posting mine.
So it is not dangerous to use both motor and motcontrol (I mean danger of 
confusing motcontrol).
I see, so "motor" and "motcont" are needed together to fully control the motors 
/ cancel orders.

Marcus, thanks for your reply. Can you please advise on what is the best way to 
drive motors smoothly, so that they do not stop while one adjusts the ratio 
between A and C, to turn slightly while moving forward with a car?
thanks!
I am happy to help in testing or drafting some code, if you wish.

Original comment by Andrea.G...@gmail.com on 15 Oct 2012 at 10:10

GoogleCodeExporter commented 9 years ago
Actually motcont.reset_tacho(port)
does not work as well as I worte above: the motor stops but motorcontrol 
"beeps".
motor.idle() works, however it does not reset the interval in motcont, so one 
can't send a command to mocont immediately after idle()
the best is to wait for motcont to say that the motor is_ready again.
(unfortunately, this is not super fast on Bluetooth, so it does not work too 
well in trying to create smooth motor movements.)

Original comment by Andrea.G...@gmail.com on 16 Oct 2012 at 10:55