DexterInd / GoPiGo3

The GoPiGo3 is a Raspberry Pi Robot!
https://gopigo.io
Other
98 stars 85 forks source link

Modify stop() to turn power off to motors #305

Closed jharris1993 closed 2 years ago

jharris1993 commented 2 years ago

This update adds a set_motor_power() call to the stop() method to turn off power to the motors after stopping the robot.

It also adds a 0.25 second safety delay to prevent inertia from causing the motor to coast.

Depends on: module "sleep" from time.

Justification:

  1. Battery power is a limited resource.

    • It has been my experience based on developing the New Remote Camera Robot project that, sitting idle, the robot can last over a day on a fully charged lithium power pack.
    • After starting and stopping the motors and allowing the robot to sit, the battery life is considerably shortened to several hours without additional use of the wheels.
  2. Component lifetime can be degraded.

    • Allowing enough idling power to "lock" the motors to run continuously through them has the potential to degrade the lifetime of the motors themselves and the chips that drive them.
jharris1993 commented 2 years ago

Since easygopigo3.py already imports time, suggest not including the

from time import sleep

and simply markup the sleep(0.25) as

time.sleep(0.25)

Oops!

How do I fix that? Open another pull request?

CleoQc commented 2 years ago

You simply need to change the files in your own github and it should reflect the changes here. Also downgrade the 0.25 to 0.1, please.

jharris1993 commented 2 years ago

I was confused because the e-mail that GitHub produces is sparse to say the least.

I did what you asked, but I am curious as to why I should reduce the sleep time from 1/4 of a second to 1/10 of a second, as I wanted to give the robot enough time to fully stop, (even if moving quickly), before free-wheeling the motors.

I also removed the import sleep from time and changed the time callout in the method to time.sleep()

Note that I did NOT mess with the version number.  Maybe I should have, but I thought it best to leave file versioning up to you.

Cool Beanies!

I pushed to my branch and it automagically updates here!

jharris1993 commented 2 years ago

Additional comment:

At the very end of the file, there are two lines:

    warnings.warn(deprecated_msg.format(sensor_description), DeprecationWarning)
    print(deprecated_msg.format(sensor_description))

I get two problems reported in VS Code that "sensor_description is not defined"

I have ignored them for the purposes of this commit since it seems to work anyway.

Any idea what's going on?  Just curious.  Maybe it's my whacked-out linter?

Sensor Warning

CleoQc commented 2 years ago

Just as I was about to merge this, I notice you added some unrelated PDFs that do not need to be in this repo. Please remove them from this PR.

jharris1993 commented 2 years ago

"Just as I was about to merge this, I notice you added some unrelated PDFs that do not need to be in this repo. Please remove them from this PR."

Done.

I'm still learning about GitHub and, apparently, after I have opened a pull request, any further work I do on my repository automagically gets included, like it or not.

In this case I was looking at the possibility of a one-for-one replacement of the switching MOSFET to increase the current capability of the GoPiGo3's power supply and I added some technical documentation to the project, forgetting that every time I sneeze I add something to the PR. (grrr)