rockwayrobotics / robot-on-python

0 stars 0 forks source link

Accelerometer #4

Open peter9477 opened 1 year ago

peter9477 commented 1 year ago

Basically just need to instantiate with wpilib.BuiltInAccelerometer() (note spelling of built-in, with the capital I), and read from getX(), getY(), getZ(). Possibly adjust range with some method that's on it.

I threw something into the prototype and managed to see a non-zero value on X on the robot, but didn't quite get far enough to observe live data as we tilted the robot. Can probably do that quickly tomorrow, which would probably be enough to call this done, as anything else is about using that data.

peter9477 commented 1 year ago

Note that the two drive bases have the Rio rotated 90 degrees from each other. As a general rule, we should have a way of identifying which robot we're running code on (I believe there's a serial number we can read in the Rio), and our code should apply a rotation to the X/Y axes to adjust to a common orientation so that the same code can run on either robot without changing source or having to remember to adjust some setting.

Also it means if we move Rios around, we have to cope with that. Exposing this as a persistent setting (saved on the Rio itself) may make the most sense actually, although I don't know which mechanism exists to do that yet. This would mean that if a Rio gets moved (or just rotated), we can make the adjustment once and then the code works on that unit unless it's moved again.