We are trying to use the built in acceliometer

Hey we are trying to use the built in accelerometer but we don’t know how. How do i make an instance of him and how can i see his value ?
by the way we are programming in java.

You can see how to do this at this page Accelerometers - Software — FIRST Robotics Competition documentation (wpilib.org).

// At head of robot class:
private Accelerometer accel = new BuiltInAccelerometer();

// In for example autonomousPeriodic():
double angle = Math.toDegrees(Math.atan2(accel.getY(), accel.getZ()) );
// .. then use that angle to for example move something to level the robot

The problem is that the built-in accelerrometer is measuring exactly that, the acceleration.
If the robot it tilted while at rest, you get a good tilt angle. But when moving, you have a lot of “noise” on the signal. A CRTE ‘pigeon’ for example gives a much more stable reading of tilt angles.

thanks a lot

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.