Challenge: horizontally / inertially stabilize a pizza on motorcycle

I'm new to arduinos and looking to dive into something challenging. I study mechanical engineering, but my roommate is a computer scientist so I have a little help. The challenge is just like it sounds: horizontally / inertially stabilize a pizza, in a box, on the back of a motorcycle. Today I started to do some research and came across a lot of people building Segway robots using an accelerometer, gyroscope, motor controller, an arduino UNO, and software based on the kalman filter. I started to wonder what would happen if the Segway was mounted sideways to the back of a motorcycle instead of on wheels? Would the robot maintain its stability? What if we added 30 lbs of weight and fast turns?

This had a lot of great information about kalman filtering and using accelerometers. Someone already built a 3 axis stabilizing platform.

Right now I'm trying to price the arduino and additional hardware out, what size a motor i woud need for a 20 lb box, and see how much programming I can find rather than beginning from scratch. I'd like to be able to make this thing as cheaply as possible.

Sounds intriguing. Please take a video of your initial testing and post a link to it. :slight_smile:

I'm not too worried about the weight sloshing around. It's only twenty pounds, and if needed we can just put the pivot point at center mass of the pizzas which would make any movement unnoticeable to the rider.

You are correct that motorcycles lean to overcome centrifugal force, but a motorcylist can also lean his/her body for the same effect. The ideal angle for the pizza/the angle for center mass, would then be somewhere between the bike and the rider. Sometimes the bike is leaned more than the rider. Sometimes the rider is leaned more than the bike. The pizza on the back is sloshing around the whole time.

Also think of it this way: You have two pizzas. Pizza one is riding along in the passenger seat of a car. Pizza two is on the back of a bike. Both vehicles go through a turn at the same speed. The pizza in the car made it. What would you expect to see inside the pizza box strapped to the bike that was leaning through the turn?

Second scenario, same situation, except that the pizza on the back of the bike remains at the same angle as the pizza in the car. Pizza in the car survives. What about the pizza on the bike?

Here's two home made gyro cams operating on the same principle. THe first one is just made with a servo that has a gyro in it, designed for RC airplanes and quadcopters. In the air im sure a quadcopter isnt pulling any G's, but on the bike you can see that the camera moves freely from the bike, yet the horizon leans a little with whichever way the bike is turning, I'm guessing at the angle for center of gravity. The second one does a surprisingly good job of staying perfectly horizontal. I wouldn't be surprised if some of that was fixed in post.

I think with an accelerometer you will be able to sense a tilted direction as the "true horizontal" when your motorcycle is turning.

I think oric_dan is right. Keeping the pizza horizontal during a turn is going to create a net force on the pizza and toppings toward the outside of the turn. One way to look at it: Imagine looking down from above and tracing the path the pizza makes during a turn. It's going to be an arc, correct? And that means a change in direction and hence acceleration. Now imagine tying a string to the pizza box and whizzing it around you in a horizontal plane. How will the pizza fair? What you want to do is make it so the direction of the total force on the pizza is orthogonal to it's plane. Just like gravity usually does.

Do you need an Arduino?

Won't this work: Gimbal - Wikipedia?


What you want to do is make it so the direction of the total force on the pizza is orthogonal to it's plane.

Which is more or less what happens if the pizza box were rigidly attached to the motorcycle
frame, such that it's horizontal when the m/c is straight up and down, rather than being
"actively stabilized".

Exactly. I was hoping the OP would realize that. In fact his idea would work better for a car which doesn't significantly lean into a corner, which is the opposite to what he's thinking. I wonder if any university has ever obtained government funding to research "Topping Drift on a Pizza En Route"

I'm too lazy to quote people directly but just a few things, and let me just say that I do like the input. I'm gonna take a couple wild guesses here:

  1. There's no way for a topping to fly off of a pizza. Just going on the observation that cheese isn't actually goo and crusts arent actually glued to the box. When a pizza box is tilted too far, the pizza slides and crumples in a corner. The toppings don't just all pop off.

  2. No pizza has ever been decimated by a car ride in the history of car rides OR pizzas. The pizza-en-route-via-car scenario is the ideal pizza delivery situation we're attempting to recreate on a motorcycle. Also because a horizontally stable platform on a motorcycle is awesome and could be used for a number of things. Large camera rigs, carrying potted plants, etc.

  3. The net force is not orthogonal to the lean angle of a motorcycle. In theory, yes. In practice there's a rider on the bike and that rider is never leaning at the same angle as the bike, so while a motorcycle does lean to overcome centrifugal force, you can lean off the bike for the same effect. Or if it's a tight, slow corner, you can just lean the bike and sit upright, as is what we're expecting to happen most-often. Plus I'm guessing it's the constant adjusting of lean angles that throws the pizza around.

  4. I don't know if an arduino is necessary. I only know that it can be done using an arduino... and an accelerometer, a gyroscope, a motor, motorcontrollers, c++, kalman filter, and some other stuff I don't know about yet.... But if a handful of people can post videos of their two wheeled robots, segways, gyrocopters, and gyrocameras, all using the same tech, I think that this project can be done.

We're trying to prevent a pizza from crumpling into the side of a box when the bike is tilted at up to a 45 deg angle.

  1. We're also trying to make a horizon-locked platform on a bike because it's awesome and if we try, we can.

  2. The net force is not orthogonal to the lean angle of a motorcycle. In theory, yes. In practice the rider is never leaning at the same angle as the bike.

Lateral forces (the ones you want to reduce) will be greater if you keep the pizza parallel to the horizon than in case where the pizza follows the leaning of the motorcycle.
You do not want to keep the pizza horizontal, unless the bike is stationary or cruising (but in that case there is no leaning).
I'd keep the roll axis fixed, but compensate for pitch, because it is breaking that produces uncompensated acceleration.

I wouldn't lock either axis if it can be avoided, but braking and throttle are definitely a lot easier to modulate by the rider than keeping the bike perfectly angled. The biggest thing I think will be the shorter, stiffer suspension on the bike, ie potholes, speedbumps, dips, etc. I havent thought of a good way to allow movement in 3 axis, apart from just suspending the thing on springs. For now I'll just worry about roll.

I'm much more of a motorcyclist than I am a physicist. This project to me seems like a great way for me to learn. If someone can help me figure out all the parts I need so we can get this whole thing built, we can test out everything in reality instead of just talking about it on the forums. I'm excited to work with arduinos and everything else.

But roll is the least of your worries.

Why don't you take a bowl of some kind, put some thick paint in it and take it for a ride. Fix it firmly in a way that when the motorcycle is upright the paint stands still. Ride normally as you would around the block, with stops and starts, left and right turns and see which way the paint drifts. My bet is that most will go forward, some will go backward, and very little left and right.

Not only it is a (semi-pseudo) scientific experiment, it's also an excellent excuse to go for a ride.

I love the idea of taping a sloshing bowl of paint to the back of my motorcycle but why not just just use an accelerometer/g-meter? I can just download an app on my phone. Or better yet, why not build a g meter using an arduino and accelerometer? That's pretty much my plan already. I'm just hoping one of those geniuses that built a stabilizing gyrocopter, or a gyro camera gimbal, or a two wheeled balancing autobot can guide me in the right direction since the selection of hardware available is quite overwhelming. Also existing software would be a great time-saver.

Lol ok seriously, can someone just help me with a parts list? There's like 20 accelerometers to choose from. I also need a motor controller, gyro, shield or other components to put it all together.

Lol ok seriously, can someone just help me with a parts list? There's like 20 accelerometers to choose from. I also need a motor controller, gyro, shield or other components to put it all together.

Your location information is missing from your forum profile. I can make recommendation to a simple accelerometer but the shipping will be expensive if you are not on my part of the world.

You can actually forgo for gyro and here is why. The gyro will only give you changes in rotation rates while the accelerometers will only sense acceleration. I severely doubt that you could turn a car or anything fast enough to harm a pizza, and compensating for this rotation would require the use of a controlled turntable which while awesome would be VERY hard to build.

Instead you just need to compensate for linear accelerations including that due to gravity. With a 3-axis acceleration mounted to the pizza carrying frame one only needs to write code that tries to keep all of the acceleration in the Z-axis. When you are sitting still it should see 1G straight down and no X or Y acceleration. Thus it will orient the sensor and thus the frame so that straight down matches with the direction of gravity. If you accelerate hard the chip will see the 1G of gravity plus the say .5 G of +Y. The combine to form a net force vector that is 63.4 degrees bellow horizontal and it should rotate to shift this net acceleration so it is centered on the Z axis (90 degrees below horizontal) The gyro would be unnecessary to tell you if this acceleration was due to a linear acceleration of the vehicle or a forward tilt of the vehicle. The forward tilt can cause the same acceleration reading by shifting gravity to the Y axis. However because both of these eventualities will affect the pizza identically you do not need to differentiate them.

You don't need a gyro only a 3-axis accelerometer
Write code to keep net acceleration vector aligned with Z-axis (PID might be good here)
You don't need Kalman filters as you won't have gyro data.
It's likely easier than you once thought.

Good luck, sounds like fun!

I guess I am also one of those people that doesn't believe that a microcontroller is the solution for everything. Add me in for the gimball. A well balanced, bearinged and weighted gimball will react a million times faster than any closed loop micro/motor/sensor could ever respond.

I should really clarify my previous post. When I said the a doubted a car could turn fast enough to harm a pizza I meant purely rotationaly. Imagine a pizza rotated about the middle so that it spins around. Now imagine how fast one would need to spin this pizza or how hard one would have to accelerate its rotation to do it any harm. I would imagine that it would need to be quite fast, and while his driving is amazing the maximum rotation rate is likely not in excess of 180 degrees a second. Not near enough by itself to harm a pizza.

The issue is the sideways g-force that is generated in the turn. This defiantly would harm a lowly pizza, but this sideways force is something the accelerometers can sense and your platform can realign to be straight down relative to the pizza. As far as the pizza is concerned gravity just got a bit stronger, but any sideways force is countered by the force of gravity which is no longer straight down on the pizza.

A well weighted suspended platform could work well and would be simpler, but without damping you could get oscillations at its resonant point that could harm the pizza too. After any sudden stop you would get a swing-set effect. Damping would help, but it would also slow the response to a sudden impulse. Good gimbals with a pair of positional servos could likely react faster than a simple pendulum without any noticeable oscillation. I would bet your main sensing loop could run at least a few hundred times a second making the system very low latency. The limit would be the maximum rotation rate of your servos, but they can be quick as well. Without the motor the platform is essentially a proportional controller. If you do a little looking into controls theory you will find why a proportional, integral, derivative controller (PID) would result in faster rise times with much less oscillation.

I think the biggest destructive force is that a motorcycle leans in turns. This would essentially lift the pizza up (assuming the box is affixed to the bike), which reduces the friction and the pizza will basically continue trying to stay in place while the box is moving. For most other movements of the bike, the friction of the pizza is likely enough to keep it moving along with the box. The little plastic spacer they put in the middle of the pizza would help a little with keeping the pizza from lifting.

I think the biggest problem in the moped/pizza scenario is that as the moped goes over bumps the pizza will sometimes have little/no contact with the pizza box - any time this happens while the moped is accelerating/braking or being thrown around sideways, the pizza will tend to shift and end up crumpled against the side of the box. Probably the best thing you can do is give the pizza box relatively soft vertical suspension with plenty of travel, and tell the rider not to accelerate or brake hard.

Your location information is missing from your forum profile. I can make recommendation to a simple accelerometer but the shipping will be expensive if you are not on my part of the world.

I'm in Berkeley, Calif.