Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
813d22e
Develop init
rayzhuca Jan 9, 2022
e94eafd
added sparkmax api
cqdowning Jan 14, 2022
151fc25
Added TurnAngle command
rayzhuca Jan 15, 2022
4087e20
m_controller instead of getController()
rayzhuca Jan 15, 2022
c752c79
Init camera subsystem
rayzhuca Jan 15, 2022
25d158f
Made variable protected and added maxSpeed
rayzhuca Jan 15, 2022
4a70fd7
Init turn to target command
rayzhuca Jan 15, 2022
bd0cf27
Added custom maxSpeed
rayzhuca Jan 15, 2022
cb7f116
Added camera captured
rayzhuca Jan 15, 2022
9cb425c
Co-authored-by: FatCactis <[email protected]>
JW-junlong Jan 15, 2022
f106b39
PigeonIMU init
rayzhuca Jan 16, 2022
6172332
Removed unnecessary line in gyroYaw
rayzhuca Jan 16, 2022
1628112
Added private
rayzhuca Jan 16, 2022
a3424b9
Added ArcadeDrive and TankDrive commands
TaylorHart02 Jan 21, 2022
88e4823
Added speed clamp
lwbuchanan Jan 21, 2022
95fe997
we did the robot container all by ourselves :]
lwbuchanan Jan 21, 2022
7dca8d0
Set deafult configs
rayzhuca Jan 22, 2022
bc1e344
working drivetrain
rayzhuca Jan 22, 2022
79e7b1c
Merge branch 'gyro' into vision
rayzhuca Jan 23, 2022
8d7aaff
Merge branch 'develop' into vision
rayzhuca Jan 23, 2022
bcb5d7d
Merge branch 'develop' into vision
rayzhuca Jan 23, 2022
e3e8fc4
Created a subsystem for intake.
lwbuchanan Jan 25, 2022
6b86de5
added some shuffleboard pid
rayzhuca Jan 25, 2022
fa99c09
Minor changes
rayzhuca Jan 25, 2022
d92b376
updated phoenix library
cqdowning Jan 28, 2022
2eb5da9
Merge branch 'vision' of https://github.com/FalconX-Robotics/roboRIO-…
cqdowning Jan 28, 2022
423b33f
Formatting
FatCactis Jan 28, 2022
9ffa249
Addede INPUT_PORT
FatCactis Jan 28, 2022
ee331df
Added Intake Command.
lwbuchanan Jan 28, 2022
8ac4358
Added Outtake command and subsystem
TaylorHart02 Jan 28, 2022
49a3df8
Added Outtake subsystem
TaylorHart02 Jan 28, 2022
9a7199d
Fixed AutoTurn bugs
rayzhuca Jan 28, 2022
82d16b7
Minor changes
rayzhuca Jan 28, 2022
506dcec
Added gyro vision entry
rayzhuca Jan 28, 2022
e8539dc
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
lwbuchanan Jan 29, 2022
cfbc68b
marked random values that need to be changed
cqdowning Jan 29, 2022
38da5eb
test commit
WilliamDeGuzman Jan 29, 2022
fbd550b
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
WilliamDeGuzman Jan 29, 2022
4ef7cab
Removed the test Commit
WilliamDeGuzman Jan 29, 2022
0551bdb
cleaned code
cqdowning Jan 29, 2022
3db80c4
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
cqdowning Jan 29, 2022
7d850a9
made motor port naming consistent
cqdowning Jan 29, 2022
ad62a5e
reformatted code
cqdowning Jan 29, 2022
bb8b9f2
reformatted code for sure
cqdowning Jan 29, 2022
b6eabb5
suppressed unused warnings
cqdowning Jan 29, 2022
08a6299
Assigned Outtake command to button
TaylorHart02 Jan 29, 2022
0b2e4cc
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
TaylorHart02 Jan 29, 2022
95885bc
Intake bindings completed.
WilliamDeGuzman Jan 29, 2022
6215100
reformatted robot container
cqdowning Jan 29, 2022
1775195
changed motor port values
cqdowning Jan 29, 2022
2b7af0c
Merge branch 'develop' into vision
rayzhuca Jan 29, 2022
b0cd723
Init mods
rayzhuca Jan 29, 2022
0954c2d
Fixed bugs
rayzhuca Jan 30, 2022
1c6bf85
Changed pigeon class
rayzhuca Jan 30, 2022
c5c612f
intake motor is brushed
cqdowning Feb 1, 2022
a71a9df
Co-authored-by: anyamustard <[email protected]>
WilliamDeGuzman Feb 1, 2022
9b1fabd
Forgot to do Intake; we did it though.
WilliamDeGuzman Feb 1, 2022
49be3ee
Added method for controlling leds with blinkin
cqdowning Feb 4, 2022
d742b9c
Fixed LowerArm bug
rayzhuca Feb 5, 2022
48b1d70
Fixed some bugs on everything and we changed variable names
rayzhuca Feb 5, 2022
ce6036b
Merge branch 'develop' into drivemod
rayzhuca Feb 5, 2022
d72c433
New ports
rayzhuca Feb 5, 2022
b32794d
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
rayzhuca Feb 5, 2022
c53ba66
Fixed brushed
rayzhuca Feb 5, 2022
2a23a9f
Code tested and works
rayzhuca Feb 5, 2022
dd13c18
Merge branch 'develop' into drivemod
rayzhuca Feb 5, 2022
af88e14
Merge branch 'drivemod' of https://github.com/FalconX-Robotics/roboRI…
rayzhuca Feb 5, 2022
7725a48
Drivemod fix
rayzhuca Feb 5, 2022
719c4e2
Minor tweaks and sin drive fix
rayzhuca Feb 6, 2022
e7a5bc3
Removed break mode
rayzhuca Feb 6, 2022
0037c9f
Merge branch 'develop' into vision
rayzhuca Feb 6, 2022
ed15e86
Used SmartDashBoard instead
rayzhuca Feb 6, 2022
ceb6405
Added shuffleboard.json
rayzhuca Feb 6, 2022
b61b4f8
bug
rayzhuca Feb 6, 2022
ae64f56
Added logs to motor output
rayzhuca Feb 6, 2022
d1bc41e
Connection subsystem and conveyor command
cqdowning Feb 11, 2022
b08a00a
to merge
rayzhuca Feb 14, 2022
7f919ef
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
rayzhuca Feb 14, 2022
e6b5a6a
Renamed to pascal case
rayzhuca Feb 14, 2022
2cebfef
Added code for limelight
rayzhuca Feb 15, 2022
d2214eb
limelight only init
rayzhuca Feb 15, 2022
7ebbb44
Merge remote-tracking branch 'origin/led' into limelight-only
rayzhuca Feb 15, 2022
9ce60f7
dont mind the led changes on the limelight branch
rayzhuca Feb 19, 2022
676d145
Made Limelight and LED work
rayzhuca Feb 19, 2022
7543064
Changed default colors
rayzhuca Feb 19, 2022
ad0f811
Added AutoShoot
rayzhuca Feb 25, 2022
70365ae
Added motor outputs
rayzhuca Feb 26, 2022
46b5e28
fixed outtake direction
rayzhuca Feb 26, 2022
789bcae
fix
rayzhuca Feb 26, 2022
e8643f9
Added found values.
rayzhuca Feb 26, 2022
b3ca4dc
Merge branch 'outtake-auto' into develop
rayzhuca Feb 26, 2022
a5ed6c6
fixed bugz
rayzhuca Feb 27, 2022
f36e042
Removed bad mods
rayzhuca Feb 27, 2022
aef4b1b
Changed Optional to OptionalDouble
rayzhuca Feb 27, 2022
dac9175
Ball subsystem (important)
rayzhuca Feb 27, 2022
86db6fd
Rename runConveyor.java to RunConveyor.java
cqdowning Mar 1, 2022
73c6be8
Added commandgroup for aiming and shooting a ball
cqdowning Mar 1, 2022
21d2997
Merge branch 'develop' of https://github.com/FalconX-Robotics/roboRIO…
cqdowning Mar 1, 2022
019798f
Added autonomous manager
rayzhuca Mar 2, 2022
6020104
Made TurnAngle and DriveForward not reset sensors
rayzhuca Mar 2, 2022
8748411
Added more to autonomous manager
rayzhuca Mar 3, 2022
6f802ae
Fixed auto bugs
rayzhuca Mar 3, 2022
e96db1a
fixed auto bugz + merge
rayzhuca Mar 3, 2022
1277f41
Encoder methods created
cqdowning Mar 4, 2022
5ed8c25
Fixed auto bugs + improvements
rayzhuca Mar 5, 2022
ac9015d
correct encoder values
cqdowning Mar 12, 2022
f4f9733
some small changes (very descriptive)
cqdowning Mar 12, 2022
5896512
correct motor ports
rayzhuca Mar 15, 2022
5ba75ed
brakes
rayzhuca Mar 15, 2022
b8aa117
almost competition
rayzhuca Mar 19, 2022
019cfdd
Added manual shoot command
cqdowning Mar 21, 2022
71ead4b
fixes for encoder and outtake
cqdowning Mar 21, 2022
025973f
removed this crash from aimandshoot
FatCactis Oct 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,052 changes: 1,052 additions & 0 deletions shuffleboard.json

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
]
}
23 changes: 23 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/LiveWindow/Camera": "Subsystem",
"/LiveWindow/Connection": "Subsystem",
"/LiveWindow/Drivetrain": "Subsystem",
"/LiveWindow/Intake": "Subsystem",
"/LiveWindow/Led": "Subsystem",
"/LiveWindow/Outtake": "Subsystem",
"/LiveWindow/Ungrouped/DifferentialDrive[1]": "DifferentialDrive",
"/LiveWindow/Ungrouped/PIDController[1]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[2]": "PIDController",
"/LiveWindow/Ungrouped/Scheduler": "Scheduler",
"/SmartDashboard/Auto/Field": "Field2d",
"/SmartDashboard/Drivetrain/AutoShoot": "Command",
"/SmartDashboard/Drivetrain/Led Chooser": "String Chooser",
"/SmartDashboard/Drivetrain/Mod Chooser": "String Chooser",
"/SmartDashboard/Drivetrain/TurnAngle": "Command",
"/SmartDashboard/Drivetrain/TurnToTarget": "Command"
}
}
}
176 changes: 176 additions & 0 deletions src/main/java/frc/robot/AutonomousManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
package frc.robot;

import java.util.ArrayList;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
import frc.robot.commands.AimAndShoot;
import frc.robot.commands.DriveForward;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.TurnAngle;
import frc.robot.subsystems.Camera;
import frc.robot.subsystems.Connection;
import frc.robot.subsystems.Drivetrain;
import frc.robot.subsystems.Intake;
import frc.robot.subsystems.Outtake;

public class AutonomousManager {

public enum Path {
NONE, TAXI, ONE_BALL, ONE_BALL_TAXI, TWO_BALL_TAXI;
}

public enum InitialPose {
INVALID(new Pose2d(0, 0, Rotation2d.fromDegrees(0))),
A(new Pose2d(0, 0, Rotation2d.fromDegrees(0))),
B(new Pose2d(0, 0, Rotation2d.fromDegrees(0))),
C(new Pose2d(0, 0, Rotation2d.fromDegrees(0))),
D(new Pose2d(0, 0, Rotation2d.fromDegrees(0)));

public final Pose2d pose;

private InitialPose(Pose2d pose) {
this.pose = pose;
}
}

// field data
private final double FIELD_WIDTH = 8.23 * 2;
private final double FIELD_LENGTH = 16.46 * 2;
public final Translation2d CENTER_FIELD = new Translation2d(FIELD_WIDTH/2, FIELD_LENGTH/2);

public final InitialPose DEFAULT_INIT_POSE = InitialPose.INVALID;
public final Path DEFAULT_PATH = Path.NONE;

private final Command m_turnAndShoot;
@SuppressWarnings("unused") private final Command m_turnBack;
private final Command m_faceInward;
private final Command m_faceOutward;
@SuppressWarnings("unused") private final Command m_pause;

private final double TAXI_DRIVE_DISTANCE = 2.15;
private final double SHOOT_DISTANCE_FROM_CENTER = 3.2;

private Path m_path;
private Pose2d m_initPose;
private ArrayList<Ball> m_ballList;
private Drivetrain m_drivetrain;
private Intake m_intake;
private Connection m_connection;
private Outtake m_outtake;
private Camera m_camera;
private XboxController m_controller;

public AutonomousManager(Path path, Pose2d initPose, ArrayList<Ball> ballList, Drivetrain drivetrain, Intake intake, Connection connection, Outtake outtake, Camera camera, XboxController controller) {
m_path = path;
m_initPose = initPose;
m_ballList = ballList;
m_drivetrain = drivetrain;
m_intake = intake;
m_connection = connection;
m_outtake = outtake;
m_camera = camera;
m_controller = controller;

m_turnAndShoot = new AimAndShoot(m_drivetrain, m_connection, m_outtake, m_camera);
m_turnBack = new TurnAngle(() -> -m_drivetrain.getRotation().getDegrees(), m_drivetrain);
m_faceInward = TurnAngle.toRotation(() -> getAngleToCenter(), m_drivetrain);
m_faceOutward = TurnAngle.toRotation(() -> 180 - getAngleToCenter(), m_drivetrain);
m_pause = new WaitUntilCommand(() -> m_controller.getStartButton());
}

public AutonomousManager(Path path, InitialPose initPose, ArrayList<Ball> ballList, Drivetrain drivetrain, Intake intake, Connection connection, Outtake outtake, Camera camera, XboxController controller) {
this(path, initPose.pose, ballList, drivetrain, intake, connection, outtake, camera, controller);
}

public AutonomousManager(Drivetrain drivetrain, Intake intake, Connection connection, Outtake outtake, Camera camera, XboxController controller) {
this(Path.NONE, InitialPose.INVALID, new ArrayList<Ball>(), drivetrain, intake, connection, outtake, camera, controller);
}

public Ball getClosestBall() {
Alliance alliance = DriverStation.getAlliance(); // works in comp?
return Ball.getClosestBallTo(m_ballList, alliance, alliance == Alliance.Blue, m_initPose.getTranslation());
}

public double getAngleToBall() {
Ball ball = getClosestBall();
Translation2d v = ball.m_position.plus(m_drivetrain.getPose().getTranslation().unaryMinus());
return Math.atan2(v.getY(), v.getX())*(160./Math.PI);
}

public double getDistanceToBall() {
Ball ball = getClosestBall();
return ball.m_position.getDistance(m_drivetrain.getPose().getTranslation());
}

public double getAngleToCenter() {
Pose2d pose = m_drivetrain.getPose();
Translation2d v = pose.getTranslation().plus(CENTER_FIELD.unaryMinus());
double a = Math.atan2(v.getY(), v.getX()) * (160 / Math.PI);
return a + 180; // + 180 to face inward instead of outward
}

public double getDistanceFromCenter(double d) {
Pose2d pose = m_drivetrain.getPose();
return CENTER_FIELD.getDistance(pose.getTranslation()) - d;
}

private Command getCommand(Path path) {
switch (path) {
case TAXI: // assumes to be facing outwards
return new SequentialCommandGroup(m_faceOutward, new DriveForward(TAXI_DRIVE_DISTANCE, m_drivetrain));
case ONE_BALL: // assumes to be facing towards center
return new SequentialCommandGroup(m_faceInward, m_turnAndShoot);
case ONE_BALL_TAXI: // assumes to be facing towards center
return new SequentialCommandGroup(getCommand(Path.ONE_BALL), getCommand(Path.TAXI));
case TWO_BALL_TAXI: // assumes to be facing same as ONE_BALL_TAXI
return new SequentialCommandGroup(
getCommand(Path.ONE_BALL_TAXI),
TurnAngle.toRotation(this::getAngleToBall, m_drivetrain),
new ParallelDeadlineGroup(new DriveForward(() -> getDistanceToBall() + 0.3, m_drivetrain), new IntakeCommand(m_intake)),
m_faceInward,
new DriveForward(() -> getDistanceFromCenter(SHOOT_DISTANCE_FROM_CENTER), m_drivetrain),
m_turnAndShoot);
default:
return new InstantCommand();
}
}

public Command getCommand() {
if (m_initPose.equals(InitialPose.INVALID.pose)) return new InstantCommand();
return getCommand(m_path);
}

public void setPath(Path path) {
m_path = path;
}

public void setInitPose(Pose2d pose) {
m_initPose = pose;
}

public void setInitPose(InitialPose pose) {
setInitPose(pose.pose);
}

public void addBalls(Ball... balls) {
for (Ball ball : balls) {
m_ballList.add(ball);
}
}

public void resetSensors() {
m_drivetrain.resetEncoder();
m_drivetrain.resetGyroYaw();
m_drivetrain.setOdometry(m_initPose, m_drivetrain.getRotation());
}
}
43 changes: 43 additions & 0 deletions src/main/java/frc/robot/Ball.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package frc.robot;

import java.util.ArrayList;

import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.wpilibj.DriverStation.Alliance;

public class Ball {
public final Alliance m_alliance;
public final Translation2d m_position;
public final boolean m_blueSide;

/**
* Represents a ball on the field
*
* @param alliance The alliance the ball belongs to
* @param translation The (x, y) coordinates of the ball. (0, 0) is the bottom left corner of the field
* @param blueSide If the ball is on the side of the blue alliance. True is left side of slant, false is right side of slant
*/
public Ball(Alliance alliance, Translation2d translation, boolean blueSide) {
m_alliance = alliance;
m_position = translation;
m_blueSide = blueSide;
}

public boolean isBall() {
return true;
}

public static Ball getClosestBallTo(ArrayList<? extends Ball> balls, Alliance alliance, boolean blueSide, Translation2d position) {
Ball closestBall = null;
double closestDistance = Double.MAX_VALUE;
for (Ball ball : balls) {
if (ball.m_alliance != alliance || ball.m_blueSide != blueSide) continue;
double distance = ball.m_position.getDistance(position);
if (distance < closestDistance) {
closestBall = ball;
closestDistance = distance;
}
}
return closestDistance == Double.MAX_VALUE ? null : closestBall;
}
}
49 changes: 45 additions & 4 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,55 @@

package frc.robot;

import edu.wpi.first.math.kinematics.DifferentialDriveKinematics;

/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
* constants. This class should not be used for any other purpose. All constants should be declared
* The Constants class provides a convenient place for teams to hold robot-wide
* numerical or boolean
* constants. This class should not be used for any other purpose. All constants
* should be declared
* globally (i.e. public static). Do not put anything functional in this class.
*
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
* <p>
* It is advised to statically import this class (or one of its inner classes)
* wherever the
* constants are needed, to reduce verbosity.
*/
public final class Constants {

// piegon ports
public final static int PIGEON_PORT = 42;

// left ports
public final static int LEFT_FRONT_MOTOR_PORT = 4;
public final static int LEFT_BACK_MOTOR_PORT = 1;

// right ports
public final static int RIGHT_FRONT_MOTOR_PORT = 7;
public final static int RIGHT_BACK_MOTOR_PORT = 2;

// controller port
public final static int CONTROLLER_PORT = 0;

// INTAKE_PORT
public final static int INTAKE_PORT = 3; // random value; change later
public final static int INTAKE_ARM_MOTOR = 5; //again, random value

// top and bottom ports
public final static int TOP_PORT = 9; // random value; change later
public final static int BOTTOM_PORT = 8; // random value; change later

// conveyor motor port
public final static int CONNECTION_PORT = 6;

// led controller port
public final static int LED_CONTROLLER_PORT = 9;

public static final double DRIVETRAIN_S = 0;

public static final double DRIVETRAIN_V = 0;

public static final double DRIVETRAIN_A = 0;

public static final DifferentialDriveKinematics DRIVE_KINEMATICS = null;

}
Loading