Go to Post Now that football is over... ARE YOU READY FOR SOME ROBOTS?!?! - KelliV [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:05.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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