Differential drive class
See original GitHub issueThis is just a potential feature request not a bug. (probably a duplicate of some other feature request but I didn’t find it)
There are many EV3 Lego creations that are mobile robots (most EV3 designs have wheels or tracks actually). When doing the programming for a mobile robot, users need to convert motor degrees into distances and into whole robot turn amounts. Obviously we can do these conversions, but for new users it would be nice to provide a convenience class for EV3 mobile robots. My suggestion for a name is Driver, but it could be any name we like, DifferentialDrive, although more accurate, just felt too long.
Example usage:
import ev3dev.ev3 as ev3 robot_base = ev3.Driver(ev3.OUTPUT_B, ev3.OUTPUT_C, 3.3, 17)
Where the arguments are:
- Left motor port
- Right motor port
- Wheel diameter (in cm in this case)
- Distance between wheels (in cm in this case)
- Plus an optional parameter not show to reverse motor direction
Once constructed users could use commands like:
- robot_base.drive(100) # to drive forward 100 cm
- robot_base.turn(90) # to turn right 90 degrees
- robot_base.arc_right(15) # arc right with about a circle with a radius of 15
- robot_base.units = ev3.Driver.UNITS_INCHES # cm by default
- robot_base.driving_speed = 4 # inches per second now, since units changed to degrees
- robot_base.turning_speed = 300 # degrees per second
These are not my ideas. I’ve used Clinton Blackmore’s Enchanting program (https://www.youtube.com/watch?v=N9HZwysMqWY) for NXT with kids for years. It’s an old Scratch based program from 2013 for NXT that he has not updated or maintained. His differential drive mechanism is extremely flexible, robust and easy to use. We use his driving commands with the old NXT robot fleet very heavily. It’d be useful if we provided a Driver class of some sort.
Obviously there are a lot of design decisions about the structure of such a class and there are issues with turning inaccuracies with tank treads instead of two wheels. Despite the concerns it’d be a highly used convenience class.
Here is Clinton’s Scratch based configuration of differential drive
And some of this Scratch commands:
BTW I’m still sad that Clinton abandon his Enchanting project. He was an amazing developer. Funny that one guy could blow away anything Lego ever made for programming the NXT. Still works great today even, despite no updates since Enchanting v0.2 from 2014, I have a kids event on Saturday where we’ll use Enchanting. http://enchanting.robotclub.ab.ca/
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Got distracted by life for a while…will pick this back up and finish it off
I think I have most of the code/math worked out in my MoveDifferential class but I am hitting a snag with trying to accurately rotate a large motor at an exact speed for an exact distance. Opened https://github.com/ev3dev/ev3dev/issues/1186 to investigate.
PS Apologies for being AWOL the past 6 months 😦