Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9c89a6b
problems
cookieandrew Jan 21, 2023
e23d6ba
new
cookieandrew Jan 21, 2023
3cc8adc
new new
RundleRoboticsGithub Jan 21, 2023
58b2e5f
new new new new
RundleRoboticsGithub Jan 21, 2023
15c4805
new new new new new
cookieandrew Jan 25, 2023
eba3fed
new x10 to the 2
RundleRoboticsGithub Jan 25, 2023
5edbb34
limelight Area targeting
cookieandrew Jan 28, 2023
0d3be4d
limelight drive closer draft (new new new new new)
cookieandrew Jan 31, 2023
ebb2f57
added ta thing
cookieandrew Jan 31, 2023
15b1a55
neo thing. unimportant do not return
cookieandrew Jan 31, 2023
9698ee5
reduced motor spinning speed
RundleRoboticsGithub Feb 1, 2023
8d836b9
limelight code Functions
cookieandrew Feb 1, 2023
583edde
garbage
RundleRoboticsGithub Feb 3, 2023
4afc959
Limelight new new new with added new
RundleRoboticsGithub Feb 3, 2023
c266d94
Merge branch 'limelight2.0' of https://github.com/Rundle-Robotics/202…
RundleRoboticsGithub Feb 3, 2023
f3a5376
Fix horrendous formatting
damians13 Feb 3, 2023
8d843ef
Add cap() and print statements
damians13 Feb 3, 2023
5106392
Simplify execute
damians13 Feb 3, 2023
4a32e0e
Simplify execute
damians13 Feb 3, 2023
419998e
Merge branch 'limelight2.0' of https://github.com/Rundle-Robotics/202…
damians13 Feb 3, 2023
e848e04
small fixes
RundleRoboticsGithub Feb 4, 2023
9ae16f0
Limelight Auto Update
cookieandrew Feb 7, 2023
c723bd9
new changes limelight with drivetrain
RundleRoboticsGithub Feb 8, 2023
71c17a7
Add pipeline switching
damians13 Feb 10, 2023
5e7a13a
Mostly wokrs
RundleRoboticsGithub Feb 10, 2023
84d3c9d
Limelight methods working
RundleRoboticsGithub Feb 11, 2023
b5362c3
TSHORT TLONG UPDATES
cookieandrew Feb 11, 2023
67b3cf5
TCORNXY
cookieandrew Feb 11, 2023
a48a5e4
idek and idec
cookieandrew Feb 11, 2023
5e05c70
ODD UPDATES
RundleRoboticsGithub Feb 11, 2023
4cabc44
i should be an engineer
RundleRoboticsGithub Feb 11, 2023
37da313
Add debug code for SmartDashboard
damians13 Feb 11, 2023
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.1.1"
id "edu.wpi.first.GradleRIO" version "2023.2.1"
}

sourceCompatibility = JavaVersion.VERSION_11
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public final class Constants {

public static class OperatorConstants {
public static final int DRIVER_CONTROLLER_PORT = 0;
public static final int DRIVER_CONTROLLER_PORT = 1;
public static final int XBOX_LEFT_Y_AXIS = 1;
public static final int XBOX_RIGHT_Y_AXIS = 5;
public static final int XBOX_LEFT_X_AXIS = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
public class RobotContainer {
// Replace with CommandPS4Controller or CommandJoystick if needed
private final CommandXboxController driverController = new CommandXboxController(
OperatorConstants.DRIVER_CONTROLLER_PORT);
public static final CommandXboxController driverController = new CommandXboxController(
OperatorConstants.DRIVER_CONTROLLER_PORT);

// The robot's subsystems and commands are defined here...
private final Drivetrain drivetrain = new Drivetrain(driverController);
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/frc/robot/commands/LimelightFollow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.Drivetrain;

public class LimelightFollow extends CommandBase {
/** Creates a new LimelightFollow. */


private Drivetrain drivetrain;



public LimelightFollow(Drivetrain drivetrain) {
this.drivetrain = drivetrain;

addRequirements(drivetrain);

}

// Called when the command is initially scheduled.
@Override
public void initialize() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//add actions here that should be run once at the start of the Limelight follow sequence
//eg LEDs, pipelines, drivetrain...


// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//run an action you want to run periodically here for as long as the command is active.
//make calls to the limelight subsystem to get info, do whatever math you want, and then send info to the drivetrain


// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//run any cleanup here. LEDs, pipelines, drivetrain?


// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
77 changes: 28 additions & 49 deletions src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,86 +4,65 @@

package frc.robot.subsystems;

import com.revrobotics.CANSparkMax;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;


import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj.motorcontrol.Spark;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Constants.ControlConstants;
import frc.robot.Constants.OperatorConstants;


public class Drivetrain extends SubsystemBase {

private MotorController frontLeft;
private MotorController frontRight;
private MotorController backLeft;
private MotorController backRight;
private CommandXboxController controller;

private MotorControllerGroup leftMotors;
private MotorControllerGroup rightMotors;
private DifferentialDrive drive;

public Drivetrain(CommandXboxController controller) {
this.controller = controller;

frontLeft = new CANSparkMax(0, MotorType.kBrushless);
frontRight = new CANSparkMax(1, MotorType.kBrushless);
backLeft = new CANSparkMax(2, MotorType.kBrushless);
backRight = new CANSparkMax(3, MotorType.kBrushless);
frontLeft = new Spark(0);
frontRight = new Spark(2);
backLeft = new Spark(1);
backRight = new Spark(3);

leftMotors = new MotorControllerGroup(frontLeft,backLeft);
rightMotors = new MotorControllerGroup(frontRight, backRight);

rightMotors.setInverted(true);

drive = new DifferentialDrive(leftMotors, rightMotors);

frontRight.setInverted(true);
backRight.setInverted(true);
}

@Override
public void periodic() {
double joyX = controller.getRawAxis(OperatorConstants.XBOX_LEFT_X_AXIS);
double joyY = -controller.getRawAxis(OperatorConstants.XBOX_LEFT_Y_AXIS);
double rotation = ControlConstants.ROTATION_MULT
* (controller.getRightTriggerAxis() - controller.getLeftTriggerAxis());
double move = controller.getLeftTriggerAxis();
double turn = controller.getLeftX();

mecanumDrive(joyX, joyY, rotation);
drive.arcadeDrive(move, turn);
}

// 2020 mecanum drive code
public void mecanumDrive(double joystickX, double joystickY, double rotation) {
// Deadband inputs
if (Math.abs(rotation) < ControlConstants.ROTATION_DEADBAND)
rotation = 0;
if (Math.abs(joystickX) < ControlConstants.JOY_DEADBAND)
joystickX = 0;
if (Math.abs(joystickY) < ControlConstants.JOY_DEADBAND)
joystickY = 0;

// Cap rotation to ControlConstants value
if (Math.abs(rotation) > ControlConstants.MAX_TURN_SPEED)
rotation *= ControlConstants.MAX_TURN_SPEED / Math.abs(rotation);

// Calculate speed for each wheel
double frontRightPower = joystickY - joystickX - rotation;
double frontLeftPower = joystickY + joystickX + rotation;
double backLeftPower = joystickY - joystickX + rotation;
double backRightPower = joystickY + joystickX - rotation;

// Cap motor powers
if (Math.abs(frontLeftPower) > ControlConstants.MAX_ROBOT_SPEED)
frontLeftPower *= ControlConstants.MAX_ROBOT_SPEED / Math.abs(frontLeftPower);
if (Math.abs(frontRightPower) > ControlConstants.MAX_ROBOT_SPEED)
frontRightPower *= ControlConstants.MAX_ROBOT_SPEED / Math.abs(frontRightPower);
if (Math.abs(backLeftPower) > ControlConstants.MAX_ROBOT_SPEED)
backLeftPower *= ControlConstants.MAX_ROBOT_SPEED / Math.abs(backLeftPower);
if (Math.abs(backRightPower) > ControlConstants.MAX_ROBOT_SPEED)
backRightPower *= ControlConstants.MAX_ROBOT_SPEED / Math.abs(backRightPower);

// Power the motors
frontLeft.set(frontLeftPower);
frontRight.set(frontRightPower);
backLeft.set(backLeftPower);
backRight.set(backRightPower);
}



public void stop() {
frontLeft.set(0);
frontRight.set(0);
backLeft.set(0);
backRight.set(0);
}
public static void setSpeeds(double forwardSpeed, double rotationSpeed){

}
}
74 changes: 74 additions & 0 deletions src/main/java/frc/robot/subsystems/Limelight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot.subsystems;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.RobotContainer;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.XboxController;

public class Limelight extends SubsystemBase {
private NetworkTable table;

private double tx;
private double ty;
private double apriltagid;


/** Creates a new Limelight. */
public Limelight() {
table = NetworkTableInstance.getDefault().getTable("limelight");
disableLimelight();


}

public void enableLimelight() {
table.getEntry("ledMode").setNumber(3);
}
public void disableLimelight() {
table.getEntry("ledMode").setNumber(1);
}

@Override
public void periodic() {
tx = table.getEntry("tx").getDouble(0.0);
ty = table.getEntry("ty").getDouble(0.0);




apriltagid = table.getEntry("tid").getDouble(0.0);

SmartDashboard.putNumber("x offset", tx);
SmartDashboard.putNumber("y offset", ty);

SmartDashboard.putNumber("TId", apriltagid);

limelightCenter();

}

public double getTX(){
return table.getEntry("tx").getDouble(0);
}
public void limelightCenter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove method

enableLimelight();
if (RobotContainer.driverController.getHID().getBButton()) {

if (tx != 2) {
Drivetrain.setSpeeds(0, .1);
}
}



}


}