Quote:
Originally Posted by anthonygraff24
Code:
package org.usfirst.frc.team2872.robot;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick stick1;
Joystick stick2;
int autoLoopCounter;
Victor Winch = new Victor(2);
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
myRobot = new RobotDrive(0,1);
stick1 = new Joystick(0);
stick2 = new Joystick(1);
Winch.set(-.15);
}
/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
myRobot.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
myRobot.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
Winch.set(-.15);
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
myRobot.tankDrive(stick1,stick2);
Winch.set(-.15);
if(stick1.getRawButton(2))
Winch.set(.05);
if(stick1.getRawButton(3))
Winch.set(-.5);
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}
}
|
Change this line:
Code:
myRobot.tankDrive(stick1,stick2);
to this:
Code:
myRobot.tankDrive(stick1.getY() * 0.5, stick2.getY() * 0.5);
Then change the 0.5 to some scalar value depending on how much you want to scale it.