Skip to content

Commit

Permalink
Merge branch 'master' into camera-skt
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiggy authored Apr 23, 2024
2 parents 66807dd + b3acee2 commit 9dfd743
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# All PRs need to be approved by a member of the reviewers team
# Note that for this to work, the repository's access settings (https://github.com/DeepBlueRobotics/RobotCode2024/settings/access)
# need to be configured to allow the reviewers team (or a parent team like devs) to explicitly have write (or higher) access.
# It isn't sufficient for all org members to have write access.
* @DeepBlueRobotics/reviewers
20 changes: 20 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Java CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Build with Gradle
run: ./gradlew build
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
simulationRelease wpi.sim.enableRelease()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
implementation "com.github.deepbluerobotics:lib199:0e5932a4219f3439ef2be3981a9189baf777f61e"
implementation "com.github.deepbluerobotics:lib199:0ce129844b9b918dad0207c0e1020fc26588f461"
}

test {
Expand Down
7 changes: 4 additions & 3 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
"incKey": 75
}
],
"axisCount": 2,
"axisCount": 5,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
"povCount": 1
},
{
"axisConfig": [
Expand Down Expand Up @@ -97,7 +97,8 @@
"useGamepad": true
},
{
"guid": "Keyboard1"
"guid": "Keyboard1",
"name": "Manipulator"
}
]
}
8 changes: 8 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
}
},
"Other Devices": {
"AbsoluteEncoder[13]": {
"header": {
"open": true
}
},
"CANCoder (v6)[2]": {
"header": {
"open": true
Expand Down Expand Up @@ -63,6 +68,9 @@
"NetworkTables": {
"transitory": {
"SmartDashboard": {
"Arm": {
"open": true
},
"BL": {
"open": true
},
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/carlmontrobotics/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ public static final class Limelightc {
public static final class Apriltag {
public static final int RED_SPEAKER_CENTER_TAG_ID = 4;
public static final int BLUE_SPEAKER_CENTER_TAG_ID = 7;
public static final double SPEAKER_CENTER_HEIGHT_METERS = Units.inchesToMeters(56.7); // 88.125
public static final double SPEAKER_CENTER_HEIGHT_METERS = Units.inchesToMeters(56.7); //88.125
public static final double HEIGHT_FROM_BOTTOM_TO_SUBWOOFER = Units.inchesToMeters(26);
public static final double HEIGHT_FROM_BOTTOM_TO_ARM_RESTING = Units.inchesToMeters(21.875);
}
}

Expand Down
43 changes: 0 additions & 43 deletions src/main/java/org/carlmontrobotics/commands/AimArmSpeaker.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/main/java/org/carlmontrobotics/commands/AimAtSpeaker.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package org.carlmontrobotics.commands;

import static org.carlmontrobotics.Constants.Limelightc.*;

import org.carlmontrobotics.Constants.Limelightc;

import static org.carlmontrobotics.Constants.Effectorc.*;

import org.carlmontrobotics.subsystems.Drivetrain;
Expand Down Expand Up @@ -47,8 +50,8 @@ public void initialize() {

@Override
public void execute() {
double angleErrRad = Units.degreesToRadians(LimelightHelpers.getTX(INTAKE_LL_NAME));
double forwardDistErrMeters = ll.getDistanceToNoteMeters();
double angleErrRad = Units.degreesToRadians(LimelightHelpers.getTX(Limelightc.INTAKE_LL_NAME));
double forwardDistErrMeters = ll.getDistanceToNoteMeters();
double strafeDistErrMeters = forwardDistErrMeters * Math.tan(angleErrRad);
// dt.drive(0,0,0);
dt.drive(Math.max(forwardDistErrMeters * 2, MIN_MOVEMENT_METERSPSEC),
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/org/carlmontrobotics/commands/MoveToNote.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 org.carlmontrobotics.commands;

import org.carlmontrobotics.Constants.Limelightc;
import org.carlmontrobotics.subsystems.Drivetrain;
import org.carlmontrobotics.subsystems.Limelight;
import org.carlmontrobotics.subsystems.LimelightHelpers;

import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;

public class MoveToNote extends Command {
private final Drivetrain dt;
private final Limelight ll;
private Timer timer = new Timer();
private boolean originalFieldOrientation;
/** Creates a new MoveToNote. */
public MoveToNote(Drivetrain dt, Limelight ll) {
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(this.dt=dt);
this.ll = ll;
}

// Called when the command is initially scheduled.
@Override
public void initialize() {
originalFieldOrientation = dt.getFieldOriented();
timer.reset();
timer.start();
dt.setFieldOriented(false);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
double radErr = Units.degreesToRadians(LimelightHelpers.getTX(Limelightc.INTAKE_LL_NAME));
double distErr = ll.getDistanceToNoteMeters(); //meters
double forwardErr = distErr * Math.cos(radErr);
dt.drive(Math.max(forwardErr*2, .5), 0, 0);
//180deg is about 6.2 rad/sec, min is .5rad/sec
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
dt.setFieldOriented(originalFieldOrientation);
}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return timer.get() >= 0.5;
}
}
15 changes: 15 additions & 0 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.revrobotics.SparkAbsoluteEncoder;
import com.revrobotics.SparkPIDController;

import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.ArmFeedforward;
import edu.wpi.first.math.trajectory.TrapezoidProfile;
Expand All @@ -30,9 +31,11 @@
import edu.wpi.first.units.Voltage;
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.simulation.SimDeviceSim;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.sysid.SysIdRoutineLog;
import edu.wpi.first.wpilibj2.command.Command;
Expand Down Expand Up @@ -76,6 +79,9 @@ public class Arm extends SubsystemBase {

private ShuffleboardTab sysIdTab = Shuffleboard.getTab("arm SysID");
private boolean setPIDOff;

private SimDouble rotationsSim;

public Arm() {
// weird math stuff
armMotorMaster.setInverted(MOTOR_INVERTED_MASTER);
Expand Down Expand Up @@ -145,6 +151,9 @@ public Arm() {
armMotorFollower.setSmartCurrentLimit(80);

SmartDashboard.putBoolean("arm is at pos", false);
if (RobotBase.isSimulation()) {
rotationsSim = new SimDeviceSim("AbsoluteEncoder", ARM_MOTOR_PORT_MASTER).getDouble("rotations");
}
}

public void setBooleanDrive(boolean climb) {
Expand Down Expand Up @@ -430,4 +439,10 @@ public void setDefaultCommand(TeleopArm teleopArm, Object object) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'setDefaultCommand'");
}

@Override
public void simulationPeriodic() {
// Fake goaling to the goal instantaneously
rotationsSim.set((goalState.position + armMasterEncoder.getZeroOffset()) / armMasterEncoder.getPositionConversionFactor());
}
}

0 comments on commit 9dfd743

Please sign in to comment.