Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8aa8401
first pass at swervepodIO
jheidegger Apr 27, 2023
708ec25
builds now
jheidegger Apr 27, 2023
7869138
converted drivetrain
jheidegger Apr 27, 2023
20aee02
drivetrain swerve state recording
jheidegger Apr 27, 2023
476b197
fixing null pointer error in sim
jheidegger Apr 27, 2023
e645a66
added logging to robot main
jheidegger Apr 28, 2023
a9d09d9
building up sim capabilities
jheidegger Apr 28, 2023
e7980e5
first crack at simulated swervepods
jheidegger Apr 28, 2023
bc153fe
swerveSim v1 working
jheidegger Apr 28, 2023
7bce3ce
fully working swervesim
jheidegger Apr 28, 2023
9327f27
cleaning up drivetrain constants
jheidegger Apr 29, 2023
71965eb
cleaning
jheidegger Apr 29, 2023
4afff86
odometry now works in sim
jheidegger Apr 29, 2023
97bfa44
odom buggy in auto needs more investigation
jheidegger Apr 29, 2023
15aaac8
fixed auto odom error
jheidegger Apr 29, 2023
e47e77c
tuneableNumber added
jheidegger May 1, 2023
c045cfd
running on hardware
jheidegger May 2, 2023
1eba439
converted back to normal pid
jheidegger May 4, 2023
299985c
first pass at arm sim
jheidegger May 4, 2023
4ba3414
added more visualization for arm
jheidegger May 5, 2023
5838cdd
vision logging
jheidegger May 9, 2023
adaa75a
oneliner for pose3d should have looked for it first
jheidegger May 9, 2023
2c42f29
vision blending option for two limelights
jheidegger May 9, 2023
f552a88
Added CurrentAmpsSupply and chngd CurrentAmps to CurrentAmpsStator
char3176 May 16, 2023
ab33b14
updating logging errors
jheidegger Jun 12, 2023
d15e149
Merge branch 'jh_logging' into HEAD
jheidegger Jun 12, 2023
d6e96ca
Merge pull request #7 from Team3176/logging_fix
jheidegger Jun 12, 2023
e79e91b
Bumping PoopCube percent to 100%
char3176 Jun 19, 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

log/*
### Linux ###
*~

Expand Down
7 changes: 4 additions & 3 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@
],
"robotJoysticks": [
{},
{},
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
"guid": "Keyboard1"
},
{
"guid": "Keyboard0"
}
]
}
39 changes: 17 additions & 22 deletions simgui-window.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,45 @@
"MainWindow": {
"GLOBAL": {
"fps": "120",
"height": "1055",
"height": "720",
"maximized": "0",
"style": "0",
"userScale": "2",
"width": "1924",
"xpos": "-1",
"ypos": "-1"
"width": "1280",
"xpos": "537",
"ypos": "110"
}
},
"Window": {
"###Addressable LEDs": {
"Collapsed": "0",
"Pos": "318,53",
"Size": "170,300"
},
"###FMS": {
"Collapsed": "0",
"Pos": "10,1036",
"Size": "336,164"
"Pos": "5,540",
"Size": "283,146"
},
"###Joysticks": {
"Collapsed": "0",
"Pos": "483,801",
"Size": "976,278"
"Pos": "250,465",
"Size": "796,155"
},
"###NetworkTables": {
"Collapsed": "0",
"Pos": "271,365",
"Size": "1500,370"
"Pos": "250,277",
"Size": "750,185"
},
"###Other Devices": {
"Collapsed": "0",
"Pos": "1905,40",
"Size": "500,1390"
"Pos": "1025,20",
"Size": "250,695"
},
"###System Joysticks": {
"Collapsed": "0",
"Pos": "10,700",
"Size": "232,254"
"Pos": "5,350",
"Size": "192,218"
},
"###Timing": {
"Collapsed": "0",
"Pos": "10,300",
"Size": "169,168"
"Pos": "5,150",
"Size": "141,150"
},
"Debug##Default": {
"Collapsed": "0",
Expand All @@ -58,7 +53,7 @@
"Robot State": {
"Collapsed": "0",
"Pos": "5,20",
"Size": "109,114"
"Size": "92,99"
}
}
}
30 changes: 26 additions & 4 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
{
"HALProvider": {
"Addressable LEDs": {
"window": {
"visible": true
"Other Devices": {
"navX-Sensor[0]": {
"header": {
"open": true
}
}
}
},
"NTProvider": {
"types": {
"/AdvantageKit/RealOutputs/Arm/mech2d": "Mechanism2d",
"/FMSInfo": "FMSInfo",
"/SmartDashboard/Auton Choice": "String Chooser"
"/LiveWindow/Ungrouped/DigitalInput[0]": "Digital Input",
"/LiveWindow/Ungrouped/DigitalInput[1]": "Digital Input",
"/LiveWindow/Ungrouped/DigitalInput[2]": "Digital Input",
"/LiveWindow/Ungrouped/DigitalInput[3]": "Digital Input",
"/LiveWindow/Ungrouped/DigitalInput[4]": "Digital Input",
"/LiveWindow/Ungrouped/PIDController[10]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[11]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[1]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[2]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[3]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[4]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[5]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[6]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[7]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[8]": "PIDController",
"/LiveWindow/Ungrouped/PIDController[9]": "PIDController",
"/LiveWindow/Ungrouped/navX-Sensor[4]": "Gyro",
"/SmartDashboard/Auton Choice": "String Chooser",
"/SmartDashboard/Field": "Field2d",
"/SmartDashboard/Scheduler": "Scheduler"
}
}
}
79 changes: 79 additions & 0 deletions src/main/deploy/pathplanner/barrier_cone_exit_HP.path
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"waypoints": [
{
"anchorPoint": {
"x": 1.9070702548184761,
"y": 4.950151324031462
},
"prevControl": null,
"nextControl": {
"x": 2.601481140462281,
"y": 4.907885128270257
},
"holonomicAngle": -177.0122233890705,
"isReversal": false,
"velOverride": null,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [
"scoreHigh"
],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 10.0
}
},
{
"anchorPoint": {
"x": 4.737149161798324,
"y": 5.1194000825501655
},
"prevControl": {
"x": 3.8913259734623296,
"y": 4.883129462498332
},
"nextControl": {
"x": 5.091721488360994,
"y": 5.218445633210695
},
"holonomicAngle": 180.0,
"isReversal": false,
"velOverride": 1.0,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
},
{
"anchorPoint": {
"x": 7.389217083121666,
"y": 7.233294505651512
},
"prevControl": {
"x": 6.493607323152147,
"y": 7.18789191484633
},
"nextControl": null,
"holonomicAngle": 0.0,
"isReversal": false,
"velOverride": 1.0,
"isLocked": false,
"isStopPoint": false,
"stopEvent": {
"names": [],
"executionBehavior": "parallel",
"waitBehavior": "none",
"waitTime": 0
}
}
],
"maxVelocity": 2.0,
"maxAcceleration": 2.0,
"isReversed": null,
"markers": []
}
78 changes: 78 additions & 0 deletions src/main/java/team3176/robot/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) 2023 FRC 6328
// http://github.com/Mechanical-Advantage
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file at
// the root directory of this project.

package team3176.robot;

import edu.wpi.first.wpilibj.RobotBase;
import java.util.Map;

public final class Constants {
private static final RobotType robot = RobotType.ROBOT_SIMBOT;
public static final double loopPeriodSecs = 0.02;
public static final boolean tuningMode = false;

public static boolean invalidRobotAlertSent = false;

public static RobotType getRobot() {
if (!disableHAL && RobotBase.isReal()) {
if (robot == RobotType.ROBOT_SIMBOT) { // Invalid robot selected
if (!invalidRobotAlertSent) {
invalidRobotAlertSent = true;
}
return RobotType.ROBOT_2023C;
} else {
return robot;
}
} else {
return robot;
}
}

public static Mode getMode() {
switch (getRobot()) {
case ROBOT_2023C:
case ROBOT_2023P:
return RobotBase.isReal() ? Mode.REAL : Mode.REPLAY;

case ROBOT_SIMBOT:
return Mode.SIM;

default:
return Mode.REAL;
}
}

public static final Map<RobotType, String> logFolders =
Map.of(RobotType.ROBOT_2023C, "/media/sda2/");

public static enum RobotType {
ROBOT_2023C,
ROBOT_2023P,
ROBOT_SIMBOT
}

public static enum Mode {
REAL,
REPLAY,
SIM
}

// Function to disable HAL interaction when running without native libs
public static boolean disableHAL = false;

public static void disableHAL() {
disableHAL = true;
}

/** Checks whether the robot the correct robot is selected when deploying. */
public static void main(String... args) {
if (robot == RobotType.ROBOT_SIMBOT) {
System.err.println("Cannot deploy, invalid robot selected: " + robot.toString());
System.exit(1);
}
}
}
70 changes: 63 additions & 7 deletions src/main/java/team3176/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

package team3176.robot;

import org.littletonrobotics.junction.LogFileUtil;
import org.littletonrobotics.junction.LoggedRobot;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.inputs.LoggedPowerDistribution;
import org.littletonrobotics.junction.networktables.NT4Publisher;
import org.littletonrobotics.junction.wpilog.WPILOGReader;
import org.littletonrobotics.junction.wpilog.WPILOGWriter;

import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import team3176.robot.Constants.RobotType;
import team3176.robot.subsystems.superstructure.Arm;
import edu.wpi.first.cameraserver.CameraServer;
import edu.wpi.first.cscore.UsbCamera;
Expand All @@ -34,15 +42,63 @@ public class Robot extends LoggedRobot{
public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
Logger logger = Logger.getInstance();
logger.recordMetadata("Robot", Constants.getRobot().toString());
System.out.println("[Init] Starting AdvantageKit");
logger.recordMetadata("RuntimeType", getRuntimeType().toString());
logger.recordMetadata("ProjectName", BuildConstants.MAVEN_NAME);
logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE);
logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);
logger.recordMetadata("GitDate", BuildConstants.GIT_DATE);
logger.recordMetadata("GitBranch", BuildConstants.GIT_BRANCH);
switch (BuildConstants.DIRTY) {
case 0:
logger.recordMetadata("GitDirty", "All changes committed");
break;
case 1:
logger.recordMetadata("GitDirty", "Uncomitted changes");
break;
default:
logger.recordMetadata("GitDirty", "Unknown");
break;
}
switch (Constants.getMode()) {
case REAL:
String folder = Constants.logFolders.get(Constants.getRobot());
if (folder != null) {
logger.addDataReceiver(new WPILOGWriter(folder));
}
logger.addDataReceiver(new NT4Publisher());
if (Constants.getRobot() == RobotType.ROBOT_2023C) {
LoggedPowerDistribution.getInstance(50, ModuleType.kRev);
}
break;

case SIM:
System.out.println("[init] starting simulation");
logger.addDataReceiver(new WPILOGWriter("./log/"));
logger.addDataReceiver(new NT4Publisher());
break;

case REPLAY:
String path = LogFileUtil.findReplayLog();
logger.setReplaySource(new WPILOGReader(path));
logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(path, "_sim")));
break;
}
setUseTiming(Constants.getMode() != Constants.Mode.REPLAY);
logger.start();


m_robotContainer = new RobotContainer();
SmartDashboard.putData(CommandScheduler.getInstance());
m_fisheyeThread = new Thread( () -> {
UsbCamera fisheye = CameraServer.startAutomaticCapture();
fisheye.setResolution(640,480);
CvSource outputStream = CameraServer.putVideo("fisheye", 640, 480);
});
m_fisheyeThread.setDaemon(true);
m_fisheyeThread.start();
// m_fisheyeThread = new Thread( () -> {
// UsbCamera fisheye = CameraServer.startAutomaticCapture();
// fisheye.setResolution(640,480);
// CvSource outputStream = CameraServer.putVideo("fisheye", 640, 480);
// });
// m_fisheyeThread.setDaemon(true);
// m_fisheyeThread.start();

}

Expand Down
Loading