It Takes Two Neurons to Ride a Bicycle (2004) 234 points by orenjacob on Jan 23, 2018 | hide | past | web | favorite | 87 comments

 This is a really easy read if folks are looking for easy-to-digest papers!From the results:> Although the two-neuron network controller works well for a range of speeds, one thing the controller does not do is to try to dampen the instabilities that can arise when riding too slowly or in too sharp of a turn. (This would probably require a third neuron that is dedicated to this task.)
 > There is not a direct or fixed correspondence, but as a general rule, during stable riding, a higher clockwise torque on the handlebars will cause the bicycle to start leaning more to the leftIt's counter-steering! I was glad to read that counter-steering is accounted for and works in their physics simulation like it does in the real world.I don't have a source handy, but I believe that there is a fixed correspondence between steering angle and the resulting turn that depends on the bike's speed, lean & steer. (And maybe tire radius counts too.) A bike riding in a stable constant clockwise turn will have a slight right lean & clockwise steer in steady-state. Steering clockwise from there will turn the bike left, or increase the turning radius until it's straight and then start turning counter-clockwise. Steering counter-clockwise from steady state clockwise turn will turn turn the bike right, increase the lean and decrease the turning radius.
 The fixed correspondence between leaning and turning is easy to derive on your own:Draw a picture of a leaning bike from behind. Add a horizontal line for the ground. Assume the entire bike/human system is leaning an equal amount, so put the center-of-mass somewhere in the leaning line.If the bicycle is maintaining a constant amount of lean, then the extended line of the force applied by the ground to the bike must pass through the center of mass (i.e. in this case the angle of the force vector is the same as the angle of lean).Now decompose the force vector into vertical and horizontal components. The vertical portion when riding on the ground (i.e. not jumping the bike), neglecting aerodynamic effects, is fixed to be the gravitational force, so it will be constant regardless of the direction of lean.This means that the horizontal portion of the force will be equal to the the gravitational force times the tangent of the lean-angle. This also means that when the tangent of the lean-angle exceeds the coefficient of friction between the tires and pavement, you will crash.The turn-radius can then be calculated by treating the horizontal force as the centripetal acceleration, and is indeed related to speed (faster speeds mean a larger turn radius).
 Yeah, that's a useful breakdown, thank you!Does this help to explain the fixed correspondence between steer and direction of turn? (For example, to someone who doesn't believe counter-steering is a thing.) The physics of the lean seems easier to decompose than the physics of counter-steering.I am interested in finding a way to describe counter-steering so that it's obvious, similar to the way you described the horizontal force vs coefficient of friction.
 If you are going straight at a constant speed and you turn the handlebars clockwise your front wheel is going to go to the right. The center of mass will want to continue forward due to the momentum of the bike. Now your bike is leaning left.
 When you turn the wheel, your wheels move to the right.Inertia keeps your center of mass moving straight, so your center of mass is now to the left of the wheels.Think of it as the ground pulling the wheels out from under you.
 Also, there is no fixed correspondence between turning the wheel and leaning, because in this case you do move your body. Think about when you are in a car and someone turns sharply to the right. At first you lean left, but then you unconsciously right yourself.Similarly on a bike, if you turn the wheel right, you will eventually either fall over, or turn to right (which will happen with an unconscious lean). Since the correction to lean-right is usually not done consciously, and happens very quickly most people don't realize there is an initial lean left.
 I nearly crashed the first time I rode a quad bike because, having had a motorcycle in the past, I instinctively tried to countersteer into turns.
 I had the same problem riding a racing course for quads. It was so bad, I couldn’t even finish the course, kept running into the walls.
 This is now my favorite scientific paper headline, beating out the previous champion, "How Many Birds Are There?"
 On the subject of birds, "Great tits also have age-related defects"
 Is this basically just taking a Fermi type estimation and making a paper out of it?I was just thinking that I like doing those sorts of calculations, and given that so many people on the Internet profess to hate them, there should be an exploitable niche somewhere.
 Do you have a freely accessible copy of this paper?
 In that case, if you lay outdoors with your mouth open, how long does it take until a bird ... in it? Depending on the worldwide bird density and the relative size of the mouth: https://what-if.xkcd.com/11/
 Does a Raspberry Pi have enough computing power to run these two neurons in the real world? Could I attach motors and sensors to a real bike and have it drive itself? That would be amazing.
 This is just a PID controller, they have existed and been used in industry much longer than computers and thus require almost no computing power at all. Everyone taking higher level engineering courses learns how to design these because almost everything uses them. Honestly I thought that the paper was a joke on how everything is called neural network, but maybe it is serious...
 It looks more like a cascade of a P controller (theta setpoint to gamma setpoint) with a PD controller (gamma setpoint to torque). But yeah, basically just classical control.
 Yes, except that there is also a threshold applied (sigma).
 Yeah, that was my thinking: how is this doing anything other than a PID controller? Glancing at the paper it actually looked like a PD controller, but maybe I missed some feed back where it could accumulate an integral term as well.
 I guess you can think of it as a "self-tuning" PID controller. It "learns" how to ride a bike.If it were really "just" a PID, you would need some arbitrarily complex procedure involving a human for tuning all the parameters?
 It isn't self-tuning, and it doesn't "learn."From the paper: "The three constants c_i need to be set by the implementor"Under "Future Directions": "One obvious thing to do with this system is to have it learn and tune its parameters with experience." The work presented in the paper does not do this."This network was designed in an ad-hoc, if traditional, way. First, a human tried to control the bicycle with the simulator. After many attempts, the human finally became a somewhat skilled operator of the bicycle ... the human at this point was able to describe the key parameters which were being attended to, and based on this, the two-neuron network was designed." By "designed," the author means "the three constants were selected."This sounds like the "arbitrarily complex procedure" you are looking for.
 So it's a PD controller.
 There's a whole body of theory on Adaptive Control (what the control systems community has called what we would now called "learning based control").This is one of the classic texts: https://www.amazon.com/Adaptive-Control-Karl-Johan-Astrom/dp...In short, many techniques that look a lot like modern machine learning have been in use for decades in control theory for tasks exactly like you describe (e.g. automatic tuning of PIDs). If you want to dig into this a bit deeper you might look up the "MIT Rule", which is a gradient style approach for dynamically tuning (and re-tuning) adaptive control systems, and is fairly common for PID tuning.
 I'm with you here. Did no-one else do robotics in CS?
 Unfortunately it's not a part of many curriculum. A lot of CS tracks seem to shy away from hardware.For contrast, the bioengineering track at my state college did include electronics (along with programming, high level math and of course biology and chemistry).
 I did as an undergrad, but I had to petition to take the class because it was considered graduate-level.
 Lot's of schools don't put robotics in CS. They put it in EE or ME. Computer vision is often a CS class, but control theory and other subjects that involve interacting with the physical world are often placed in other departments most CS students avoid.
 Funnily, I learned about PID controllers first while playing a Minecraft mod... but yeah, this definitely looks like one.
 Fun fact: PID controllers are embedded into the wiring of today's brushless hobby motors, the kind used for drones, for example. The last motor I dissected had a tiny little ATMEL 8-bit 1Mhz chip shrinkwrapped into the wires that controls the phase of the magnets that drive the motor, to make sure it matches the spin rate and make sure it doesn't skip or get out of phase. ATMEL published a whitepaper on the PID controller that says it runs the chip at around 10% load, meaning it could handle the PID calculations for 9 motors and still have some spare cycles.A Raspberry Pi is powerful enough to run hundreds or thousands of PID controllers simultaneously, depending on your sample rate.
 Do you have a link or a more-searcheable term? This sounds like a fantastic rabbit hole to do down, given I spent a significant proportion of the last week tuning PID to run well at very low motor RPMs... (have a look at the repos for the hardware and firmware for the VESC motor controller for some fun: https://github.com/vedderb)The problem with Pis is going to be that running Linux they're at best soft real-time. Sampling, PID, etc needs hard real-time.
 I just looked for "atmel brushless motor control" and got this, which looks similar to the document I read before, but it's for the atmega32 instead of the atmega8:https://www.researchgate.net/profile/Mohamed_Mourad_Lafifi/p...I can also see a ton of PID controller projects on various microcontrollers searching for pid and brushless controller and esc and motor controller and things like that.
 Thanks. I was specifically intrigued by your description of the microcontroller inside the motor, thinking it must be just for sensing and PID control, since unlikely it would have enough room to do the actual power drive. That Power Stage Controller is interesting, but somewhat obsolete since everyone's moving to Field-Oriented Control now, which requires a lot more grunt than an 8-bit micro.
 Not surprising, given that we had mechanical PID controllers working with extreme accuracy (steering a ship in severe weather) in 1922.
 If by drive you mean not fall over, yes. If you mean actual routing, avoiding collisions and reacting to unexpected situations, very much no.
 No, because the model described in the paper only works for an extremely simplified toy simulation of a bicycle, not a real bicycle riding on a real road that is not a spherical cow.
 Yes of course. But if your goal is to make a robot bike there are better algorithms than this one.
 Nice paper. It makes me wonder how different the two 'neurons' are from a classical control theory set of equations (w/ gains in a feedback loop) solving for the same plant model.I do love the visualization of "Instability of an unsteered bicycle" in figure 2 though.
 I have some minor background in control theory. After going trough the paper I had a very same thought thus I googled and found this: http://www.control.lth.se/media/Staff/KarlJohanAstrom/Lectur...After checking out the slides I kind of feel that there might be some oversimplification in the used simulator, like producing _the desired lean angle_ might not be enough. But I am no expert.
 I give the authors a little bit of a break because they're sort of more thinking about the meta problem of how to build an automated system to create a controller. From that standpoint, the original paper is more introducing the early landscape of the problem and documenting some early stabs at it. Introducing the question of how to get that automated derivation to arrive a simple set of end controls for the system as simulated.
 Looking at the roads it seem like driving cars is taking no neurons at all.
 I wish math notation becomes substitued with pseudocode. I can never figure out all the greek letters!
 But then it wouldn't look as "scientific" (i.e. anyone could understand it, it wouldn't look complicated). At least that's what I feel like, reading and writing a bunch of papers for my master's. We are encouraged to put math stuff in ours just because it looks more theoretical that way. Whenever I do something of worth I also make sure to blog about it so I can write down in normal terms what we did and found, with code, (online) demo, and anything else that might be useful.
 1) Sometimes it's actually helpful to use greek letters when a convention is used. For example: capitals for matrices (A), lowercase for column vectors (a), and Greek for scalars (α).2) I agree with the gist of your point, but I'm guessing you're being down-voted because you come off as sort of flippant. Anyhow, I've long thought that mathematics should have hover-text to help remove the mental overhead of translating the concise notation to meaningful interpretation. Obviously, using variables names like `velocity_of_thing` is much too verbose in mathematics (papers would 1000's of pages); however, β with hover-text "This is the velocity vector of the thing." would be super helpful IMO.
 Just the other day I spent a solid 30 minutes trying to distinguish between I and Iⱼ in an equation of motion. Turns out that the former was the identity matrix and the later was the inertial matrix of body j.If there's a way to add that sort of hover annotation in LaTeX, I'd gladly use that for my thesis.
 It seems there is a method to add tooltips, though it looks a little rough. Worth a shot, I suppose. https://tex.stackexchange.com/q/155518/77180
 > Obviously, using variables names like `velocity_of_thing` is much too verbose in mathematicsThat is not obvious to me. Perhaps in a purely mathematical paper with dozens of formulas, but that's not my field of study. In any paper I read of any discipline, I never came across any paper filled with enough formulas that it would make sense to compress at the cost of clarity.I fully agree, though, on following conventions (that only conveys extra context) and using hover text to act as a quick lookup function. I actually looked for the latter in the past but couldn't find a way to do it in LaTeX.
 It's like programming languages: people want loud syntax for things that are new, but short syntax for familiar concepts.Math is heavily optimized for peope already familiar with the topic at hand. In many cases, that's the only way you have a chance of understanding the paper at all. So long names would just be noise to the main audience of the paper.
 > I never came across any paper filled with enough formulas that it would make sense to compress at the cost of clarityFair point, but with this approach, even simple formulae could really clutter up a page if the variable names are long and descriptive (imagine just a rational function!). Also, as with programming, folks might abbreviate (e.g., `vel_thg`) and then we're nearly back at square one.
 Also in programming, when my girlfriend (the mathematician[1]) used single letters in code and I helped her with the coding part of it, she had to remind me what some letters stood for. With acronyms or abbreviations I might need to ask a first time (or maybe not even that, especially if you put a comment with the full version upon declaration), but it's definitely easier to remember what is what.But anyway that's programming. Papers are a little different of course, with limited space so usually there are no big code parts with declarations and comments. Which is also why I like blog posts: things are clickable and interactive. A PDF is super static and you can't expect a reader to click through to the code or to be able to zoom in.[1] well, she claims not to be, but from my POV it's math even if she says it's a subfield.
 Is there a standard notation that can produce both? I don't know much LaTex but I don't think it holds sufficient information. Does MathML maybe?
 The MathML standard is split into two parts, Presentation MathML, which is widely used and contains roughly the same information as TeX, and Semantic MathML which is used by a handful of computer algebra systems. The latter does what you want.Both formats have their origins in Wolfram Mathematica.
 Somehow I never considered hover-text for math. Now I'm actually rather angry that it's not already standard, what with papers being distributed digitally. Keeping track of notation when reading papers is the bane of my existence.
 I got the same feeling while I was still in university. I mean if the mathematical notation would at least make it more concise, because there are definitely computations which are easier explained using this notation.But more often than not I look at papers, where I know what they were doing and how and just have to ask myself: Why would you go through the work of translating what you did back into formulas, which bring exactly zero benefit and are harder to understand than the code you wrote?!
 I'm old enough to have never been tested for dyslexia, because I scored high in average tests..But come high school years, or in British sixth form studying for"A levels", I scored in the top decile for my class and for Applied Math, but the bottom dectile for Pure Math.I think you can make a very good argument that math notation is not doing the potentially career changing job it could be doing, by not expanding the keys. Darn, even a key table index alongside would be night and day better. Edit - didn't remember the length of my comment after coming back to it after a break, so culled the excess. The punchline was that when we got a new young and enthusiastic Pure tutor, who was French, so he in true anger would explain to us in great eloquent depth, my marks equalized in two semesters.There's surely something like a formal study of students to show if comprehension is the main reason math is hard?
 At the level of arithmetic, there are studies of children performing math in the marketplace, but then being unable to do the same calculation on paper. So translation from notation to reality (and back) is probably a significant barrier to success in math.
 It would be great to have a website where the writers of the paper, or well, anyone who understood it well, would write an article about it in a more accessible way with some examples included etc. I am a big fan of blogs explaining such things.
 Checkout https://blog.acolyer.org/
 That's an interesting idea! Might be something indeed.
 > We are encouraged to put math stuff in ours just because it looks more theoretical that way.If that's really true, you are getting bad advice.
 Would you mind sharing your field of study?
 Security, software and network engineering. (Previous study was software and security, this one is security and network; and I've always liked to play with tech in those three subfields.)
 Ya science has this way with needing to look and seem self important. Or at least the scientists reviewing journals.
 Then we would just have a bunch of mathematicians wondering what some of the function names meant, since English isn't always definitive of obvious in definition (not to mention the non-English speakers who have to learn a combination of symbols instead of one).All you're really doing is substituting something you're unfamiliar (or less familiar) with, common mathematics symbols, with something you specifically happen to be more familiar with (programming pseudocode).It's really no different than someone looking at your pseudocode and saying "why can't they just write it in plain English?"
 Then maybe something that can translate math notation to pseudocode and back?
 I often feel the opposite. Pseudocode makes me lost.Ideally, you'd have both. The clean math notation AND pseudocode.
 Or at least spell them out like lambda
 This sounds a whole lot like a Braitenburg vehicle [1] and I was surprised the author did not cite and compare/contrast Braitenburg's work.
 I loved that diagram titled "Instability of an unsteered bicycle"
 There are no secrets to riding a bike:1. Do no try to go straight. Move the handlebars violently left and right when you feel you are falling left or right.2. Going slow is hard. Go fast. The wheels spinning will behave as stabilizers, making it easier to stay on the bike.3. Moving your body will make you fall at first if you do not counteract by moving the handlebar. Start by going downhill, without pedaling.
 The two "secrets" I know to riding a motorcycle are (1) not leaning on your arms, and (2) consciously countersteering.Seems like a lot of people I see on the street never learned how to countersteer and turn or change lanes with alacrity.
 > (1) not leaning on your armsI can already guess an answer to this, but would you mind expanding on it anyway? I tend to do this on my bicycle a lot.
 Well, I was told not to in the course I took to get my license, and I found it helped without really thinking about why.However, if I try to introspect...supporting my weight with my arms tends to conflict with the counter-steering part. If I push on the left side, the motorcycle leans that way. But one instinctively pushes on something to hold oneself up. So I think I would say my brain gets subconsciously conflicted over whether to push or pull.Unfortunately, sport bikes typically have a seating position that makes it very difficult not to put weight on your wrists unless you have good leg and abdominal muscles.
 2. is the correct outcome but not the correct explanation. The real explanation is that turning inputs have a greater effect on balance at high speed. Turning input directly relates to turning radius, which, when combined with the square of tangential velocity, gives centripetal acceleration. This centripetal acceleration is used to counteract an imbalance of the body/bike system.Basically, the faster you go, the easier it is to influence your balance on the bike. If you go fast enough you can get too much influence, which is how speed wobbles happen.
 I don't think I've ever heard about somebody which knew how to ride a bike after just reading some text :)
 Why would you expect that?
 > The wheels spinning will behave as stabilizers, making it easier to stay on the bike.Bicycle wheels do not have enough mass to impact handling through gyroscopic inertia. They do not act as stabilizers.Motorcycle wheels do, and consequently they require more effort to lean at higher speeds as well as require additional lean when accelerating into a curve.
 Gyroscopic forces are not the dominant force keep a bicycle upright, this has been demonstrated with bicycles with counter-rotating wheels. Steering geometry of the front wheel is what self-stabilizes a bicycle.
 It's not just one thing. At different speeds there are different things that help you stay balanced. At low speeds, yes, what you do with the handlebar and so the front wheel is predominant. At higher speeds gyroscopic forces do not actively keep you upright, but they help by slowing down the speed with which you loose you balance and so you have more time to react (by steering).
 (2004)
 Unfortunately, the videos linked in the paper seem to have disappeared. Are these mirrored anywhere?
 They work, but the tilde character in the pdf is wrong. Try this: http://www.paradise.caltech.edu/~cook/Warehouse/RecursiveBik...
 Thanks! A moderator updated the title.
 code?
 does anyone recognize what software was used during this study