sbcshop / MotorShield

Designed to help you get your Raspberry Pi based Robot. This board can control DC motor as well as the stepper motor. You can connect your IR and Ultrasonic sensors to tell your robot about its environment. You can easily make your Line Following, Object following, Wall following, Maze-Solver Robots.
https://shop.sb-components.co.uk/products/motorshield-for-raspberry-pi
52 stars 47 forks source link

Add Function to Return Current Motor Speed #19

Open ronaldroe opened 4 years ago

ronaldroe commented 4 years ago

Please see commit from Oct 21, 2019. I added a function to return current motor speed, and an array of motor speeds for linked motors.

This allows developers to capture the current speed programmatically for use in calculations. This makes using, say an analog stick on a controller easier to work with.

Usage: Single motor getSpeed() returns integer speed value. Linked motor getSpeed() returns array of integer speed values.

Example:

motor1 = PiMotor.Motor("MOTOR1")
motor2 = PiMotor.Motor("MOTOR2")

motors = PiMotor.LinkedMotors(motor1, motor2)

motor1.forward(100)
print(motor1.getSpeed()) #prints speed for motor 1 (100)

motors.forward(50)
print(motors.getSpeed()) #prints array of motor speeds ([50, 50])

There's also some changes where I commented out the print(). Please ignore that. I was trying to reduce output so I could work on a bug in another script.

ronaldroe commented 9 months ago

Are the owners of this library active? There's 4 open PRs, and several unanswered issues.

Maybe it's time to let the community run this if the owners aren't willing to