-
Notifications
You must be signed in to change notification settings - Fork 0
Limelight2.0 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Limelight2.0 #4
Changes from 4 commits
9c89a6b
e23d6ba
3cc8adc
58b2e5f
15c4805
eba3fed
5edbb34
0d3be4d
ebb2f57
15b1a55
9698ee5
8d836b9
583edde
4afc959
c266d94
f3a5376
8d843ef
5106392
4a32e0e
419998e
e848e04
9ae16f0
c723bd9
71c17a7
5e7a13a
84d3c9d
b5362c3
67b3cf5
a48a5e4
5e05c70
4cabc44
37da313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() {} | ||
|
||
|
|
||
| // Called every time the scheduler runs while the command is scheduled. | ||
| @Override | ||
| public void execute() {} | ||
|
||
|
|
||
| // Called once the command ends or is interrupted. | ||
| @Override | ||
| public void end(boolean interrupted) {} | ||
|
||
|
|
||
| // Returns true when the command should end. | ||
| @Override | ||
| public boolean isFinished() { | ||
| return false; | ||
| } | ||
| } | ||
| 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(); | ||
ishanvermani marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
|
|
||
| public double getTX(){ | ||
| return table.getEntry("tx").getDouble(0); | ||
| } | ||
| public void limelightCenter() { | ||
|
||
| enableLimelight(); | ||
| if (RobotContainer.driverController.getHID().getBButton()) { | ||
|
|
||
| if (tx != 2) { | ||
| Drivetrain.setSpeeds(0, .1); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.