Repository navigation
Description
This 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/
Activity
dwalton76 commentedon Oct 4, 2017
I like it. @fisherds you should submit a pull request :)
dwalton76 commentedon Oct 8, 2017
I started on this one so will take it unless someone else is interested in working on it
dwalton76 commentedon Oct 12, 2017
@fisherds if you say
drive in an arc to the left with a radius of 50cmis the expectation that the outer wheel, inner wheel or midpoint between the two wheels creates a circle with a radius of 50cm?dwalton76 commentedon Oct 12, 2017
Same basic question in regards to setting driving speed, are you specify the speed of the outer wheel, inner wheel or of the midpoint between the two wheels.
fisherds commentedon Oct 12, 2017
@dwalton76 I think the best plan is midpoint for all questions like that. Love that you are working on this idea!
dwalton76 commentedon Nov 23, 2017
I need to get back to this...got distracted by Rubik’s cube solving work this past month.
dwalton76 commentedon Jan 31, 2018
I am declaring my Rubik’s cube solver complete so should be able to get back to this and other ev3 related todos
dwalton76 commentedon Aug 6, 2018
Got distracted by life for a while....will pick this back up and finish it off
dwalton76 commentedon Oct 26, 2018
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 ev3dev/ev3dev#1186 to investigate.
PS
Apologies for being AWOL the past 6 months :(
MoveDifferential (#536)