Skip to content

Differential drive class #392

Closed
Closed

Description

@fisherds

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
configure_drive

And some of this Scratch commands:
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

  1. dwalton76 commented on Oct 4, 2017

    @dwalton76
    Collaborator

    I like it. @fisherds you should submit a pull request :)

  2. dwalton76 commented on Oct 8, 2017

    @dwalton76
    Collaborator

    I started on this one so will take it unless someone else is interested in working on it

  3. self-assigned this
    on Oct 8, 2017
  4. dwalton76 commented on Oct 12, 2017

    @dwalton76
    Collaborator

    @fisherds if you say drive in an arc to the left with a radius of 50cm is the expectation that the outer wheel, inner wheel or midpoint between the two wheels creates a circle with a radius of 50cm?

  5. dwalton76 commented on Oct 12, 2017

    @dwalton76
    Collaborator

    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.

  6. fisherds commented on Oct 12, 2017

    @fisherds
    Author

    @dwalton76 I think the best plan is midpoint for all questions like that. Love that you are working on this idea!

  7. dwalton76 commented on Nov 23, 2017

    @dwalton76
    Collaborator

    I need to get back to this...got distracted by Rubik’s cube solving work this past month.

  8. dwalton76 commented on Jan 31, 2018

    @dwalton76
    Collaborator

    I am declaring my Rubik’s cube solver complete so should be able to get back to this and other ev3 related todos

  9. added this to the 2.1 milestone on Jul 29, 2018
  10. dwalton76 commented on Aug 6, 2018

    @dwalton76
    Collaborator

    Got distracted by life for a while....will pick this back up and finish it off

  11. dwalton76 commented on Oct 26, 2018

    @dwalton76
    Collaborator

    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 :(

  12. added a commit that references this issue on Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions