|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Today I tried to program the "FRC GYRO & ACCEL" we got on FIRST CHOICE. It is a On-Board accelerometer and gyro. the gyro work fine but the accelerometer always returns me 0 XYZ. The robot drove about 5m and noting changes. I used the ADXL362 class at the wpilib and tried all the functions to read the acceloration. Also tried to chage the sesor to another one. Help please.
|
|
#2
|
|||
|
|||
|
Re: accelerometer return acceleration 0
Post your code
|
|
#3
|
|||
|
|||
|
Re: accelerometer return acceleration 0
Code:
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick joystick;
ADXL362 acc;
CANTalon[] drive = new CANTalon[4];
@Override
public void robotInit()
{
for(int i = 1; i < 5; i++)drive[i-1] = new CANTalon(i);
myRobot = new RobotDrive(drive[2],drive[0]);
joystick = new Joystick(0);
acc = new ADXL362(Accelerometer.Range.k4G);
}
@Override
public void autonomousInit() {
}
@Override
public void autonomousPeriodic() {
}
@Override
public void teleopInit() {
}
@Override
public void teleopPeriodic() {
myRobot.arcadeDrive(joystick);
if(acc.getX() != 0)System.out.println("X " + acc.getX());
if(acc.getY() != 0)System.out.println("Y " + acc.getY());
if(acc.getZ() != 0)System.out.println("Z " + acc.getZ());
}
@Override
public void testPeriodic() {
LiveWindow.run();
}
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|