Fast line-following robots
207 points by a1k0n 6 years ago | 26 comments- bananasbandanas 6 years agoThere is a similar competition in Germany called the CaroloCup. Here is a video of our run when I was still a student [1].
We used model-predictive control which evaluated about 10k trajectories with look-ahead, which works really well even when tires begin to degrade after a few minutes. You can see the effects in the video towards the end, where the car starts to slide, but the controller manages to catch it in time.
Our CV was a bit more complex as we had to deal with missing line segments. We pre-processed the camera image with a distance transform, then used an optimization pass written in opencl to fit a 3rd-order polynomial to the image.
- a1k0n 6 years agoNice! Are you doing probabilistic roll-outs, iLQR, or SQP, or what? What does your model look like? I've been struggling with this -- not sure how complex the tire dynamics model needs to be, for instance; do you need the whole Pacejka magic formula or is tanh() good enough?
- bananasbandanas 6 years agoWe opted not to use a tire model at all, because we weren't sure how well something like Pacejka would transfer to model-size.
Instead, we built an empirical transfer function from (target yaw rate, speed) -> steering wheel angle. To get to this function, we measured the yaw rate during a steady-state circular test at different speeds and steering wheel angles. Then do some kind of regression to get a continuous function. During the test, also eyeball when the tires start to slip, then use this to limit max lateral velocity.
Of course this does not take into account changing tire conditions at all. We thought about estimating the slip angle from CV or using controller oscillations as indicators, but never got around to it.
- gugagore 6 years agoDo you know if there's work on adapting to the vehicle dynamics on the fly? The comment about tires degrading made me thing that there should be some parameters in the model corresponding to how degraded the tires are, and instead of relying purely on feedback to correct for model-mismatch, you could try to get a better model on the fly.
- a1k0n 6 years agoI'm aware of one paper which tries to fit a local polynomial model to the lateral dynamics, and they have a different model for different positions on the track (it requires really good localization to work): https://arxiv.org/abs/1610.06534
I had some of the vehicle parameters as part of my EKF for a while, but it led to some instabilities in the control.
The main problem is that it's really hard to know what the car's instantaneous lateral velocity is. I think the best you can do is check the difference of velocity*gyro yaw rate and lateral accelerometer measurement to get a noisy lateral acceleration measurement, and that can tell you how well your tires are hooking up. I might try fitting a least-squares model on the fly with something like that.
- a1k0n 6 years ago
- bananasbandanas 6 years ago
- a1k0n 6 years ago
- a1k0n 6 years agoDidn't mention it in the post, but info about the car hardware and all the code is at https://github.com/a1k0n/cycloid
- drivers99 6 years agoThis is really inspiring. I played around with converting an RC car to self-driving with an arduino but it was very simplistic. It used an ultrasonic sensor (Parallax "Ping)))" sensor) to try to keep a specific range of distance from a wall to its left. It wasn't aware of its angle so it had a positive feedback loop in its reactions which caused it to oscillate more and more out of control. Just knowing there are people are there playing around with this for fun makes me want to get back into it.
- a1k0n 6 years agoI think just adding a simple low-pass filter on your distance measurements and tracking the derivative for PD control would cure that problem. Try it!
- sgillen 6 years agoCan also put two distance sensors on and fet the angle using some trig.
And when you’re ready to get a little more serious you can get an imu and gps. Maybe even get a more beefy computer and add a camera!
- drivers99 6 years ago> Can also put two distance sensors on and fet the angle using some trig.
That is exactly what I was planning to do next. I realized that when the angle was greater, it would see the distance to the wall as higher than it really is, because of trigonometry. And that is a positive feedback loop which makes it worse. (I just realized that is only true when it headed towards the wall at an angle, but is the opposite when heading away from the wall at an angle. It reacts later (steer right) when it's angle towards the wall, but it should react sooner (steer left) when it's angled away from the wall... hmm...) Getting the angle, I could set a target angle and distance together, and steer as needed.
- drivers99 6 years ago
- a1k0n 6 years ago
- elwell 6 years agoWow, really the best email address spam protection method [0]:
[0] - bottom of OP's homepage https://www.a1k0n.net/_=0;k;main(){while(_<641){for(k=0;"##K#8(38D-##C]L5870.X7\\M_b;90\\" "MC-M/NZGB6Q,I0VGB6a0FbN<VG.6Q\\bNb7^@`X=N@`XQaOVX:^]NX=:Z8PY]B`:>P" "NY8^$#SM):XA"[_/6]-35>>_++%6&1;k++);putchar(k[" _/\\\n,`)('<-"]);}}
- a1k0n 6 years agoHeh, you can just click on it to see the result if you don't want to actually compile it.
- elwell 6 years agoPretty cool. Works here too: https://www.onlinegdb.com/online_c_compiler
- elwell 6 years ago
- a1k0n 6 years ago
- adrianN 6 years agoA similar discipline is Micromouse, where robots have to solve mazes and then race the path they found.
- hobolord 6 years agoThis is great, I did a robotics course in uni that was essentially this. We never took it further than PID control though. https://www.youtube.com/watch?v=oDqfKm4Ovcg
That was a fun time in uni
- bufferoverflow 6 years agoWe did too. Had to use Lego Mindstorms. It was a pain in the a$$ to program back then.
One of the guys built a very fast line-following robot, much faster than what we see here. It was simpler though, it was a solid black line.
- berti 6 years agoI remember having to do the solid black line with a couple of photo-diodes and a small AVR in first year EE. Was kind of a neat project thinking back, but we all hated it at the time because it soaked up quite a lot of time tuning it aggressively to beat everyone else without losing the track, going back where you came from, etc!
- hobolord 6 years agoluckily ours was arduino-ish and pretty simple to program. But we had to built everything since it was more of a mechanical + electrical design class, so there was lots of machine shop time
- berti 6 years ago
- bufferoverflow 6 years ago
- cmontella 6 years agoVery cool! We ran a competition like this once for undergrads: https://vaderlab.wordpress.com/roscar-robot-stock-car-autono...
It had to be a little more complex than line following, because at one point in the track there are a bunch of line crossings. So you had to do some mapping and tracking too in order to stay in the right lane.
It's really fun seeing how fast you can make them go. One team maxed out the speed on the platform.
- TaylorAlexander 6 years agoAwesome post! I really need to attend the robo cars event. I’m working slowly on my own autonomous robot:
- a1k0n 6 years agoYeah, come check it out, it's pretty fun! https://www.meetup.com/DIYRobocars/
- a1k0n 6 years ago
- msadowski 6 years agoThat's super interesting! How do you generate those canvases showing the algorithm behaviour? I think such animations could be very useful for teaching PID tuning.
If you don't mind I would love to add this article in my next WeeklyRobotics (https://weeklyrobotics.com/) issue.
- a1k0n 6 years agoThe canvases are just some javascript code which draw to the 2d context after a requestAnimationFrame(): https://www.a1k0n.net/js/steering.js
Sure, that sounds good!
- a1k0n 6 years ago
- Already__Taken 6 years agoLooking forward to seeing this thing remember the line each lap and refine its curve. At that point you're then working on traction control problems wouldn't you?
- a1k0n 6 years agoYes, that's the current state of the car. It's constantly fighting for traction; there are some lower-level control systems trying to maintain yaw rate (which automatically does things like counter-steering in a drift). I'll get to that in a future post.
- a1k0n 6 years ago
- SubiculumCode 6 years agoThis is pretty dang cool, imo.