DexterInd / GoPiGo3

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

easygopygo3's "stop()" method does not remove power from the motors #306

Closed jharris1993 closed 2 years ago

jharris1993 commented 2 years ago

Ref: Pull request #305

Issue: Once the motors have been energized by the methods in the easygopigo3 library, they never get turned off.  This causes a continuous power drain and potential stress to the components involved.

Why this is an issue:

  1. Battery power is a limited resource and allowing continuous motor current to run will cause them to be depleted more quickly.
    • Though I have not measured this with precision, my experience with the New Remote Camera Robot project indicates that, absent motor power, the battery's run time is in the tens or twenties of hours.  After the motors have been energized and stopped, the run time is measured in units of hours.
  2. Allowing current to continuously run thorough the motors/drivers stresses both the motors and their driving circuitry and may shorten their useful life.
    • Note that the servos already have a disabling method that can be used to turn off power to the servos when not in use.

Proposed solution: Within the stop() method, follow the set_motor_dps() command that stops robot motion with a set_motor_power() command that turns the motors themselves off.  This makes removal of power automatic and prevents inadvertent additional load on the power source.

Alternate solution: Create a motor disabling method corresponding to the servo[n].disable_servo() methods that already exist for the servos.

Caveat: If you remove power from the robot motors too quickly after stopping them, the robot's inertia may try to keep the motors moving if the robot is heavy or moving quicly.  The solution to this is to provide a slight, (0.25 - 0.50 second), pause between the set_motor_dps() command that stops the robot and the set_motor_power() command to give the robot time to come to a complete stop.

CleoQc commented 2 years ago

Now fixed. Thank you for your contribution.