Go to Post A Strong FRC Team Should... have a clear vision and an understanding of how to achieve it within their means. - jwfoss [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-01-2015, 17:20
B0sh B0sh is offline
Registered User
FRC #2078 (Robotic Wolves)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2012
Location: Louisiana
Posts: 6
B0sh is an unknown quantity at this point
Gyro not proprely reading

I know a gyro post was just made, but this problem is different from the other guy's.

The value from gyro.getAngle() is steadily increasing although the gyro is not being moved. At first it starts out at 0 and then it goes up slightly, then by the time it gets to 1 its rising very quickly.

We've tried everything: Switching the gyro to a different analog port, Switching the PWM cable, changing our code, swapping out the gyro, calibrating the gyro...

I just have no idea what the issue could be. I've read many guides and I've followed them to the tee. My question is is there any other trouble shooting things I can do?

I've posted all of my code for reference, with the gyro code commented out. (The angle reading still went up just the same though)

Code:
/**
 * FRC 2078 Robot using Mecanum Drive and Camera 
 */
public class Robot extends SampleRobot {
	Gyro gyro;
    RobotDrive robotDrive;
    Joystick stick;
    CameraServer server;

    // Channels for the wheels
    final int frontLeftChannel	= 0;
    final int rearLeftChannel	= 1;
    final int frontRightChannel	= 2;
    final int rearRightChannel	= 3;
    
    // The channel on the driver station that the joystick is connected to
    final int joystickChannel	= 0;
    
    /** 
     * Constructor for the robot
     */
    public Robot() {
        server = CameraServer.getInstance();
        server.setQuality(50);
        //the camera name (ex "cam0") can be found through the roborio web interface
        server.startAutomaticCapture("cam0");
        
        //Create Robot Drive
    	robotDrive = new RobotDrive(frontLeftChannel, rearLeftChannel, frontRightChannel, rearRightChannel);
    	robotDrive.setExpiration(0.1);
        robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);	// invert the left side motors
    	robotDrive.setInvertedMotor(MotorType.kRearLeft, true);		// you may need to change or remove this to match your robot
        gyro = new Gyro(1);
        stick = new Joystick(joystickChannel);
    }
        
    /**
     * Runs the motors with Mecanum drive.
     */
    public void operatorControl() {
        robotDrive.setSafetyEnabled(true);
        gyro.reset();
        
        boolean buttonFour;
        buttonFour = stick.getRawButton(4);
        boolean buttonFive;
        buttonFive = stick.getRawButton(5);
        boolean forceTurn = false;
        
        double turn = 0;
        
        while (isOperatorControl() && isEnabled()) {
        	SmartDashboard.putNumber("Angle", gyro.getAngle());
        	buttonFour = stick.getRawButton(4);
        	buttonFive = stick.getRawButton(5);
        	
        	/*
        	if (Math.abs(gyro.getAngle()) > 1) {
        		
        	//	turn = (-gyro.getAngle()/45);
        		turn = 0;
        		
        	} else {
        	*/
        		if (buttonFour) {
        			turn = -.5;
        			forceTurn = true;
        		} else {
	        		if (buttonFive){
	        			turn = .5;
	        			forceTurn = true;
	        		} else
	        			turn = 0;
        		}
        		/*
        	}        			
//        		*/
        	
        	
        	// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
        	// This sample does not use field-oriented drive, so the gyro input is set to zero.
            
        	//positive Z turns right
        	//negative Z turns left
        	while (stick.getRawButton(4) || stick.getRawButton(5)){
               	robotDrive.mecanumDrive_Cartesian(stick.getX(), stick.getY(), turn, 0);
                SmartDashboard.putNumber("Angle", gyro.getAngle());
                Timer.delay(0.005);	// wait 5ms to avoid hogging CPU cycles
                gyro.reset();
        	}
        	
        	if (!stick.getRawButton(4) && !stick.getRawButton(5)){
        		robotDrive.mecanumDrive_Cartesian(stick.getX(), stick.getY(), turn, 0);
        		SmartDashboard.putNumber("Angle", gyro.getAngle());
        		Timer.delay(0.005);	// wait 5ms to avoid hogging CPU cycles
        	}
        	
            if (forceTurn){
            	Timer.delay(.25);
            	gyro.reset();
            	forceTurn = false;
            }
        }
    }
}
Reply With Quote
  #2   Spotlight this post!  
Unread 29-01-2015, 17:33
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro not proprely reading


While you're waiting for responses, here is a link to some threads that might be of interest.


Reply With Quote
  #3   Spotlight this post!  
Unread 29-01-2015, 17:36
TeamMarcies TeamMarcies is offline
Registered User
FRC #4777
 
Join Date: Jun 2013
Location: Canada
Posts: 9
TeamMarcies is an unknown quantity at this point
Re: Gyro not proprely reading

I'm guessing I'm the "other" guy - Yeah, I also noticed I have an issue like this as well in the DriverStation log, where when I print out the gyro.getAngle(); - it's a decimal value increasing steadily, and then really fast with no apparent change in the robot's orientation. We've also tried all possible combinations with the wires and are getting same results. I even went as far as disconnecting the gyro altogether and I was still getting these concurrent values.
Reply With Quote
Reply


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 10:52.

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