View Single Post
  #25   Spotlight this post!  
Unread 26-04-2015, 13:40
WillNess's Avatar
WillNess WillNess is offline
Programmer
AKA: Will Ness
FRC #4944 (The Hi Fives)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: United States
Posts: 90
WillNess is just really niceWillNess is just really niceWillNess is just really niceWillNess is just really nice
Re: Getting Gyro Working w/ Mecanum Drive

Do you think this will work? (I only included the drive code)

Code:
public void teleopInit(){
	gyroMode = true;
}

public void teleopPeriodic() {
        Jx = OI.joystick0.getX(); //Drive Joystick X
        Jy = OI.joystick0.getY(); //Drive Joystick Y
        Jz = OI.joystick0.getZ(); //Drive Joystick Z
        rotationSpeedForError = RobotMap.GyroMod(Jz);
        RobotMap.driveRobotDrive41.mecanumDrive_Cartesian(Jx, Jy, Jz + rotationSpeedForError, 0);
}

public double GyroMod(double rotation){
	if (gyroMode == true) {
		double error = gyro.getAngle() - gyroHeading;
		double kP = .05;
		if (rotation == 0) {
			rotation = rotation + kP * error;
		} else {
			gyroHeading = gyro.getAngle();
		}
	}
	return rotation;
	}
}
__________________

Outreach Lead // Lead Programmer // Junior

2014 FRC:
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Utah
Rookie Allstar, Highest Rookie Seed & Semifinalist @ Colorado
2015 FRC:
Creativity In Engineering & Semifinalist @ Arizona West

Last edited by WillNess : 26-04-2015 at 23:00.
Reply With Quote