Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   accelerometer return acceleration 0 (http://www.chiefdelphi.com/forums/showthread.php?t=154424)

TakeItEasy 29-01-2017 08:30

accelerometer return acceleration 0
 
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.

acastagna 29-01-2017 22:27

Re: accelerometer return acceleration 0
 
Post your code

TakeItEasy 30-01-2017 02:48

Re: accelerometer return acceleration 0
 
Quote:

Originally Posted by acastagna (Post 1637945)
Post your code

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();
        }
}

i tried this code for testing but it doesnt print anything.


All times are GMT -5. The time now is 09:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi