ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

Motor Angle Reset - Is there a way to just reset the counter? #691

Closed ghost closed 4 years ago

ghost commented 4 years ago
**ev3dev version: 4.14.96-ev3dev-2.3.2-ev3
**ev3dev-lang-python version:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-===================-==========================
ii  micropython-ev 2.0.0~beta5  all          Python language bindings for ev3d
ii  python3-ev3dev 1.2.0        all          Python language bindings for ev3d
ii  python3-ev3dev 2.0.0~beta5  all          Python language bindings for ev3d

WHAT'S GOING ON: When we try to reset the motors at the beginning of our robot game runs, sometimes the motor won't reset - maybe once out of every 4 -5 times we run our program.

We are wanting the motor angle reset to 0, so we can keep track of how far we've gone on each move, but when it doesn't reset, the run gets all thrown off.

This happens only sometimes - if we kill the program, and restart, or redownload and restart, we are good for a few program initiations...then it happens again.

I was hoping there was a simple motor.reset_angle() command, but there doesn't appear to be. See #674.

Other than just reading the motor.position and using it as an offset value internal to the program, is there anything that can be done?

Is there some way to reset ONLY the motor angle and not every thing about the motor (we also invert the of the 4 motors we are using).

Frustrating...because everything else (except gyro reset) seems to work great. We get awesome positional precision using ev3dev2.

Thanks in advance.

dlech commented 4 years ago

It should be possible to set the position - but only when the motor is stopped.

motor.position = 0
ghost commented 4 years ago

That sounds like it will work.

I'll have the kids try it tomorrow.

Thanks for the help and all your work on ev3dev.

ghost commented 4 years ago

Works like a charm and prevents the hiccups and hassles of using the motor.reset().

The kids send their thanks for helping fix their frustrations with the motor.reset().

WasabiFan commented 4 years ago

Glad to hear your problem was solved! Can this issue be closed?

ghost commented 4 years ago

@dlech @WasabiFan - My team and I wanted to send you a thank you for your help. We just had our FLL tournament. We were the only team using EV3 Python. That gave a big plus on the judging, as this is the second year Ohio has allowed alternative programming languages and the first year that FLL globally has allowed it.

It is honestly a lot easier to program the robot this way than with the EV3-G graphical programming method. We were running out time and literally made a big change to the program in about 30 seconds and downloaded the code to the robot just as we were entering the competition area (where we had to shut off our wifi link).

We had a good enough robot day to score 330 of possible 620 (we were shooting for a max of 420).

That was the second highest score at the tournament and allowed us to move on to the next competition.

I would not have been possible without your help.

Thank you.

dwalton76 commented 4 years ago

@Technonati this is very cool to hear :) Thank you for sharing