-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Refactor motor drivers #945
Comments
@jithu83 I'm generalizing input/output/pwm handling so each motor controller is not tightly coupled to the particular library that is is using to get ttl or pwm outputs. There is code in actuators.py that you contributed; ArduinoFirmata, ArdPWMSteering, ArdPWMThrottle that uses the Arduino Firmata sketch and python pymata library to talk to it. This is used is in the templates/arduino_drive.py template, which creates a robot that can be driven by a joystick only. This is very specialized code for a very limited use case. Is see the real use-case is for LattePanda boards, since they have a build-in arduino compatible board for GPIO. That is not a board we intend to generally support. We are supporting RaspberryPi and Jetson Nano directly in the code. If we are going to keep Arduino Firmata support, then like to either generalize this code so we can use the Arduino Firmata like other sources of pwm/duty_cycle. I have a branch which is abstracting input/output/pwm pins into what I am calling the 'pin provider' api (see https://github.com/autorope/donkeycar/blob/945-refactor-motor-drivers/donkeycar/parts/pins.py). Is it worth supporting Arduino Firmata as a source of PWM? One of the issues is that it seems Arduino Firmata can produce a duty cycle, but we don't have control over the frequency; it seems like it would be difficult or impossible to use to control a servo for instance, although the arduino_drive.py template seems to imply that it can. Basically, I'm trying to figure out if it is worth keeping in the main code and building into a more generalized system. Should we put time into this? |
Status
1 and 3 are well along. I'm starting on 2 & 4 now. |
I've checked in code to the branch to address #2 & #4 from my prior comment. #2. There is now a drivetrain named PWM_STEERING_THROTTLE and a generalized pulse controller called PulseController that use the pins.py pin provider api to send servo style PWM pulses to Servo/ESC style RC car drivetrains. #4. I've ported the @deprecated decorator from another branch and marked a bunch of stuff in actuators.py as deprecated. I've also left large comments on those classes that explain why they are deprecated and an explanation to how we might proceed if we wanted to keep them in the code. I think one in particular, the Arduino Firmata support, is worth putting into the pins.py pin provider api, but I don't want to block getting this code tested and merged. We can make that a separate issue if we want to move forward with that. |
|
TestingTesters please see the Overall Tests to be performedFor ESC/Steering Servo hardware configurations:
Related Documentation
Configurations:Raspberry Pi, Steering Servo + ESC (standard RC car)
Jetson Nano, Steering Servo + ESC (standard RC car)
Differential Drive
RC hat on RaspberryPi using ESC/Servo drive trainVerify that the new RC hat works correctly in the old config and the new config.
TestersThank you for helping. If you have a configuration that matches one of the above, please checkout the code branch and the documentation branches. The older 'legacy' DRIVE_TRAIN_TYPE configurations, like Instructions
|
I have verified configuration |
I have verified this configuration
I enabled pwm on board pin 13 and board pin 12 using this documentation https://github.com/autorope/donkeydocs/blob/945-refactor-motor-drivers/docs/parts/pins.md#generating-pwm-from-the-jetson-nano |
Verified configurations #9 and #10. |
* Add PWM explanatino to servo/esc section of actuators. * Move PWM svg into assets * Fix PWM svg link * Added docs for pin providers and specifiers * Added instructions for enabling PWM on Jetson Nano * Documentation for new drive-train configurations that use pin providers * Add link to RC setup in controllers.md * Add known issue with OLED driver and diff. drive configurations. * Add wiring diagram for PCA9685 * gitignore hidden files * Fix broken asset links in build_hardware.md - Ok, ok, I broke them. You got me. Happy!? * Fix broken asset links, typos * Remove redundant reference to rc.md - yes, I did it again. * Fix broken links. * Fix broken links. * Change link for 3-pin L298N example. * Update RC hat docs to use PWM_STEERING_THROTTLE drive train. This has been tested autorope/donkeycar#945 (comment) * Update known issue with OLED and RPi.GPIO
merged code PR #951 and docs PR autorope/donkeydocs#25 |
Our motor drivers are pretty tightly bound to the libraries used to control PWM and GPIO pins. This makes it hard to re-use code when building a new driver.
I'm in the process of enabling donkeycar software on a Duckiebot robot homebrew clone here. It uses an TB6612FNG motor controller which is pin compatible with an L298N. However, due to the evolution of the Duckiebot platform, one of it's motors get's it's enable signals from GPIO and the other from a PCA9685. The other motor get's it's enable signals from GPIO and PWM from PCA9685.
This would all be actually pretty easy to handle if we had our motor drivers accept a more generic interface for setting GPIO and PWM signals. We could implement versions for the RPi.GPIO library, PiGPIO library and the PCA9685. We could even write a version that controls this via an arduino using I2c or serial.
I would also refactor the templates by extractng the drivetrain construction from complete.py and making this a function that can be called by any template. Then we could give other templates the flexibility to choose drivetrains, even if we only add a default in their config.
Add more documentation on how to wire the motor drivers. Each of our choices for motor implies a certain kind of hardware and wiring. It would be useful to add a little more documentation and references on this. Links to product descriptions on Amazon and Aliexpress tend to go stale very quickly, so we should focus on finding datasheets and tutorials that are likely to stay live longer.
This article does a very detailed job of describing the possible connections to an L298N https://www.etechnophiles.com/l298n-motor-driver-pin-diagram/ However, it does not explicitly describe how only the duty cycle inputs are used and the enable pins are not used. The links to the product pages are 404ing. I'm assuming this driver is for a 'mini' L298N. That board uses just 4 wired to hookup 2 motors as this driver assumes. Here is an article on how t use this with an arduino; https://www.instructables.com/Tutorial-for-Dual-Channel-DC-Motor-Driver-Board-PW/ Basically, the input pins are also used as PWM/duty cycle pins. I assume you can use a full L298N module in this mode by leaving the enable pins jumpered and sending PWM via the input pint.
The text was updated successfully, but these errors were encountered: