Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit 3c6f662

Browse files
authored
Merge pull request #16 from frc6506/devlopment
The robot drivers!
2 parents c966fdc + d0f6d17 commit 3c6f662

File tree

20 files changed

+671
-31
lines changed

20 files changed

+671
-31
lines changed

.github/workflows/format.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Google Java Formatter
22

3-
on: [push]
3+
on:
4+
- push
45

56
jobs:
67
formatting:

.github/workflows/gradle.yml .github/workflows/main.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
name: Build FRC Java with Gradle
1+
name: Build FRC Java with Gradle 2
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
- release/*
8-
pull_request:
9-
branches:
10-
- master
11-
- release/*
4+
- push
125

136
jobs:
147
build:

RobotCode2020/.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"**/.classpath": true,
1111
"**/.project": true,
1212
"**/.settings": true,
13-
"**/.factorypath": true,
14-
"**/*~": true
13+
"**/.factorypath": true
1514
}
1615
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Main-Class: frc.robot.Main
3+

RobotCode2020/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "java"
3-
id "edu.wpi.first.GradleRIO" version "2020.2.2"
3+
id "edu.wpi.first.GradleRIO" version "2020.1.2"
44
}
55

66
sourceCompatibility = JavaVersion.VERSION_11

RobotCode2020/src/main/java/frc/robot/OI.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
package frc.robot;
99

1010
import edu.wpi.first.wpilibj.Joystick;
11-
11+
import edu.wpi.first.wpilibj.buttons.Button;
12+
import edu.wpi.first.wpilibj.buttons.JoystickButton;
1213
/**
1314
* This class is the glue that binds the controls on the physical operator interface to the commands
1415
* and command groups that allow control of the robot.
@@ -21,16 +22,10 @@ public class OI {
2122
// number it is.
2223
// Joystick stick = new Joystick(port);
2324
// Button button = new JoystickButton(stick, buttonNumber);
25+
public Joystick controller = new Joystick(RobotMap.CONTROLLER_PORT_ID);
26+
public Button abutton = new JoystickButton(controller, RobotMap.A_BUTTON_ID);
27+
public Button bbutton = new JoystickButton(controller, RobotMap.B_BUTTON_ID);
2428

25-
Joystick xbox = new Joystick(RobotMap.JOYSTICK_PORT);
26-
27-
public double getXboxX() {
28-
return xbox.getRawAxis(RobotMap.XBOX_X_AXIS);
29-
}
30-
31-
public double getXboxY() {
32-
return xbox.getRawAxis(RobotMap.XBOX_Y_AXIS);
33-
}
3429
// There are a few additional built in buttons you can use. Additionally,
3530
// by subclassing Button you can create custom triggers and bind those to
3631
// commands the same as any other Button.
@@ -51,4 +46,7 @@ public double getXboxY() {
5146
// until it is finished as determined by it's isFinished method.
5247
// button.whenReleased(new ExampleCommand());
5348

49+
public double getAxis(int axis) {
50+
return controller.getRawAxis(axis);
51+
}
5452
}

RobotCode2020/src/main/java/frc/robot/Robot.java

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import frc.robot.commands.ExampleCommand;
1616
import frc.robot.subsystems.ExampleSubsystem;
1717

18+
import frc.robot.subsystems.Mailbox;
19+
import frc.robot.subsystems.Drivetrain;
20+
import frc.robot.subsystems.Arm;
21+
import frc.robot.subsystems.Climb;
22+
1823
/**
1924
* The VM is configured to automatically run this class, and to call the functions corresponding to
2025
* each mode, as described in the TimedRobot documentation. If you change the name of this class or
@@ -25,6 +30,12 @@ public class Robot extends TimedRobot {
2530
public static ExampleSubsystem m_subsystem = new ExampleSubsystem();
2631
public static OI m_oi;
2732

33+
// subsystems
34+
public static Mailbox mail = new Mailbox();
35+
public static Drivetrain drivetrain = new Drivetrain();
36+
public static Arm armMotor = new Arm();
37+
public static Climb climbDevice = new Climb();
38+
2839
Command m_autonomousCommand;
2940
SendableChooser<Command> m_chooser = new SendableChooser<>();
3041

RobotCode2020/src/main/java/frc/robot/RobotMap.java

+21-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,26 @@ public class RobotMap {
2323
// public static int rangefinderPort = 1;
2424
// public static int rangefinderModule = 1;
2525

26-
public static final int JOYSTICK_PORT = 0;
27-
public static final int XBOX_X_AXIS = 0;
28-
public static final int XBOX_Y_AXIS = 0;
26+
// arm motor ID; placeholder for now
27+
public static final int CONTROLLER_PORT_ID = 0;
2928

30-
public static final int DRIVE_LEFT_PORT = 0;
31-
public static final int DRIVE_RIGHT_PORT = 1;
29+
public static final int MOTOR_ARM_ID = 0;
30+
31+
public static final int MOTOR_MAILBOX_ID = 0;
32+
33+
public static final int MOTOR_LEFT_ID =
34+
12; // Fliped sides virutally becuaes of turning issues //nevermind
35+
public static final int MOTOR_RIGHT_ID = 10;
36+
37+
public static final int MOTOR_CLIMB_ID = 0;
38+
39+
// left joystick
40+
public static final int JOYSTICK_DRIVE_FORWARDS_ID = 1;
41+
public static final int JOYSTICK_DRIVE_ROTATION_ID = 0;
42+
public static final int A_BUTTON_ID = 0;
43+
public static final int B_BUTTON_ID = 0;
44+
// backwards button
45+
// public static final int JOYSTICK_LEFT_TRIGGER_ID = 0;
46+
47+
// public static final int JOYSTICK_MAILBOX_ROLLERS_ID = 0;
3248
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import frc.robot.Robot;
11+
import edu.wpi.first.wpilibj.command.Command;
12+
13+
public class ArmSet extends Command {
14+
public ArmSet() {
15+
// Use requires() here to declare subsystem dependencies
16+
// eg. requires(chassis);
17+
requires(Robot.armMotor);
18+
}
19+
20+
// Called just before this Command runs the first time
21+
@Override
22+
protected void initialize() {}
23+
24+
// Called repeatedly when this Command is scheduled to run
25+
@Override
26+
protected void execute() {
27+
Robot.armMotor.turn(Robot.m_oi.getAxis(0));
28+
}
29+
30+
// Make this return true when this Command no longer needs to run execute()
31+
@Override
32+
protected boolean isFinished() {
33+
return false;
34+
}
35+
36+
// Called once after isFinished returns true
37+
@Override
38+
protected void end() {}
39+
40+
// Called when another command which requires one or more of the same
41+
// subsystems is scheduled to run
42+
@Override
43+
protected void interrupted() {}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.Command;
11+
import frc.robot.Robot;
12+
import frc.robot.RobotMap;
13+
14+
public class Drive extends Command {
15+
public Drive() {
16+
// Use requires() here to declare subsystem dependencies
17+
// eg. requires(chassis);
18+
requires(Robot.drivetrain);
19+
}
20+
21+
// Called just before this Command runs the first time
22+
@Override
23+
protected void initialize() {}
24+
25+
// Called repeatedly when this Command is scheduled to run
26+
@Override
27+
protected void execute() {
28+
double speed = Robot.m_oi.getAxis(RobotMap.JOYSTICK_DRIVE_FORWARDS_ID) * -1;
29+
double rotation = Robot.m_oi.getAxis(RobotMap.JOYSTICK_DRIVE_ROTATION_ID);
30+
31+
Robot.drivetrain.drive(speed, rotation);
32+
}
33+
34+
// Make this return true when this Command no longer needs to run execute()
35+
@Override
36+
protected boolean isFinished() {
37+
return false;
38+
}
39+
40+
// Called once after isFinished returns true
41+
@Override
42+
protected void end() {}
43+
44+
// Called when another command which requires one or more of the same
45+
// subsystems is scheduled to run
46+
@Override
47+
protected void interrupted() {}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.Command;
11+
import frc.robot.Robot;
12+
13+
public class MailboxSet extends Command {
14+
public MailboxSet() {
15+
// Use requires() here to declare subsystem dependencies
16+
// eg. requires(chassis);
17+
requires(Robot.mail);
18+
}
19+
20+
// Called just before this Command runs the first time
21+
@Override
22+
protected void initialize() {}
23+
24+
// Called repeatedly when this Command is scheduled to run
25+
@Override
26+
protected void execute() {
27+
double turnValue = Robot.m_oi.getAxis(0);
28+
Robot.mail.turn(turnValue);
29+
}
30+
31+
// Make this return true when this Command no longer needs to run execute()
32+
@Override
33+
protected boolean isFinished() {
34+
return false;
35+
}
36+
37+
// Called once after isFinished returns true
38+
@Override
39+
protected void end() {
40+
Robot.mail.turn(0);
41+
}
42+
43+
// Called when another command which requires one or more of the same
44+
// subsystems is scheduled to run
45+
@Override
46+
protected void interrupted() {}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.Command;
11+
import frc.robot.Robot;
12+
13+
public class WinchUnwind extends Command {
14+
public WinchUnwind() {
15+
// Use requires() here to declare subsystem dependencies
16+
// eg. requires(chassis);
17+
requires(Robot.climbDevice);
18+
}
19+
20+
// Called just before this Command runs the first time
21+
@Override
22+
protected void initialize() {}
23+
24+
// Called repeatedly when this Command is scheduled to run
25+
@Override
26+
protected void execute() {
27+
if (Robot.m_oi.bbutton.get()) {
28+
Robot.climbDevice.turn(-1);
29+
} else {
30+
Robot.climbDevice.turn(0);
31+
}
32+
}
33+
34+
// Make this return true when this Command no longer needs to run execute()
35+
@Override
36+
protected boolean isFinished() {
37+
return false;
38+
}
39+
40+
// Called once after isFinished returns true
41+
@Override
42+
protected void end() {}
43+
44+
// Called when another command which requires one or more of the same
45+
// subsystems is scheduled to run
46+
@Override
47+
protected void interrupted() {}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.Command;
11+
import frc.robot.Robot;
12+
13+
public class WinchWind extends Command {
14+
public WinchWind() {
15+
// Use requires() here to declare subsystem dependencies
16+
// eg. requires(chassis);
17+
requires(Robot.climbDevice);
18+
}
19+
20+
// Called just before this Command runs the first time
21+
@Override
22+
protected void initialize() {}
23+
24+
// Called repeatedly when this Command is scheduled to run
25+
@Override
26+
protected void execute() {
27+
if (Robot.m_oi.abutton.get()) {
28+
Robot.climbDevice.turn(1);
29+
} else {
30+
Robot.climbDevice.turn(0);
31+
}
32+
}
33+
34+
// Make this return true when this Command no longer needs to run execute()
35+
@Override
36+
protected boolean isFinished() {
37+
return false;
38+
}
39+
40+
// Called once after isFinished returns true
41+
@Override
42+
protected void end() {}
43+
44+
// Called when another command which requires one or more of the same
45+
// subsystems is scheduled to run
46+
@Override
47+
protected void interrupted() {}
48+
}

0 commit comments

Comments
 (0)