Skip to content
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

2024 beta changes #4

Merged
merged 59 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
fea4a73
Initial 2024 updates, removed some houndauto things
superpenguin612 Oct 26, 2023
99aba98
Add struct support and updates for PathPlanner
superpenguin612 Dec 21, 2023
2df2dd4
Add Virpil OI
superpenguin612 Dec 21, 2023
fdd4d64
Add base subsystem interfaces
superpenguin612 Dec 21, 2023
c6132ad
rm DeferredCommand
superpenguin612 Dec 21, 2023
369c91d
Do not require triconsumer on HoundRobot
superpenguin612 Dec 21, 2023
f3234ff
Create CoaxialSwerveModule interface and update NEOCoaxialSwerveModule
superpenguin612 Dec 21, 2023
1add9da
Add MotorHoldMode
superpenguin612 Dec 21, 2023
ee16e93
Do not require name for @Log, instead infer based on var name
superpenguin612 Dec 21, 2023
9266cc0
Remove autosettings
superpenguin612 Dec 23, 2023
8ec890e
Update physical values for virpil + add flip trigger
superpenguin612 Dec 23, 2023
4072e8b
Run logging at 50hz
superpenguin612 Dec 23, 2023
6040d86
Add basevision
superpenguin612 Dec 23, 2023
e61cd4f
Add ChassisSpeeds to BaseSwerveDrive
superpenguin612 Dec 23, 2023
fd83de4
Conversions to SwerveConstants
superpenguin612 Dec 23, 2023
02b470e
Change logging + spark max configurator
superpenguin612 Dec 23, 2023
dae2bfc
New logging
superpenguin612 Dec 23, 2023
8814337
Do not generate new table if blank subsystem to avoid issues
superpenguin612 Dec 23, 2023
5bc05f4
Bugfixes to annotations
superpenguin612 Dec 23, 2023
00a6f78
Add class register to LoggingManager
superpenguin612 Dec 23, 2023
442dba9
Redo profiles and add Phoenix 6 devices
superpenguin612 Dec 23, 2023
3f14f4f
Delete phoenix5 vendordep
superpenguin612 Dec 23, 2023
f16543f
Update CI for 2024 beta
superpenguin612 Dec 23, 2023
3661324
Update to 2024.1.1-beta-4
superpenguin612 Dec 23, 2023
b6b45dc
Merge branch '2024-beta' of https://github.com/frc868/houndutil into …
superpenguin612 Dec 23, 2023
46cfd4b
Remove unused features
superpenguin612 Jan 2, 2024
10177a4
Fix virpil axes
superpenguin612 Jan 7, 2024
b20bf18
Kraken swerve first pass
superpenguin612 Jan 7, 2024
42397d8
high-fidelity swerve sim + REVLib updates
superpenguin612 Jan 7, 2024
250d818
rename swerve path following commands
superpenguin612 Jan 7, 2024
3493c0d
use PhotonCameraConstants
superpenguin612 Jan 7, 2024
95d1b69
SparkMaxConfigurator -> SparkConfigurator
superpenguin612 Jan 7, 2024
7b192e6
REVLib updates
superpenguin612 Jan 7, 2024
8d8e648
REVLib
superpenguin612 Jan 7, 2024
c06ddc4
Hotfix to HoundRobot for AutoManager compat
superpenguin612 Jan 7, 2024
93840f3
Update to 2024.1.1
superpenguin612 Jan 7, 2024
dc35e77
Update vendordeps
superpenguin612 Jan 7, 2024
90ab277
Update sendablelogger to use NT4
superpenguin612 Jan 7, 2024
a5add13
Add DCMotorSim
superpenguin612 Jan 7, 2024
47df666
Log loop time
superpenguin612 Jan 7, 2024
12605b5
Revlib updates
superpenguin612 Jan 7, 2024
33d0c94
Update photonlib vendordep
superpenguin612 Jan 9, 2024
5e28662
Add drive motor voltage getter for SysId
superpenguin612 Jan 9, 2024
b75f61d
Add more talonfx telemetry
superpenguin612 Jan 9, 2024
20909ee
Add motion magic control to kraken and fix units
superpenguin612 Jan 9, 2024
3c121c2
Update navx and pathplannerlib vendordeps
superpenguin612 Jan 9, 2024
074e85f
Fix vendordeps
superpenguin612 Jan 10, 2024
576054b
NEOCoaxialSwerveModule IRL fixes
superpenguin612 Jan 10, 2024
d0c26c6
Merge branch '2024-beta' of https://github.com/frc868/houndutil into …
superpenguin612 Jan 10, 2024
1db07f6
More accurate simulation
superpenguin612 Jan 12, 2024
0ef13a1
SPARK Flex logging
superpenguin612 Jan 12, 2024
b45f2a3
Add CANSparkFlex as a supported annotation log
superpenguin612 Jan 12, 2024
0f6b772
Update apriltagphotoncamera
superpenguin612 Jan 20, 2024
ece1661
Use MotionMagic on kraken
superpenguin612 Jan 20, 2024
73dc9e8
Update logitems to only log when chagned
superpenguin612 Jan 20, 2024
5cfd996
Add singlejointedarmsim to logging
superpenguin612 Jan 20, 2024
1e13a19
Merge branch '2024-beta' of https://github.com/frc868/houndutil into …
superpenguin612 Jan 20, 2024
53a12fd
Merge branch 'main' into 2024-beta
superpenguin612 Jan 20, 2024
f899213
Update photonvision
superpenguin612 Jan 20, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest

# This grabs the WPILib docker container
container: wpilib/roborio-cross-ubuntu:2023-22.04
container: wpilib/roborio-cross-ubuntu:2024-22.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,15 @@ gradle-app.setting
.settings/
bin/

# IntelliJ
*.iml
*.ipr
*.iws
.idea/
out/

# Fleet
.fleet

# Simulation GUI and other tools window save file
*-window.json
2 changes: 1 addition & 1 deletion .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2023",
"projectYear": "2024",
"teamNumber": 868
}
2 changes: 1 addition & 1 deletion WPILib-License.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2021 FIRST and other WPILib contributors
Copyright (c) 2009-2023 FIRST and other WPILib contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.2.1"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

def ROBOT_MAIN_CLASS = ""

Expand Down Expand Up @@ -84,6 +86,7 @@ wpi.sim.addDriverstation()
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from sourceSets.main.allSource
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=permwrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=permwrapper/dists
35 changes: 22 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
5 changes: 4 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2023'
String frcYear = '2024'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')
Expand All @@ -25,3 +25,6 @@ pluginManagement {
}
}
}

Properties props = System.getProperties();
props.setProperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true");
134 changes: 41 additions & 93 deletions src/main/java/com/techhounds/houndutil/houndauto/AutoManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import com.pathplanner.lib.PathPlannerTrajectory;
import com.pathplanner.lib.path.PathPlannerPath;
import com.pathplanner.lib.path.PathPlannerTrajectory;
import com.techhounds.houndutil.houndlog.LogGroup;
import com.techhounds.houndutil.houndlog.LoggingManager;
import com.techhounds.houndutil.houndlog.enums.LogType;
import com.techhounds.houndutil.houndlog.loggers.SendableLogger;
import com.techhounds.houndutil.houndlog.logitems.DoubleLogItem;
import com.techhounds.houndutil.houndlog.logitems.StringLogItem;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.trajectory.Trajectory;
import edu.wpi.first.math.kinematics.ChassisSpeeds;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.smartdashboard.Field2d;
Expand All @@ -31,20 +30,11 @@ public class AutoManager {
private AutoRoutine lastRoutine;
private SendableChooser<AutoRoutine> chooser = new SendableChooser<AutoRoutine>();
private Field2d field = new Field2d();
private Command scheduledCommand;
private Command baseCommand;
private Command currentCommand;
private Consumer<Pose2d> resetOdometryConsumer;
private HashMap<String, Command> eventMap = new HashMap<String, Command>();

private Command currentCommand;
private AutoPath currentAutoPath;

private AutoSettingChooser[] autoSettingChoosers = new AutoSettingChooser[] {
new AutoSettingChooser(),
new AutoSettingChooser(),
new AutoSettingChooser(),
new AutoSettingChooser()
};

private Timer timer = new Timer();

/**
Expand All @@ -53,7 +43,8 @@ public class AutoManager {
* the chooser.
*/
private AutoManager() {
lastRoutine = chooser.getSelected();
// lastRoutine = chooser.getSelected();
chooser.setDefaultOption("None", new AutoRoutine("None", Commands.print("Waiting...")));
setupShuffleboardTab();
}

Expand Down Expand Up @@ -111,89 +102,44 @@ public void setResetOdometryConsumer(Consumer<Pose2d> consumer) {
* Create a Shuffleboard tab with the field and chooser objects.
*/
public void setupShuffleboardTab() {
LoggingManager.getInstance().addGroup("Autonomous",
LoggingManager.getInstance().addGroup("autonomous",
new LogGroup(
new DoubleLogItem("Timer", timer::get, LogType.NT),
new SendableLogger("Field", field),
new SendableLogger("Chooser", chooser),
new SendableLogger("Auto Setting Value #1", autoSettingChoosers[0]),
new SendableLogger("Auto Setting Value #2", autoSettingChoosers[1]),
new SendableLogger("Auto Setting Value #3", autoSettingChoosers[2]),
new SendableLogger("Auto Setting Value #4", autoSettingChoosers[3]),
new StringLogItem("Auto Setting #1", () -> autoSettingChoosers[0].getName(), LogType.NT),
new StringLogItem("Auto Setting #2", () -> autoSettingChoosers[1].getName(), LogType.NT),
new StringLogItem("Auto Setting #3", () -> autoSettingChoosers[2].getName(), LogType.NT),
new StringLogItem("Auto Setting #4", () -> autoSettingChoosers[3].getName(), LogType.NT),
new SendableLogger("Generate Routine",
Commands.runOnce(this::generateSelectedRoutine)
.withName("Generate Routine")
.ignoringDisable(true))));
}

public void setAutoSettingChoosers(List<AutoSetting> settings) {
for (int i = 0; i < settings.size(); i++) {
autoSettingChoosers[i].setAutoSetting(settings.get(i));
}

for (int i = settings.size(); i < 4; i++) {
autoSettingChoosers[i].clearAutoSetting();
}
}

public void generateSelectedRoutine() {
for (AutoSettingChooser chooser : autoSettingChoosers) {
chooser.updateSetting();
}
AutoRoutine selectedRoutine = getSelectedRoutine();
if (resetOdometryConsumer != null) {
try {
resetOdometryConsumer.accept(selectedRoutine.getInitialPosition());
} catch (Exception e) {
DriverStation.reportError("Error resetting odometry: " + e.getMessage(), true);
}

Optional<AutoPath> autoPathOpt = selectedRoutine.getAutoPath();
if (autoPathOpt.isPresent()) {
currentAutoPath = autoPathOpt.orElseThrow();
try {
currentCommand = selectedRoutine.getCommand(currentAutoPath);
} catch (Exception e) {
DriverStation.reportError(
"[houndauto] Failure creating autonomous command! This is likely due to a configuration error. "
+ e.getMessage(),
true);
return;
}
displayAutoPath(currentAutoPath);
}
}
new DoubleLogItem("autoTimer", timer::get, LogType.NT),
new SendableLogger("field", field),
new SendableLogger("chooser", chooser)));
}

/**
* Updates the Shuffleboard visualization with the new selected auton path. This
* should be put in {@code disabledPeriodic()}.
*/
public void periodicUpdate(boolean ignoreLastTrajCheck) {
if (lastRoutine != getSelectedRoutine()) {
setAutoSettingChoosers(getSelectedRoutine().getAutoSettings());
lastRoutine = getSelectedRoutine();
public void periodicUpdate() {
AutoRoutine selectedRoutine = getSelectedRoutine();
if (getSelectedRoutine() != lastRoutine) {
if (resetOdometryConsumer != null) {
resetOdometryConsumer.accept(selectedRoutine.getInitialPose());
}
if (selectedRoutine.getPathPlannerPaths() != null)
displayPaths(selectedRoutine.getPathPlannerPaths());
lastRoutine = selectedRoutine;
}
}

/**
* Display the selected routine's trajectories on the field object.
*/
public void displayAutoPath(AutoPath autoPath) {
if (getSelectedRoutine() != null) {
ArrayList<PathPlannerTrajectory> trajectories = autoPath.getTrajectories();
Trajectory fullTrajectory = trajectories.get(0);
for (int i = 1; i < trajectories.size(); i++) {
fullTrajectory = fullTrajectory.concatenate(trajectories.get(i));
}
field.getObject("Autonomous Routine")
.setTrajectory(fullTrajectory);
public void displayPaths(List<PathPlannerPath> paths) {
ArrayList<Pose2d> poses = new ArrayList<Pose2d>();
for (PathPlannerPath path : paths) {
PathPlannerTrajectory trajectory = path.getTrajectory(new ChassisSpeeds(),
path.getStartingDifferentialPose().getRotation());

poses.addAll(trajectory.getStates().stream()
.map((state) -> new Pose2d(state.positionMeters, state.targetHolonomicRotation))
.collect(Collectors.toList()));
}

field.getObject("trajectory").setPoses(poses);
}

/**
Expand All @@ -209,19 +155,21 @@ public void runSelectedRoutine() {
if (this.getSelectedRoutine() == null) {
DriverStation.reportError("[houndauto] An auto routine must be chosen.", false);
} else {

// the line after this makes the autoroutine command a composition, and
// commands that are in a composition cannot be recomposed, which is what this
// would do if auto is run multiple times. this fixes it by removing the
// composition from the scheduler.
CommandScheduler.getInstance().removeComposedCommand(scheduledCommand);
CommandScheduler.getInstance().removeComposedCommand(baseCommand);

baseCommand = getSelectedRoutine().getCommand();

timer.reset();
timer.start();
Command toRun = currentCommand
.beforeStarting(() -> resetOdometryConsumer.accept(getSelectedRoutine().getInitialPosition()));
toRun.schedule();
new Trigger(toRun::isFinished).onTrue(Commands.runOnce(timer::stop).ignoringDisable(true));
currentCommand = baseCommand
.beforeStarting(() -> resetOdometryConsumer.accept(getSelectedRoutine().getInitialPose()))
.withName("auto");
currentCommand.schedule();
new Trigger(currentCommand::isFinished).onTrue(Commands.runOnce(timer::stop).ignoringDisable(true));
}
}

Expand All @@ -230,8 +178,8 @@ public void runSelectedRoutine() {
*/
public void endRoutine() {
timer.stop();
if (scheduledCommand != null) {
scheduledCommand.cancel();
if (currentCommand != null) {
currentCommand.cancel();
}
}

Expand Down
Loading