Ignore sysprops.xml, write drive code

This commit is contained in:
Austen Adler 2016-07-23 14:18:09 -04:00
parent ebc87707e6
commit b326e64087
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1
6 changed files with 27 additions and 62 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
dist/FRCUserProgram.jar dist/FRCUserProgram.jar
build build
bin bin
sysProps.xml

View File

@ -23,5 +23,11 @@ public class OI {
// Print log when button 1 pressed // Print log when button 1 pressed
joystickButtons[0][0].whenPressed(new LogEncoder()); joystickButtons[0][0].whenPressed(new LogEncoder());
} }
public Joystick[] getJoysticks() {
return joysticks;
}
public JoystickButton[][] getJoystickButtons() {
return joystickButtons;
}
} }
// vim: sw=2:ts=2:sts=2 // vim: sw=2:ts=2:sts=2

View File

@ -5,89 +5,39 @@ import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
/**
* 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 { public class Robot extends IterativeRobot {
public static OI oi; public static OI oi;
Command autonomousCommand; Command autonomousCommand;
SendableChooser chooser; SendableChooser chooser;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() { public void robotInit() {
oi = new OI(); oi = new OI();
chooser = new SendableChooser(); chooser = new SendableChooser();
// chooser.addObject("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", chooser); SmartDashboard.putData("Auto mode", chooser);
} }
/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
* the robot is disabled.
*/
public void disabledInit() { public void disabledInit() {
} }
public void disabledPeriodic() { public void disabledPeriodic() {
Scheduler.getInstance().run(); Scheduler.getInstance().run();
} }
/**
* This autonomous (along with the chooser code above) shows how to select between different autonomous modes
* using the dashboard. The sendable chooser code works with the Java SmartDashboard. If you prefer the LabVIEW
* Dashboard, remove all of the chooser code and uncomment the getString code to get the auto name from the text box
* below the Gyro
*
* You can add additional auto modes by adding additional commands to the chooser code above (like the commented example)
* or additional comparisons to the switch structure below with additional strings & commands.
*/
public void autonomousInit() { public void autonomousInit() {
autonomousCommand = (Command) chooser.getSelected(); autonomousCommand = (Command) chooser.getSelected();
/* String autoSelected = SmartDashboard.getString("Auto Selector", "Default");
switch(autoSelected) {
case "My Auto":
autonomousCommand = new MyAutoCommand();
break;
case "Default Auto":
default:
autonomousCommand = new ExampleCommand();
break;
} */
// schedule the autonomous command (example)
if (autonomousCommand != null) { if (autonomousCommand != null) {
autonomousCommand.start(); autonomousCommand.start();
} }
} }
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() { public void autonomousPeriodic() {
Scheduler.getInstance().run(); Scheduler.getInstance().run();
} }
public void teleopInit() { public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (autonomousCommand != null) { if (autonomousCommand != null) {
autonomousCommand.cancel(); autonomousCommand.cancel();
} }
} }
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() { public void teleopPeriodic() {
Scheduler.getInstance().run(); Scheduler.getInstance().run();
} }
/**
* This function is called periodically during test mode
*/
public void testPeriodic() { public void testPeriodic() {
LiveWindow.run(); LiveWindow.run();
} }
} }
// vim: sw=2:ts=2:sts=2 // vim: sw=2:ts=2:sts=2

View File

@ -3,8 +3,8 @@ public class RobotMap {
//Drive //Drive
public static int driveLeftMotorOne = 1; public static int driveLeftMotorOne = 1;
public static int driveLeftMotorTwo = 2; public static int driveLeftMotorTwo = 2;
public static int driveRightMotorOne = 1; public static int driveRightMotorOne = 3;
public static int driveRightMotorTwo = 2; public static int driveRightMotorTwo = 4;
public static int driveRightEncoder = 0; public static int driveRightEncoder = 0;
public static int driveLeftEncoder = 1; public static int driveLeftEncoder = 1;
//Arm //Arm
@ -30,4 +30,4 @@ public class RobotMap {
public static int mainArmPresetCloseShot = 95; public static int mainArmPresetCloseShot = 95;
public static int mainArmPresetFarShot = 85; public static int mainArmPresetFarShot = 85;
} }
// vim: sw=2:ts=2:sts=2 // vim: sw=2:ts=2:sts=2

View File

@ -1,9 +1,10 @@
package org.usfirst.frc.team2059.robot.commands; package org.usfirst.frc.team2059.robot.commands;
import edu.wpi.first.wpilibj.command.Command; import org.usfirst.frc.team2059.robot.commands.CommandBase;
import org.usfirst.frc.team2059.robot.Robot;
/** /**
* *
*/ */
public class Drive extends Command { public class Drive extends CommandBase {
public Drive() { public Drive() {
} }
// Called just before this Command runs the first time // Called just before this Command runs the first time
@ -11,6 +12,13 @@ public class Drive extends Command {
} }
// Called repeatedly when this Command is scheduled to run // Called repeatedly when this Command is scheduled to run
protected void execute() { protected void execute() {
double x = Robot.oi.getJoysticks()[0].getRawAxis(0);
double y = Robot.oi.getJoysticks()[0].getRawAxis(1);
double z = Robot.oi.getJoysticks()[0].getRawAxis(2);
System.out.println("x: "+x);
System.out.println("y: "+y);
System.out.println("z: "+z);
driveBase.driveArcade(x, y, z, 0);
} }
// Make this return true when this Command no longer needs to run execute() // Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() { protected boolean isFinished() {

View File

@ -2,12 +2,12 @@ package org.usfirst.frc.team2059.robot.subsystems;
import org.usfirst.frc.team2059.robot.RobotMap; import org.usfirst.frc.team2059.robot.RobotMap;
import org.usfirst.frc.team2059.robot.commands.Drive; import org.usfirst.frc.team2059.robot.commands.Drive;
import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.CANTalon; import edu.wpi.first.wpilibj.Talon;
public class DriveBase extends Subsystem { public class DriveBase extends Subsystem {
CANTalon leftMotorOne = new CANTalon(RobotMap.driveLeftMotorOne); Talon leftMotorOne = new Talon(RobotMap.driveLeftMotorOne);
CANTalon leftMotorTwo = new CANTalon(RobotMap.driveLeftMotorTwo); Talon leftMotorTwo = new Talon(RobotMap.driveLeftMotorTwo);
CANTalon rightMotorOne = new CANTalon(RobotMap.driveRightMotorOne); Talon rightMotorOne = new Talon(RobotMap.driveRightMotorOne);
CANTalon rightMotorTwo = new CANTalon(RobotMap.driveRightMotorOne); Talon rightMotorTwo = new Talon(RobotMap.driveRightMotorOne);
public void initDefaultCommand() { public void initDefaultCommand() {
setDefaultCommand(new Drive()); setDefaultCommand(new Drive());
} }
@ -18,4 +18,4 @@ public class DriveBase extends Subsystem {
rightMotorTwo.set(y + (x + z)); rightMotorTwo.set(y + (x + z));
} }
} }
// vim: sw=2:ts=2:sts=2 // vim: sw=2:ts=2:sts=2