Measure roll/lean of moving motorcycle

It's been a while again, but this time I come with a big update.

Not relevant to the original question, but here's how I made the headlight:



The inner bucket has 5 bearings that ride in the channel in the outer housing. Whole thing is moved by the stepper motor, right now it's a "short body nema" . Currently, gear ratio is 9:1.

That's how the 3D printed headlight looks on the bike. It's one of those LED Jeep headlights from Amazon. I added fog lights as high beam on the main headlight is weak. Fog light are actually too bright but I'm gonna keep them anyways.

There are two MakerFocus TF-Lunas just hot glued to the rear of the bike. One on each side.

To calculate the angle from the distance I just did ("left sensor reading" - "right sensor reading"), then gathered some data with this reading and digital angle gauge. Data is plotted in LoggerPro and I used "best curve fit" to obtain a function used to convert this distance to angle.

Here's a short demo video with headlight on the bike:

I think it looks pretty cool from the 2:40 mark.

Right now I take 10 distance readings and average them out. Speed of the stepper is also turned down to prevent it from skipping steps. In the "inside garage" part you can see that headlight is lagging behind the bike. Also I only gathered data by leaning bike to the left and then simply inputted the same data with negative signs in front for the right. Lunas must be glued unevenly as when leaning right, angle reads too high. I think I'll keep it that way - there's less worry about blinding oncoming traffic if right side is too high.

Whole thing works decent how it is now. There's couple things to fix, including:

  • increase gear ratio/use bigger stepper - I would like the headlight rotation speed to be higher than it is now, but stepper will skip if I increase the speed. Could possibly bump up the current but stepper is getting pretty hot right now.
  • reprint the inner housing - I made some mistakes that were fixed with file/grinder/drill. Gap between bearings and outer bucket was too big so I pressed in some sleeves on the outside, but now the headlight makes this squeaking sound when rotating.
  • waterproof it / tidy up the wiring - or at least give it a fighting chance in the rain. I've never ridden in the rain yet despite having bike for couple of years.
  • buttons, display, and sensors are mostly held together with hot glue, which is a great temporary (holds fine and easy to remove with isopropyl alcohol but might melt if bike left on the sun)
    ...and probably more.

Do you think it's worth sharing the files/code for this project? I would need to fix some things before that tho. What would be the best place?

Anyways, thanks for the help. I would never think of using the distance sensors and I've gotten nowhere with the gyros.

2 Likes