diff --git a/README.md b/README.md index b765c30..e6d6894 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,47 @@ -# The 🍁 Swerve Skeleton +# 🍁 Swerve Skeleton --- -[Iron Maple](https://www.thebluealliance.com/team/5516/2024)’s Swerve Drive Skeleton Project +6328 ([TBA](https://www.thebluealliance.com/team/6328/2024) | [Github](https://github.com/mechanical-advantage) | [Website](http://team6328.org/))'s [Advanced Swerve Drive Project](https://www.chiefdelphi.com/t/advantagekit-2024-log-replay-again/442968/54#advanced-swerve-drive-project-2) with enhanced physics simulation. -Completely Simulated Swerve-Bot, with [250HZ Odometry](https://pro.docs.ctr-electronics.com/en/stable/docs/application-notes/update-frequency-impact.html), [6328's Log-Replay Technology](https://www.youtube.com/watch?v=BrzPw6ngx4o&t=1517s) and Vision - -> 🙏 We extend our deepest appreciation to [Littleton Robotics](https://www.littletonrobotics.org/) for their [open source projects](https://github.com/Mechanical-Advantage), which have made this project possible. +> 🙏 We extend our deepest appreciation to [Team 6328](https://www.littletonrobotics.org/) for their [open source project](https://github.com/Mechanical-Advantage), which have made this project possible. > -> ⚖️ This project is based on the [Advanced Swerve Drive Example](https://github.com/Mechanical-Advantage/AdvantageKit/tree/main/example_projects/advanced_swerve_drive/src/main) from [AdvantageKit](https://github.com/Mechanical-Advantage/AdvantageKit/), which is under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html#license-text) license. All teams are welcome to use this project, provided that you adhere to the [Advantage Kit License](./AdvantageKit-License.md). - -## 👭Digital-Twin - -A complete-real simulation, with physics engine, score-count, human-players and opponent robots. - -- **Uses Actual Robot Code** in the simulator. This means that you can tune Auto-Stages, PIDs, Auto-Scoring functions and more. The simulator display robots through https://github.com/Mechanical-Advantage/AdvantageScope. -- **Swerve-Drive Physics Simulation**, fine-tuned with experimental data measured in our training field, as well as real-life data gathered from real competitions this year. - - ![physics simulation 2.gif](./media/physics_simulation_2.gif) - -- **2D Rigid-Body Collision Simulation** for game-pieces and robots on field. Using open source 2d physics engine https://github.com/dyn4j/dyn4j. - - ![robot physics simulation.gif](./media/robot_physics_simulation.gif) - -- **Opponent Robots Simulation** that can either be controlled by a gamepad to play defense or follow pre-stored cycle paths. - - ![Untitled video - Made with Clipchamp.gif](./media/Untitled_video_-_Made_with_Clipchamp.gif) -- **Odometry Simulation**, which behaves like a real odometry: when you hit the wall, it skids and the IMU drifts. [Video](https://youtu.be/ersRWIzC0zc) -- ![Odometry Sim](./media/OdometrySim.gif) -- **Vision Simulation** with [PhotonLib](https://docs.photonvision.org/en/latest/docs/simulation/simulation.html), [code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/dev/src/main/java/frc/robot/subsystems/vision/VisionIOSim.java). +> ⚖️ This project is based on an example from [AdvantageKit](https://github.com/Mechanical-Advantage/AdvantageKit/), which is under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html#license-text) license. All teams are welcome to use it, provided that you adhere to the [Advantage Kit License](./AdvantageKit-License.md). -## 🕹️Driving +## Simulation Details -- **250HZ Odometer**, Custom [Odometry Thread](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/subsystems/drive/OdometryThreadReal.java) -- **A Star Auto-Alignment** [Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/commands/drive/AutoAlignment.java), [Video](https://www.youtube.com/watch?v=HjQfurIPfgw) -- **Skid Detection** inspired by [1690 online software session](https://youtu.be/N6ogT5DjGOk?feature=shared&t=1674) -- **Acceleration Constraining** during TeleOp, [code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/commands/drive/JoystickDrive.java). -- **Robot Configuration Storage** in JSON files, [code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/Config/MapleConfigFile.java), [example configs](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/tree/main/src/main/deploy/configs/ChassisWheelsCalibration). -- **Robot Status Visualization** through [Elastic Dashboard](https://github.com/Gold872/elastic-dashboard), [AdvantageScope](https://github.com/Mechanical-Advantage/AdvantageScope), LED and [Network Alerts](https://github.com/Mechanical-Advantage/NetworkAlerts) +A complete-real simulation with [dyn4j physics engine](https://github.com/dyn4j/dyn4j) -## 🖥️ Dashboard -![Screenshot 2024-06-17 005557.png](./media/Screenshot_2024-06-17_005557.png) +### Swerve-Drive Physics Simulation, +Fine-tuned with data measured in our training field, the swerve drive simulation provides an incredibly realistic drivetrain characteristics. +It simulates the behavior of each individual swerve module using [WPILib DCMotorSim](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj/simulation/DCMotorSim.html) and use the data from 4 modules together to simulate the force on the drivetrain. +[[Source Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/CompetitionFieldUtils/Simulations/SwerveDriveSimulation.java)] +![swervedrivesim.gif](media/swervedrivesim.gif) -## 🤖Auto +### Game Pieces and Intake Simulation +In our simulation, game pieces on the field has collision spaces and can interact with the robot. +It also allows teams to simulate a fixed intake module on the robot that grabs a game pieces whenever in-contact. +[[Source Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/CompetitionFieldUtils/Simulations/IntakeSimulation.java) | [Example Code](https://github.com/Shenzhen-Robotics-Alliance/5516-2024-OffSeason/blob/main/src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java)] +![intakesim.gif](media/intakesim.gif) -- **Decisive Autonomous Framework** -- **Path-Planning**, [PathPlanner](https://github.com/mjansen4857/pathplanner) and [Choreo](https://github.com/SleipnirGroup/Choreo) both supported. With Custom Follow-Path-Command. +### Opponent Robots Simulation +Simulated robots that can either be controlled by a gamepad to play defense or follow pre-stored cycle paths. +Just as real robots, opponent robots have collision spaces. +This allows drivers to practice defense/offense. +[[Source Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/CompetitionFieldUtils/Simulations/OpponentRobotSimulation.java)] +![opponentrobotsim.gif](media/opponentrobotsim.gif) -## 📝Logging +### Odometry Simulation -Built Upon [AdvantageKit](https://github.com/Mechanical-Advantage/AdvantageKit), all sensor inputs are logged and recorded for after-match analysis. +Odometry Simulation with realistic characteristics such as skidding and the IMU drifts. +[[Source Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/subsystems/drive/IO/ModuleIOSim.java) | [Video](https://youtu.be/ersRWIzC0zc)] +- ![Odometry Sim](./media/odometrysim.gif) +### Vision Simulation with +Built Upon [PhotonLib Camera Sim](https://docs.photonvision.org/en/latest/docs/simulation/simulation.html), our vision simulation behaves exactly the same as a real vision system +The system uses April Tags to position the robot on field, and teams can tune the system without a field +![visionsim1.gif](media/visionsim1.gif) +We also Provide a convenient feature that generates [Advantage Scope Fix Camera Config](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/CustomConfigs/PhotonCameraProperties.java) automatically, which allows you to see the camera's view in advantage scope with easy steps to set up, [Source Code](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/main/src/main/java/frc/robot/utils/CustomConfigs/PhotonCameraProperties.java) +![visionsim2.gif](media/visionsim2.gif) -## 👁️Vision +## Getting Started -- **April-tag Robot Localization** With [Photon Vision](https://photonvision.org/), Also works in [Simulation](https://github.com/Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton/blob/dev/src/main/java/frc/robot/subsystems/vision/VisionIOSim.java) -- **360° Game-Piece Detection** running on Jetson-Orin-Nano coprocessor. [GitHub - FRC-Phantom-Vision: machine-learning-based object-detection tool for FRC](https://github.com/Shenzhen-Robotics-Alliance/FRC-Phantom-Vision) diff --git a/media/OdometrySim.gif b/media/OdometrySim.gif index b8170a1..c9109d1 100644 Binary files a/media/OdometrySim.gif and b/media/OdometrySim.gif differ diff --git a/media/Screenshot_2024-06-17_005557.png b/media/Screenshot_2024-06-17_005557.png deleted file mode 100644 index 32e8584..0000000 Binary files a/media/Screenshot_2024-06-17_005557.png and /dev/null differ diff --git a/media/Untitled_video_-_Made_with_Clipchamp.gif b/media/Untitled_video_-_Made_with_Clipchamp.gif deleted file mode 100644 index d71c810..0000000 Binary files a/media/Untitled_video_-_Made_with_Clipchamp.gif and /dev/null differ diff --git a/media/intakesim.gif b/media/intakesim.gif new file mode 100644 index 0000000..4f7496e Binary files /dev/null and b/media/intakesim.gif differ diff --git a/media/opponentrobotsim.gif b/media/opponentrobotsim.gif new file mode 100644 index 0000000..9088a8e Binary files /dev/null and b/media/opponentrobotsim.gif differ diff --git a/media/physics_simulation_2.gif b/media/physics_simulation_2.gif deleted file mode 100644 index cef471c..0000000 Binary files a/media/physics_simulation_2.gif and /dev/null differ diff --git a/media/robot_physics_simulation.gif b/media/robot_physics_simulation.gif deleted file mode 100644 index a38258b..0000000 Binary files a/media/robot_physics_simulation.gif and /dev/null differ diff --git a/media/swervedrivesim.gif b/media/swervedrivesim.gif new file mode 100644 index 0000000..516b183 Binary files /dev/null and b/media/swervedrivesim.gif differ diff --git a/media/visionsim1.gif b/media/visionsim1.gif new file mode 100644 index 0000000..28bbf9c Binary files /dev/null and b/media/visionsim1.gif differ diff --git a/media/visionsim2.gif b/media/visionsim2.gif new file mode 100644 index 0000000..66bcea5 Binary files /dev/null and b/media/visionsim2.gif differ