I was thinking about using hoverboard motors on a rover for quite a while. They offer high torque at an unbeatable price. The ODrive looks like a perfect fit for those motors. It uses closed loop control with the motor’s hall sensors to allow very precise movements even at low speeds.
Finally I found some time to put it all together and the results looks very promising. I use auto mode without any global reference (no GPS or compass). ODrive allows to read out the encoder positions, so it can be used as as wheel encoders for the EKF3 without any extra hardware.
This is a simple mission following a 3m x 2m rectangle. There is a little bit of oscillation after the pivot turns, but I think it looks pretty decent.
The biggest issue at the moment is gyro drift. I believe this is caused by having only one measurement source for rotations (just the gyro no compass), so the EKF can’t really estimate the offset. It might be a good idea to calibrate the gyro offset any time the rover is not moving.
At the moment this is just a quick and dirty hack, but I think ODrive support could be added to the mainline if there is some interest.
That is very nice !
Would it be a problem for you if I put this post in the blog section ?
This is such great work that I’ve promoted it to a Blog post. I hope that’s OK. Nicely done!
Thanks. Sure, no problem to use it as a blog post.
very good idea to use the hoverboard motors… i am scanning ebay and local markets for broken ones the last two days
looking forward to my 4wd offroad platform!
from my understanding these are normal brushless motors and should run with a blheli esc?
even better! you can use the original hardware !
How did you setup the ODrive? PWM or Analog?
I’m trying this, but I’m getting a bunch of noise on the Pixhawk 2.1 outputs and it’s hard debugging…
Any tips would be appreciated!
Odrive 3.6 (54v) and Pixhawk Black Cube.
@Jeb_Campbell: I was controlling it using the ASCII protocol over USB. Ardupilot runs on a RPi with a modified output driver to directly talk over the virtual serial port. This allows to read the encoders positions from ODrive over the same connection. I needed the wheel encoders as I didn’t have GPS or any other absolut measurement of speed.
It shouldn’t be too hard to do the same using the UART connection on the Pixhawk and Odrive. But requires modifying the firmware.
Are you sure it’s noise on the Pixhawk outputs? I had some trouble with the ODrive itself. There was noise on the encoders and I had to upgrade the ODrive firmware to have a stable system.
Thanks for the info. This is a great setup for a rover with odrive.
I’m willing to send pizza/beer money for a detailed write up and modified serial code as I have been banging my head on this for too long now. Just send me a paypal address…
I re-watched your video and I’m so impressed with how simple it is. I went back to the garage last night and looked at my jumble of wires that isn’t moving…
@Jeb_Campbell, are you able to compile/modify Ardupilot from source code?
Are you trying to get this working on a RPi or the Pixhawk?
Do you need encoder feedback in ardupilot?
Do you need PWM outputs for things other than the ODrive (Servos, etc)?
My current code is quite hacky and might be confusing. It will not work on any off the shelf boards without modifications! But you can find it here if you want to have a look. To merge this in the mainline Ardupilot, I would need some support how to correctly integrate this into the Ardupilot codebase.
What is your progress so far? What are the concrete issues you are facing?
Using PWM is probably the easiest to get this working. If the PWM signal is too noisy to work, you might have trouble with uart as well. So analog filters might help here.
PS: I am running ardupilot on a RPi with an IMU directly hooked up to the SPI. That’s all you really need for a rover, but its not supported out of the box.
@Daniel_Widmann Thank you for taking the time to look at this! I’ll detail what I know below.
(Hardware available) Pixhawk 2.1 + GPS, Rpi 3b+ w/ BerryGPS/IMU, and the Odrive.
I didn’t know Ardupilot would run on a bare Rpi… So I’ve been trying to get the Pixhawk running. Encoder input to the EKF would be nice. And I love the simplicity of your build (I just want to build a solar mower/rover to see if I can do it). I have linux experience, some coding, and can at least work an oscilloscope well enough to impress my kids…
What is working:
(Odrive) works with ASCII commands over USB and Serial. I had this going with one of the ESP32 Lora chips to a Blynk app on my phone. PWM not tested, but I followed the docs. But it needed a brain…
(Pixhawk 2.1) Bench config tested with GPS, 900MHz telemetry, and commands from Qgroundcontrol and Mission Planner. 48v -> 5v powersupply tested on bench. Clean and correct PWM output for skid steering verified from oscope.
But it doesn’t work when I hook them together (they are grounded together). One odrive wheel drives in reverse (sometimes) with no command input and no change with Pixhawk output. This made me get the scope out…
My scope wouldn’t even lock on a frequency on the PWM pin when it was turned on. So I powered the Pixhawk from USB (odrive off) and the signal looks good (16kHz). As soon as the odrive is powered on and connected the signal goes crazy. If I disconnect the pins from the pixhawk to odrive, I start getting noise on the pixhawk output pins (rf interference?).
I would like to start down the Rpi route. I’ll look in your code for which ./waf --board xxx you used. Thank you for your time, and I’d still love to send some pizza/beer money… jebc AAATTT c4solutions DDOOTT net.
@Jeb_Campbell, your options are:
- Add the BerryGPS/IMU as a Ardupilot board (This is a non trivial amount of coding / debugging work). Port my ODrive code on top.
- Get a Navio board. Port my ODrive code on top.
- Get the same IMU I used and run my code. This probably also requires some debugging and fine tuning.
- Add ODrive uart support to the Pixhawk
- Fix the PWM in your setup (There is no technical reason why this should’t work)
At the moment, non of the rpi stuff is super easy, so I would recommend investigating that PWM issue first. It will be much less effort.
- Have you tried to disconnect just the PWM (but run everything else from the battery) and look at the signal with the scope?
- Have you tried a servo tester / arduino / RC Remote / etc to verify that the PWM inputs of the Odrive are working?
@Daniel_Widmann - Thank you, servo tester ordered and should be here Friday.
While I wait on that, I’ll probably start looking a BerryIMU port (the sensors are there).
I went through your code last night and it is the perfect jumpstart to adding a board and the Odrive driver.
Thank you so much. And let me send you a beer… Jeb
Hi did you get the original hardware to work with APM. and if so i would like your help
yes i use the original “hoverboard” hardware. just connected a st-link programer flashed the “hack” firmware. (have a look at the video above).
now you can control the two weels with either ppm or analog voltage.
i went the simple way and used pixhawk (outputs pwm) -> pwm to ppm converter -> hoverboard hardware.
and was ready to go. i use 4wd.
Thx for replying I have already flash the hoverboard but how do you connect the pixhawk to the HoverBoard?
to make it very simple if you have no programing background use the PPM input.
pixhawk only outputs PWM so you need a converter PWM to PPM.
for example this one here : https://www.banggood.com/AFPV-SN-Signal-Conversion-Module-10CH-PWMPPMSBUS-32-Bit-Converter-for-FPV-RC-Model-Receiver-p-1423476.html
you could also use a arduino for converting the PWM signals to analog voltage and use that to control the motors.
@Daniel_Widmann I looked at that link but couldn’t find any commits; did you push them to github? Thank you
Just looked at it, and as the author said: To merge this in the mainline Ardupilot, I would need some support how to correctly integrate this into the Ardupilot
Additionally the code is 3 years old and it cannot be merged as the Rover structure has radically changed since.