Shop OBEX P1 Docs P2 Docs Learn Events
Best way to get lean angle of a motorcycle — Parallax Forums

Best way to get lean angle of a motorcycle

Jim FouchJim Fouch Posts: 395
edited 2013-08-03 09:46 in General Discussion
I'm looking for a way to determine the lean angle of a motorcycle (In motion of course). I have used a basic 2 axis accelerometer, but after the initial roll in to a turn, the tilt value that is normally accurate when the accelerometer is stopped, becomes affected by the bikes centrifugal forces of it wanting to slide out of the turn.
I have a single axis electronics gyroscope that is used in RC helicopter applications to help stabilize them, but have not interfaced with it yet. I also don't know if the outputs would always have level as center. I also don't know if it would be affected the same way the accelerometer is.
I’m also considering creating an old school motor type Gyro and having some pots on it for readings.
The main purpose for this is to have a camera mount that will adjust for lean angles and also wheelies. Basically, instead of having the camera point at the sky, it will actually look like a person is following the bike.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jim Fouch

FOUCH SOFTWARE
«134

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-11-07 21:56
    Because a force is a force, either by gravity or by a change in acceleration it looks the same to the sensor. I would think gyroscopes would be better at this, since they measure rotational force rather than linear force the way accelerometers do. This is why IMUs use both, to measure both linear and rotational forces.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • pemspems Posts: 70
    edited 2008-11-07 22:13
    interesting problem

    i though about it a bit, and i think you can estimate the tilt angle with just 1 Axis accelerometer.

    here is how:
    1. fix the accelerometer with the axis pointing up/down.
    2. measure the accel reading when fully upright (to get gravity value)
    3. obtain the tilt angle from the following formula:

    alpha = arcsin( g / x )

    where:
    alpha - current tilt angle (fully upright is 90 degrees)
    g - accel's reading in fully upright
    x - current accel reading

    this should work for a motorcycle in a reasonably steady state (i.e no bumps, sudden elevation changes, sudden wheel turns, etc)
  • SRLMSRLM Posts: 5,045
    edited 2008-11-07 23:16
    If you already have a gyroscope, might as well use that. It's (more or less) impervious to bumps, unlike the accelerometer. If it's for a helicopter, it most likely that six wires in two pairs of three. The input is a pulsewidth, output pulsewidth. Just send it a 1.5 ms pulse, and see what pulseout you get when the gyro is level. Then, simply compare the new pulseout when you turn the gyro, and you can compare it to the level measurement.
  • wadiprawitawadiprawita Posts: 7
    edited 2008-11-07 23:30
    I think the best way is GPS receiver. Two information that You can use are :

    - heading change rate (delta heading / time interval), this will function the same as vertical gyro with lower data rate
    - ground speed

    The lean angle will be the function of those two measurement, some thing like these :

    lean_angle = atan(gps_ground_speed / 9.81 * heading_change_rate);

    where 9.81 is gravity constant at your location. You can fine tune the result with some constant or non linear function.

    regards

    -doni-
  • wadiprawitawadiprawita Posts: 7
    edited 2008-11-07 23:32
    Oh ye, the best GPS receiver to use is more than 1 Hz GPS, such as uBlox. For calculating heading changerate, the data will be noisy, so you will need some smoothing algorithm, one of the simplest is moving average.

    regards

    -doni-
  • TJHJTJHJ Posts: 243
    edited 2008-11-08 01:39
    Full size right? Not an RC motorcycle?

    Thoughts
    1. Why not just mount it on your helmut? (Because thats no fun, I know).

    2. If you know the speed, and a rough weight of the bike, you could accurately determine how much force is being contributed by speed to the lean angle, I think, Im gonna half to sit down and do the math on that. Also knowing the speed will make the "wheelies" a lot easier to figure out, as they would seem to look the same as the bike accelerating/ compression loading the suspension, I would say it would be simplest to get front and rear wheel speed. Most modern motorcycles use a 5v hall sensor for front wheel speed so that should be easy, and knowing that, you can inductively pick up rpm that would give you a "rear" wheel speed and in reference to front wheel speed shouldn't be to hard to determine the gear you are in. So thats the hard math way, but maybe, If you need the math for it, shoot me a PM.

    3. Why not put a ping on each side, and measure distance to the ground, if they were angled right I think you could get all your position information from just two of them. I guess it doesn't half to be a ping but just an ultrasonic range finder, then its just a simple matter of figuring out the angle of the triangle. I am unsure if eventually at a given speed the ping pulses would fail to make it back to the unit, from the relative motion effect.

    So left one shortens, its leaning left, they both get longer, its on the rear wheel, ect ect.

    Just some thoughts,

    Best of luck,
    TJ
  • grindelgrindel Posts: 68
    edited 2008-11-08 02:59
    I have done some thinking on this:

    motorcycle lean angle is kind of tricky to visualize for those who don't ride...even those who do for that matter

    This is what I think I understand:
    The lean angle is determined the combination of the motorcycle's force vector through the C.G. (gravity and centrifugal) and the rider's force vector through the C.G (gravity and centrifugal). For a constant lean angle turn, viewed from the rear, the sum of the two vectors has to go through the contact patch of the tire...if it doesn't you will not maintain that lean angle Add a little countersteer and things really get a bit more complicated but manageable. For normal riding the rider C.G., the bike C.G. and the contact patch are in a straight line, but since the rider is not strapped into the cycle, but is able to mover around in the seat...you've seen racers hanging off the side of their bikes, right?...GPS and accelerometer data will not work. I think you're down to gyro and ping, and I don't think ping will handle the doplar effect. Depends on the accuracy needed and type of riding necessary, but one could imagine a brute force solution of two wheeled trailer on an articulated (U-Joint?) swivel (rotationally free to move) mount with an encoder to give you a very accurate lean angle.
  • Jim FouchJim Fouch Posts: 395
    edited 2008-11-08 16:29
    Some real good ideas guys!!

    I'll try the electronics Gyro I have to see what it does. The best way to test it is to film some riding while overlaying the data over the video. That way you simply play back the video and see how well things work.

    I do like the idea of the PING, but I wonder if the PING will work well if it's not facing the object (The ground) at 0 degrees. As the bike changes it's angle, the angle of the PING will also change.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • LawsonLawson Posts: 870
    edited 2008-11-08 17:07
    I've got an RC motorcycle and have previously been tempted to make a balancing controller for it as the existing mechanical system isn't very robust. My plan was to use two gyros in a two level control loop. The first level would have the gyro's axis aligned with the direction of travel. This gyro would do all the high speed balancing but drift in this gyro would make the motorcycle fall over quickly. The second gyro and a wheel speed sensor would be used to measure lean angle. Combined with the steering channel from the receiver my controller would generate an error signal for correcting the high speed control loop. The second gyro would be oriented with it's axis perpendicular to the direction of travel and perpendicular to the handlebars. (i.e. pointing directly up)

    My specific method for measuring lean angle would be to use the second gyro to measure the rate of turn of the motorcycle. For a given rate of turn and speed a motorcycle has one possible lean angle. Just ran through the math. I've attached a scan of it below. atan(w*S/g) = lean angle, this should be a nice well behaved function.

    Marty

    P.S. The bike lean angle will mess with the response of the second gyro. The best solution is to put the gyro on the level platform with your camera. Otherwise another formula can be generated to correct the rate of turn measurement based on lean angle. This system of equations could be solved each control cycle, or the correction could be generated using the lean angle from the previous cycle. Still, bumps would couple in at high lean angles.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?

    Post Edited (Lawson) : 11/8/2008 7:08:43 PM GMT
    1279 x 1083 - 45K
  • kelvin jameskelvin james Posts: 531
    edited 2008-11-08 17:56
    This is a sensor that you should have a look at, it even controls the servos. It would have to be mounted for an unobstructed view, and possibly recalibrated depending on the enviroment being travelled through. If it can keep a plane or heli level, it should work for a camera with an optic stabilizer. Interesting technology. The manual is in the downloads page.



    www.fmadirect.com/Detail.htm?item=1489&section=20
  • T ChapT Chap Posts: 4,223
    edited 2008-11-08 20:36
    If the cam is mounter rear of the bike, you can consider a plate mounted to a servo(or plate mounted on shaft to a bearing for load, driven by stepper, DC, or servo).

    If you can isolate the Ping reflections with a tube around each transmitter and recdeiver, you could use two Pings on the plate, and some variation of PID to keep the plate balanced. Using an average of time to calculate t he error, you might be able to get it pretty smooth.
    292 x 235 - 14K
  • Jim FouchJim Fouch Posts: 395
    edited 2008-11-08 22:44
    Originator:

    I think that may just work. The Prop could read both PINGs and use the Servo to try to balance them with the resulting position being the true lean angle of the bike.

    The lean indicator will be mounted under the bike and the camera mount will be positioned behind the rider.

    This would also throw out any issues with other forces. Also when both pings show an equal increase above normal ride height, that would indicate a wheelie. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • Jim FouchJim Fouch Posts: 395
    edited 2008-11-08 23:16
    Does anyone know if the PING always sends out sound or only when asked for a reading? I'm thinking if a read one after the other, I will not get interference between the two.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • pemspems Posts: 70
    edited 2008-11-08 23:53
    Hi

    I am just curious why my proposition wasn't considered? I though about it some more and it really does seem like it would work well (according to my grade 8 physics diagram). Just put some filter (running average?) on it's input and it should balance out any kind of high frequency noise (like small bumps on the road)
    Besides it's 1. cheap (1axis accelerometer) 2. simple. Not sure why one would rather look for exotic solutions (other than for coolness factor [noparse];)[/noparse] )
  • T ChapT Chap Posts: 4,223
    edited 2008-11-09 00:16
    Also, maybe look at a Steadycam for ideas on whether you can mount the cam on some counter balanced system that helps with the steadiness.


    Using two ADC's and an upside down joystick(using pots) with a weight detects Gforce in right or left turn. Regardless of
    lean angle, sensor will tend to want to arrive at 90 degree angle perpendicular to ground at some sufficient Gforce vs
    Weight factor. Greater outward Gfoce puts greater pressure on spring, producing info to use as an
    offset. Use a speed factor to determine if the bike is moving. At some known speed, the joystick will tend move opposite gravities pull.

    There should be some known values of lean angle at X speed based on riding habits given a flat surface track.

    If Speed = 0, and Lean = Left, the joystick leans left too. Use Speed to tell the code that the bike is leaning left, with no Gforces, therefor, correct the cam to the opposite direction.

    If Speed = 100, and lean = left, the joystick leans right (against gravity), so use Speed and the ADC value to arrive at a lean value to correct that indicates the bike is leaning left still.

    Post Edited (Originator) : 11/9/2008 12:21:28 AM GMT
    229 x 292 - 12K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-09 00:39
    pems,

    Your idea would work when the bike is standing still or going straight, but not when it's banking in a turn. This is because of the centripetal acceleration vector that gets added to g results in a net acceleration pointing at the same angle the bike is leaning. This is the vector the accelerometer will measure, not g itself. So, from the accelerometer's frame of reference, the bike will seem to be upright. It's for this same reason that a biker's vestibular system doesn't sense an imbalance when the bike is in a turn, since "apparent gravity" still feels like it's pulling "down" relative to the biker's body.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Just a few PropSTICK Kit bare PCBs left!
  • W9GFOW9GFO Posts: 4,010
    edited 2008-11-09 01:30
    Here's my idea, can't see why it wouldn't work but someone else may...

    Use a two axis accelerometer mounted so that each axis points up and out from the bike at a 45 deg angle. Like a Vee when viewed from the front.

    When both axis are equal the bike is upright.
    When they are unequal but sum to one gee, then you can calculate the static lean angle.
    When they are unequal but sum to more than one gee you will be able to calculate the lean angle by the difference in readings and how much more than one gee there is.

    For example at 45 deg static lean one will read 1g, the other 0g.
    Going 100 mph while leaning 45 deg, one will still read one gee, the other, quite a bit more than zero.

    Rich H

    Post Edited (W9GFO) : 11/9/2008 1:48:25 AM GMT
  • pemspems Posts: 70
    edited 2008-11-09 02:20
    Phil Pilgrim (PhiPi) said...
    pems,

    Your idea would work when the bike is standing still or going straight, but not when it's banking in a turn. This is because of the centripetal acceleration vector that gets added to g results in a net acceleration pointing at the same angle the bike is leaning. This is the vector the accelerometer will measure, not g itself. So, from the accelerometer's frame of reference, the bike will seem to be upright. It's for this same reason that a biker's vestibular system doesn't sense an imbalance when the bike is in a turn, since "apparent gravity" still feels like it's pulling "down" relative to the biker's body.

    -Phil

    thanks for commenting Phil

    This is exactly how i see it and here is why i think it will work:
    When the bike is upright and standing still (or going along straight line), the only force is gravity, so the pavement exerts the opposite force pointing up, so the bike stays in its place and not going anywhere.
    Now, add the centrifugal force exerted on bike/biker once at speed and turning - another force, perpendicular to the gravity and direction of motion. So, since these two forces have to be counteracted, the pavement now has to counteract the geometrical sum of these two forces, thus it exerts the negative sum of gravity and the centrifugal. To stay balanced (and not fall), the bike has to tilt such way so it would be parallel to this sum vector, which means that it is sufficient to simply use permanently mounted accelerometer measuring the vertical acceleration (from the bike's frame of reference) and use the simple formula i gave earlier to calculate the tilt angle

    i am very curious to know if there is a flaw in my logic, so please point it out if it's the case
  • W9GFOW9GFO Posts: 4,010
    edited 2008-11-09 02:33
    pems, it makes sense to me except that you have no way of knowing the direction you are leaning.

    Rich H
  • pemspems Posts: 70
    edited 2008-11-09 02:43
    W9GFO said...
    pems, it makes sense to me except that you have no way of knowing the direction you are leaning.

    Rich H

    indeed Rich that's a shortcoming.
    I guess this binary piece of info can be obtained from some cheap radar type of solution (something that would sense reflecting off the ground)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-09 03:38
    pems,

    'Sorry, I glossed over your math and jumped to the wrong conclusion. But for the direction issue, as Rich points out, your idea has some merit. You're assuming, however, that the bike+rider's center of gravity always aligns with the bike's vertical axis. This assumption gets compromised, unfortunately when the rider shifts his weight. An additional uncertainty occurs when going through a dip or over a hill crest. As a gedanken experiment, imagine yourself blindfolded, riding on the back of the bike. Could you tell, just by sensing acceleration, whether and how much the bike was leaning?

    I wonder, though, if a three-axis accelerometer, combined with speed and steering-angle sensors, might provide adequate data to compute the bike's tilt angle.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Just a few PropSTICK Kit bare PCBs left!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-11-10 15:08
    This thread is off topic and is being moved from the Propeller Forum to the Sandbox Forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Nick McClickNick McClick Posts: 1,003
    edited 2008-11-10 20:41
    If an accelerometer measures CG, then there are too many non-angle related inputs that change CG on a motorcycle. What if the rider shifts and changes their center of gravity? As fuel is depleted, the CG shifts, too.

    It seems to me the best solution is two ping sensors, one on each side of the bike, pointing towards the ground. they can be mounted anywhere, just as long as they're mounted at the same height. The lean angle is a simple calculation of the difference in height. You can also take this off one bike and put it on another very easily.

    Maybe you could do it with just a single ping sensor, attached to the bottom-center of the engine fairing. Whenever you lean, the bottom gets farther from the ground. You couldn't suppose which direction the bike is leaning, but you would get an angle.

    EDIT - thinking about this a bit further - inputs that change the CG will change the angle of the bike, right?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Gadget Gangster - Share your Electronic Projects - Sign up as a Designer and get a free 4-pack of Project Boards!

    Post Edited (Nick McClick) : 11/10/2008 8:56:16 PM GMT
  • Dave HeinDave Hein Posts: 6,347
    edited 2008-11-11 01:06
    A gyro will work, but you will also need accelerometers to measure tilt to cancel drift in the gyro.··Uncorrected data from the accelerometers will be useful only when the motorcycle is going straight, and not turning.· If you measure the speed of the bike and the angle of the front wheel you could compute the centrifugal force.· Theoretically, this could be subtracted from the accelerometer data to provide the angle.

    The gyro will give you the best instantanous measure of the tilt angle.· Filtered data from the accelerometers minus the centrifugal force will provide a slower response and longer term measurement, which·can be used to correct for drift in the gyro.· I don't think using accelerometers without a gyro will work well because of the noise caused by road vibration.

    Dave
  • ercoerco Posts: 20,257
    edited 2008-11-11 14:46
    Lots of great ideas here, guys. I think many of them could be made to work in a static environment. Something tells me that the bike dynamics, vibration and wind noise would cause sensor problems with many of them at speed on the road.

    I assume this is only for occasional use under controlled circumstances. How about just a simple spring-loaded trailing wheel mounted on·one side of the·rear of the bike that directly measures lean angle (could be as simple as a rotary pot) and sends info to a camera servo up front?





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
    180 x 100 - 4K
  • Dave HeinDave Hein Posts: 6,347
    edited 2008-11-11 16:52
    Someone mentioned using a 2-wheel trailer behind the bike to measure the lean angle.· Why not just mount the camera on a trailer behind the bike?· Springs and shock absorbers would be need to keep the vibration down, but it seems like this would work.

    Dave
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-11 17:13
    erco,

    That's a great idea! It cuts through heaven knows how many lines of trig formulas. Keep it simple. I like it!

    -Phil
  • Nick McClickNick McClick Posts: 1,003
    edited 2008-11-11 23:15
    A bike is a high noise environment; wind, bumps, rain, vibration, etc. I think a trailing wheel might work, but you have to attach it to the bike's swing arm. If it were attached to the body, when the bike shifts from acceleration, it would push the arm down and be interpreted as a lean.

    The wheel should be heavy, though. otherwise it will skip and bounce over the road surface. Depends on your bike, but the swingarm might be blocked by 750 deg exhaust pipe. The other side by a chain.

    I'm still a fan of using two ping sensors, pointing down at a 45 deg angle, bungie corded to the back seat. Then you can easily move it between bikes & it doesn't interfere with the bike.

    Whatever method you decide, let us know how it goes!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Gadget Gangster - Share your Electronic Projects - Sign up as a Designer and get a free 4-pack of Project Boards!
  • Tony BoersmaTony Boersma Posts: 41
    edited 2008-11-12 00:22
    What about a 3 axis accel mounted with the body axes of the bike. z is going down, y is forward, x is to the right (I think that makes the right hand rule correct). When the bike is in steady state with no lean the z would be 1g, the others would be zero. When the bike leans but doesn't turn z and x will change. When the bike leans and turns z will change with the centripetal force, V*V/r and x will show a proportional gravity signal but won't be affected by the turn since the vector does not go through x, but it will be affected by the lean rate (from zero to steady state). Integrating the change will give you the angle while dynamic (you also need to know the height off the ground which you have)·and the proportinal gravity will give you steady state. The y axis is for wheelies, same ideas.

    I ignored all of the math, and this would make a cool simulation in Matlab using lagrange equations and what-not, but I think the idea is at least semi-solid.

    T
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-11-12 00:41
    The Pings may have some problems with acoustic noise, particularly that coming from the chain. I had similar issues once with ultrasonics above a chain conveyor. But it's certainly cheap enough to try, and you won't know for sure until you do.

    -Phil
Sign In or Register to comment.