-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Donkeycar #41
Comments
I'm very interested in the autonomous driving features by the Donkeycar project. It would be great if the freenove 4wd smart car would support this. |
The code I added above will handle the drive train. We must also consider the camera. The camera is a standard Raspberry Pi camera, so the default
In donkey we can use the PulseController https://github.com/autorope/donkeycar/blob/5d7fd5014e3eb0831a270b57f5b8f7783787fc47/donkeycar/parts/actuator.py#L85 with an appropriate pin specifier, like We may want to point the camera slightly down so it can see immediately in front of the car. |
Regarding the camera position: I copied https://github.com/Freenove/Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/blob/faa05beb1a29668aacaf331609e4ce62b01d9353/Code/Server/servo.py and https://github.com/Freenove/Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/blob/faa05beb1a29668aacaf331609e4ce62b01d9353/Code/Server/PCA9685.py into the mycar folder and used the servo class to initialize the camera position once in the import time
from servo_freenove import Servo
pwm=Servo()
pwm.setServoPwm('0',90, 10)
time.sleep(0.2)
pwm.setServoPwm('1', 90, 10)
time.sleep(0.2) |
Donkeycar
I am one of the maintainers of the Donkeycar project. We have recently had a user ask about running the Donkeycar code on his Freenove 4WD Smart Car Kit for Raspberry Pi. I believe it could easily be done. Perhaps you might do this work and make Donkeycar available to your users. Here is what I suggested to him; if Freenove could do this work and test it, then you could open a pull request into donkeycar and add value for your users.
Looking at the github, it appears the Freenove 4WD Smart Car Kit for Raspberry Pi is using a PCA9685 to generate the duty cycle for 4 motors; https://github.com/Freenove/Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/blob/master/Code/Server/Motor.py. The 4 motors, one per wheel, each use two PWM outputs from the PCA9685; one for forward duty cycle and one for reverse duty cycle.
The closest drivetrain the Donkeycar project has is
DRIVE_TRAIN_TYPE == "DC_TWO_WHEEL"
, which uses two PWM outputs each for two motors (a left and right motor) as in a typicaly differential drive configuration. So you need to 1) create a new drivetrain type in manage.py/complete.py, 2) Add configuration for the new drivetrain to myconfig.py/cfg_complete.py and make sure it is uncommented. 3) setDRIVE_TRAIN_TYPE == <new_configuration_name>
in myconfig.py. I'll detail these steps below:actuator.L298N_HBridge_2pin
part for each of the 4 motors. Something like this;DRIVE_TRAIN_TYPE == "DC_TWO_WHEEL_SKID"
by copying theDC_TWO_WHEEL
configuration block at https://github.com/autorope/donkeycar/blob/5d7fd5014e3eb0831a270b57f5b8f7783787fc47/donkeycar/templates/cfg_complete.py#L290, like;DRIVE_TRAIN_TYPE == "DC_TWO_WHEEL_SKID"
in your myconfig.pyNOTE myconfig.py is really just a copy of cfg_complete.py and manage.py is really just a copy of complete.py (both linked above). So if you want to make integrate the changes into the donkeycar framework, then you could change those files. The when you create a new
mycar
application using thedonkey createcar path=~/mycar
command it will create a myconfig.py and manage.py with the changes. If you do that and your testing shows that car works, please open a pull request and we can make that new drivetrain part of the regular donkeycar code.The text was updated successfully, but these errors were encountered: