Introduction
A few weeks ago I had a crazy idea to make an autonomous RC car. I've been working on it for a while, so I figured I should start writing down my experience. I'll start with this general overview of what I've done so far, then provide updates or deep dives in later posts.
Goals
- The car navigates itself around a course set by waypoints. It has some way of knowing its location, I have some way of setting the waypoints, and I have some way of telling it to start and stop.
- The car should drive around the course as fast as possible. It should be able to handle and anticipate understeer, oversteer, and wheel slip.
- Obstacles are not a concern. I want to focus mainly on control of the car, not on the dog that runs out in front of the car. For that, I will need a way to take over manual control of the car at any instant.
- I do not want to rely on machine learning or computer vision for the primary means of control.
- I want to build as many of the components myself as possible - both electronics and software. I don't want to just go out and buy a flight controller and adapt it to my needs.
Background
As a teenager, I was into RC cars. I had a Team Associated RC10T. My buddies and I would just bash our RC cars around the neighborhood. I made some good memories through the hobby and I learned some things, but my interests eventually moved on. That was 25 years ago, and up until a few weeks ago I hadn't held a "real" RC transmitter since the day I put away my teenage toy.
But to make an autonomous RC car you first need an RC car, so I went out and bought a Traxxas Slash VXL. I had forgotten how much fun it is to drive these things! There were a few days when I nearly forgot about my goal and was just having fun driving the car. I also learned that my dogs love to chase the car - it's a great way to get some energy out of them.
Electric Circuits
So now that I had the car, I needed to learn how its electronics work. I knew the roles of the radio, ESC, and steering servo, but I wasn't entirely sure what happens on those 3 wires of servo cable. With a little bit of research and my multimeter I learned that I was dealing with 6V PWM. Oh no, that's a different voltage than my Arduino!
Electric circuits are not my strong point. Back in college, electrical engineering 101 was enough to convince me to not major in computer engineering (I switched to computer science). Don't get me wrong, I understand the difference between volts and amps, and I'm handy enough with wiring around the house - I've previously wired up a shed and installed a subpanel, rewired the lighting system on my motorcycle, and had tinkered with some basic circuits controlled by an Arduino. But dealing with different voltages in the same circuit was beyond me.
I struggled for a while, and I learned a lot. I discovered voltage level shifters and voltage buck converters. I learned how to use NPN and PNP transistors along with resistors to translate between different voltages. Then I discovered the world of integrated circuits and how they could eliminate all of those discrete transistors and make my life so much easier.
I think I'm finally over the initial hurdle of building the electronics and reading and writing the PWM signals. My board is powered by the car battery (via the ESC), I can read the PWM signals from the radio, and I can write PWM signals to control the steering servo and ESC.
Separation of Powers
I'm hopefully better at coding than I am at electronic circuits, but even then I don't trust myself to always write perfect code. It's only a matter of time before my code locks up the microcontroller or sends the car in a very unfortunate direction. In those cases I wanted to have a completely separate microcontroller that just has one job - to act as a "kill switch". By flipping an auxiliary switch on my RC transmitter I can transfer control between autonomous control and manual control.
The kill switch reads the PWM signal of the auxiliary channel and accordingly sets the select pin on a multiplexer. The multiplexer is what determines where the steering and throttle PWM signals are coming from. As long as the kill switch functions correctly (it's only about 40 lines of code) and the multiplexer does its job (there's no code on it, it's just hardwired silicon), then I should be able to take manual control of the car no matter what my navigation controller is doing.
GPS RTK, LoRa, and Bluetooth - Oh My!!!
I'm good at over-complicating things.
I decided to first try using GPS for positioning of the car and the waypoints. I quickly realized that any old GPS receiver wasn't going to be accurate enough for my needs. With a NEO-6M receiver and a basic small ceramic antenna, I was getting about 4 meter accuracy at the best of times under a clear sky. It was frequently off by more than that. For the courses that I have in mind, I think I'll need accuracy of about 1 meter.
Next I looked into Ultra-wideband (UWB). It's a somewhat new radio technique which, in addition to transmitting data, is apparently pretty good at positioning. It is currently being marketed for indoor positioning, with a range of 30 meters or so. Basically you have a collection of base stations scattered around at known locations, and your rover does triangulation to compute its location within a claimed 10cm accuracy. That's accurate enough for my needs, but I had a lot of trouble finding a developer kit that was affordable and in stock. I also wasn't super keen on having to setup those base stations every time I wanted to test out the car.
When I contacted Adafruit to ask whether they had any UWB products, they informed me of GPS RTK. I did some research and it looks perfect! (Albeit a bit pricey compared to normal GPS receivers). They claim 1cm accuracy - more than accurate enough for my needs. Nearly all of the information that I found on GPS RTK comes from the land surveying and farming industries, but apparently it's now popping up in some quadcopters as well.
Here's the catch - to get that level of accuracy, it needs a constant stream of RTCM data coming from some nearby base station. You can either create your own base station, or you can jump through some hoops and use some semi-public base staitons that are scattered around. And you need some way of getting those bits to the receiver. WiFi and Bluetooth are options, but they are somewhat short range and have high power requirements.
LoRa is a long range, low power radio signal, with a claimed signal radius of somewhere around 10km to 10 miles. One catch is that it's really slow using the default parameters that will yield that range. The RTCM data stream needs around 500 bytes/second, and when I first tried it out I was getting nowhere near that rate. I changed up the parameters and I'm now getting around 2400 bytes/second. I don't yet know how this will affect the range, but I figure I'll never be more than about 100 meters from the car, so hopefully it's enough. Another issue is that it's just a radio physical layer - there's no MAC layer, so interference is a concern (LoRaWAN provides MAC, but also enforces a lot of extra constraints like airtime limits, which I would exceed). To deal with potential interference, I added SHA256 HMAC signatures to my radio packets to ensure that I'm only receiving my own radio packets.
Now I needed some way to configure the car - to set its waypoints, calibrate the steering and throttle, etc. While I could technically do this using LoRa, that's a pain since it needs some sort of relay device with a LoRa radio. Instead, I decided to add a Bluetooth Low Energy radio directly on the car. I figured it may also be helpful in cases when I don't want to use the LoRa radio to transmit the RTCM data for some reason (e.g. to avoid signal interference), and when range isn't a concern.
Add it all up and I am adding 3 radios to the car (a GPS receiver, a LoRa transceiver, and BLE) and 3 microcontrollers to the car (the navigation controller, the radio controller, and the kill switch). This is in addition to the car's radio, so that's a total of 4 radios on the car. Add on the LoRa relay that I made with another microcontroller, and my smartphone which pulls the RTCM data from the internet via LTE or WiFi and sends it out to the LoRa relay via Bluetooth. That yields 6 different radio signals and 4 microcontrollers (plus the microcontrollers on the car's transmitter and receiver).
Current Status
Here's what's working:
- The kill switch works. I can manually control the car with my device intercepting the PWM signal.
- I can do a simple proxy of the steering and throttle PWM signals from the inputs to the outputs via the navigation controller.
- I have a working communication protocol between the navigation controller and the radio controller. It's a custom request-response protocol over a serial connection for things like fetching the current GPS coordinates, calibrating the PWM signals, setting waypoints, etc.
- I implemented a ping between the LoRa relay and the LoRa radio on the car. This allows me to find the bi-directional RSSI to verify that the LoRa radios are working.
- I can transmit RTCM data from my phone, via the LoRa relay, via the radio controller, via the navigation controller, to the GPS RTK receiver (that's 4 hops after the data reaches my phone from the internet).
- I also have a 9DOF IMU onboard, and I can read the linear acceleration, angular rotation, and direction, but it's not yet calibrated.
- I have a working physical mounting solution, but I may change it up a bit.
These are my next steps:
- I'm adding a wheel RPM sensor, and a better GPS antenna which can receive multi-band GNSS L1 and L2 signals (required to get that 1cm accuracy).
- I need to save the servo calibration and IMU calibration to the onboard flash storage so that the device stays calibrated between power cycles.
- I need to build out the Bluetooth interface to the car. I'm trying to decide between building a simple command-line interface where I can use a basic Bluetooth Serial emulator on my phone, or building a JSON interface where I need to build an custom Android app. I've never made an Android app, but I think this could be a lot of fun.
- I need to implement some kind of sensor fusion algorithm. This will merge the data I'm getting from GPS, the IMU, the RPM sensor, and steering and throttle outputs, such that the car has a good estimate of its state of the world at all times.
- And of course, I need to implement autonomous navigation. I'll probably start by just controlling the steering autonomously, and continue relaying the throttle signal from the RC transmitter.
Still, the potential income has been a big promoting level for legalizing sports activities betting in lots of} states. From that perspective, cell choices appears more likely to|prone to} increase. In this instance, winning bets will not pay off until the conclusion of the Super Bowl in January or February . Odds for such a wager generally are expressed in a ratio of items paid to unit wagered. The 카지노 staff wagered upon could be 50–1 (or +5000) to win the Super Bowl, which signifies that the wager can pay 50 instances the amount wagered if the staff does so.
ReplyDelete