question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Differential drive class

See original GitHub issue

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/

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
dwalton76commented, Aug 6, 2018

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

0reactions
dwalton76commented, 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 https://github.com/ev3dev/ev3dev/issues/1186 to investigate.

PS Apologies for being AWOL the past 6 months 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Differential Drive Kinematics - WPILib Docs
The DifferentialDriveKinematics class is a useful tool that converts between a ChassisSpeeds object and a DifferentialDriveWheelSpeeds object, which contains ...
Read more >
wpilib.drive.DifferentialDrive - RobotPy Documentation
A class for driving differential drive/skid-steer drive platforms such as the Kit of Parts drive base, “tank drive”, or West Coast Drive.
Read more >
allwpilib/DifferentialDrive.java at main - GitHub
A class for driving differential drive/skid-steer drive platforms such as the Kit of Parts drive. * base, "tank drive", or West Coast Drive....
Read more >
Differential drive best code - Programming - Chief Delphi
Right now we have a simple arcade drive with the left ( front and… ... The differential drive class in WPILIB has a...
Read more >
ecl_mobile_robot: ecl::DifferentialDrive Class Reference
Differential drive properties and algorithms. This class typedefs various algorithm groups as well as providing some generic structures/methods for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found