Search code examples
raspberry-pi4motordriver

Calibrate Donkey Car via raspberrypi4 with l298n motor (* no 16 channel servo driver )


So I am building a donkey car in raspberry pi 4 2gb. I have installed the software and all libraries needed and made changes in myconfig.py. My car runs properly, but I couldn't calibrate it to turn properly (left and right) according to https://docs.donkeycar.com/guide/calibrate/. If anyone could help it would be great.

code changes in myconfig.py

# #CAMERA
CAMERA_TYPE = "WEBCAM" 
IMAGE_W = 200
IMAGE_H = 120

DRIVE_TRAIN_TYPE = "DC_TWO_WHEEL_L298N"

DC_TWO_WHEEL_L298N = {
    "LEFT_FWD_PIN": "RPI_GPIO.BOARD.16",        # TTL output pin enables left wheel forward
    "LEFT_BWD_PIN": "RPI_GPIO.BOARD.18",        # TTL output pin enables left wheel reverse
    "LEFT_EN_DUTY_PIN": "RPI_GPIO.BOARD.22",    # PWM pin generates duty cycle for left motor speed 
     "RIGHT_FWD_PIN": "RPI_GPIO.BOARD.15",       # TTL output pin enables right wheel forward
     "RIGHT_BWD_PIN": "RPI_GPIO.BOARD.13",       # TTL output pin enables right wheel reverse
     "RIGHT_EN_DUTY_PIN": "RPI_GPIO.BOARD.11",   # PWM pin generates duty cycle for right wheel speed
}

Solution

  • This question is probably best asked in the robotics stackexchange or the donkeycar discord. But to answer your question, a differential drive robot (you've chosen the DC_TWO_WHEEL_L298N drive train, so I am assuming you have two motors connected to the L298N) does not need to have it's steering calibrated. So you can ignore that calibration step. The robot is steered by varying the throttle to each motor. For a left turn, the left motor is given less throttle, so it's wheel will turn slower than the right wheel; that will cause the robot to turn in a leftward arc. A right turn is similar but the right wheel turns slower.