• Hi there! I'm Bre, a game developer at a children's hospital. I'm exploring using Puck.js as a game controller for MakeCode Arcade games, so that we can use them for adaptive gaming, procedure support, etc. I'd like to show you guys what I've done so far, and see if I can get a little help as well.

    You can try the following examples I've put together - just click "Connect Puck.js" at the bottom of the page to connect the Puck, and then tilt the Puck to play.

    Space Destroyer - tilt Puck left/right (about accelerometer X axis) to move left right, tilt forward (about accelerometer Y axis) to shoot.

    Hot Air Balloon - tilt Puck forward (about accelerometer Y axis) to move the hot air balloon up.

    I'm using the Madgwick AHRS algorithm to estimate orientation, but only using the accelerometer/gyroscope data as input. Here's a demo that rotates a 3D model from the Puck accel/gryo data only. I'm pretty happy with the pitch/roll calculations, but heading has always been off. I was hoping to use the magnetometer to improve my orientation calculations.

    If I add in the magnetometer data to the Madgwick algorithm like I do in this example, the orientation is way worse. The heading always seems to want to drift to the same direction, regardless of what direction it's pointing. I've been searching datasheets and documentation and code for answers, but for the life of me, I cannot get the magnetometer and accelerometer data to play well together.

    Has anyone been able to combine the accel/gyro/mag data to estimate orientation? I have the Puck v2.1a, just FYI. I don't really know much about sensor fusion and I've been trying to figure this out for a while, so any help would be much appreciated! Thank you!

About

Avatar for bre @bre started