Part: Diff_drive

Hello development team,

I wonder, why diff_drive part is not included at the default distribution.

Is nobody missing this basic 2 wheel controller ?
I’d like to extend the controller classes for simple arduino nano pymata usage.

Thanks for a short feedback

Cheers
Chrimo

By and large the current design has one set of drive wheels and one steering set. More of an Ackerman model, even though kinematic models aren’t directly used in the project per say like they might be in a ROS project. The default car receive its velocity commands for essentially a fixed set of rear wheels.

Whereas differential drive is more suited for robots with two primary wheels that provide velocity and angle from a single set of wheels and have a third caster or similar type wheel for balance.

I suspect the real reason is that most of the model cars more closely resemble the ackerman, but as indicated at the top, even that is controlled through simple “+1/-1” for forward/reverse and “+1/-1” for left right without any linear algebra one might normally use to convert angle/velocity into separate motor commands on a differential drive robot.

That said, there’s nothing stopping you from building your own diff-drive robot and using the part. (I’m in process on such a car myself, mostly because it’s much easier to get odometery)

Yes, thats it. I’m coming from ROS and have a lot of diffdrive robots available. I’m typically using tank like vehicles and use simple USB connected arduino PWM hardware.
We should give it a try and I like to port my generic ros USB PWM drivers to DonkeyCar.

Many thanks for your friendly hints

Cheers
Chrimo

There are TwoWheelSteeringThrottle in the donkeycar 3.0.x actuator.py. I use this class and Adafruit_DCMotor_Hat to run donkeycar on JetBot. However, TwoWheelSteeringThrottle did not work as it is, so I am using it as follows.

diff -ur donkeycar.org/donkeycar/parts/actuator.py donkeycar/donkeycar/parts/ac\
tuator.py                                                                       
--- donkeycar.org/donkeycar/parts/actuator.py   2019-06-25 20:32:47.733752617 +\
0900                                                                            
+++ donkeycar/donkeycar/parts/actuator.py       2019-06-23 12:41:12.214024421 +\
0900                                                                            
@@ -241,9 +241,13 @@
         from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor      
         import atexit                                                          
                                                                                
-        self.FORWARD = Adafruit_MotorHAT.FORWARD                               
-        self.BACKWARD = Adafruit_MotorHAT.BACKWARD                             
-        self.mh = Adafruit_MotorHAT(addr=0x60)                                 
+        #self.FORWARD = Adafruit_MotorHAT.FORWARD                              
+        #self.BACKWARD = Adafruit_MotorHAT.BACKWARD                            
+        #self.mh = Adafruit_MotorHAT(addr=0x60)                                
+        self.FORWARD = Adafruit_MotorHAT.BACKWARD                              
+        self.BACKWARD = Adafruit_MotorHAT.FORWARD                              
+        self.RELEASE = Adafruit_MotorHAT.RELEASE                               
+        self.mh = Adafruit_MotorHAT(i2c_bus=1)                                 
                                                                                
         self.motor = self.mh.getMotor(motor_num)                               
         self.motor_num = motor_num                                             
@@ -251,8 +255,10 @@
         atexit.register(self.turn_off_motors)                                  
         self.speed = 0                                                         
         self.throttle = 0                                                      
-                                                                               
-                                                                               
+                                                                               
+    def turn_off_motors(self):                                                 
+        self.mh.getMotor(self.motor_num).run(self.RELEASE)                     
+                                                                               
     def run(self, speed):                                                      
         '''                                                                    
         Update the speed of the motor where 1 is full forward and              
@@ -270,10 +276,10 @@
             self.motor.run(self.BACKWARD)                                      
                                                                                
         self.motor.setSpeed(self.throttle)                                     
-                                                                               
                                                                                
     def shutdown(self):                                                        
-        self.mh.getMotor(self.motor_num).run(Adafruit_MotorHAT.RELEASE)        
+        self.mh.getMotor(self.motor_num).run(self.RELEASE)                     
+                                                                               
                                                                                
 class Maestro:                                                                 
     '''                                                                        
1 Like

Hi thanks,
great hint. I’m digging in the same lines to add my new driver :slight_smile:

Cheers
Chrimo