View Single Post
  #1   Spotlight this post!  
Unread 29-01-2017, 23:02
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 38
Lesafian is an unknown quantity at this point
ADXRS450 Straight Drive Not Working

My team is using mecanum wheels this year, and we've found that it's very hard to drive in a straight line. Along with that, it is impossible to drive straight in auton. We decided to use the gyroscope that comes with the kit of parts (ADXRS450). I've used the code in the screensteps, and it does not work whatsoever. I'm unable to set the sensitivity for the gyro, but I assume it's because there is no need since the class is specifically for that gyroscope.

Here is the code.

Code:
package org.usfirst.frc.team6077.robot;


import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.ADXRS450_Gyro;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


public class Robot extends SampleRobot {
    RobotDrive drive;
    VictorSP leftFront, leftBack, rightFront, rightBack;
    ADXRS450_Gyro gyro;
    double kP = 0.03;

    public Robot() {
    	leftFront = new VictorSP(0);
    	leftBack = new VictorSP(1);
    	rightFront = new VictorSP(2);
    	rightBack = new VictorSP(3);
        drive = new RobotDrive(leftFront, leftBack, rightFront, rightBack);
        gyro = new ADXRS450_Gyro();
        gyro.calibrate();
    }

    public void autonomous() {
    	gyro.reset();
    	while (isAutonomous() && isEnabled()) {
    		SmartDashboard.putNumber("Gyro Angle", gyro.getAngle());
    		//X and Y are switched because of inversion
    		drive.mecanumDrive_Cartesian(-0.5, 0, -gyro.getAngle()*kP, 0);
    	}
    }

The only noticeable effect of the gyroscope is that when kP is above 0.005 the robot spins at full speed in a circle.

Thanks!
Reply With Quote