-
Notifications
You must be signed in to change notification settings - Fork 6
Simulation(MapleSim)
- Make sure you have the MapleSim vendor installed
- PhoenixUtil file(will be in common library soon)
- The rest of the module's code completed
You will need a wpilibj simulation object to do a lot of the simulation stuff so you don't have to.
DCMotorSim is to simulate an individual motor
MapleMotorSim is to simulate a motor but with a bit more physics
FlywheelSim is to simulate shooter mechanisms
ElevatorSim is to simulate elevator mechanisms
LinearSystemSim is for mechanisms with linear change in forces
SingleJointedArmSim is for simulating mechanisms that rotate around a single joint such as an arm, shooter mount, or an intake mount
IntakeSimulation is for simulating intake mechanisms, this one functions a bit differently than the others as it is not made by WPI so a lot of the methods are different
SwerveDriveSimulation is for simulating swerve, like intake simulation it is made by MapleSim instead of WPI so the methods are different
SimulatedBattery this simulates the battery and it draining over time, if you want to get a rough estimate of when your robot will experience a brownout, use this (I don't know how accurate this is)
SimulatedMotorController is for simulating the motor controller, you will generally need this for all mechanisms(except pneumatics)
You will need to define your simulated module which will look something like this:
ElevatorIOSim(){
//Last one is for simulating gravity, the parameters will depend on the module
this.elevatorSim = new ElevatorSim(elevatorGearbox, elevatorGearingReduction, elevatorMass, drumRadius, elevatorMinHeight, elevatorMaxHeight, true);
this.simulatedMotorController = new SimulatedMotorController.GenericMotorController(elevatorGearbox);
SimulatedBattery.addElectricalAppliances(this::getSupplyCurrent);
elevatorSim.update(0.0)
}Then you will need to make a updateInputs method to have the simulation update the IO data which will look something like this:
@Override
public void updateInputs(ElevatorIOInputs inputs){
Voltage realVoltage = motorController.constrainOutputVoltage(elevatorPosition, elevatorVelocity, targetVoltage);
realVoltage = SimulatedBattery.clamp(realVoltage);
inputs.elevatorData = new ElevatorIOData(
true,//Main Motor Connected
true,//Follower Motor Connected
elevatorPosition.in(Rotations),
realVoltage.in(Volts), //Main Motor Voltage
elevatorVelocity.in(RotationsPerSecond), //Main Motor Velocity
getSupplyCurrent().in(Amps), //Main Motor Current
realVoltage.in(Volts), //Follower Motor Voltage, usually you can mirror if it is a follower motor
elevatorVelocity.in(RotationsPerSecond), //Follower Motor Velocity
getSupplyCurrent().in(Amps)); //Follower Motor Current
}This is an officially licensed product of Team 4026. Decatur Robotics 2024 is not sponsored by any other Team, and is not responsible for any damages caused by using this product or trusting the programming team, which is by far the least most trustworthy team(Shadow owen money gang, we love coding the robot). By using this product, you are consenting to your information, and thus your identity to be stolen and first-born child taken.
- Editing Documentation & Markdown Syntax
- Code Team to-do List
- Code Standards
- Common Library Structure
- Interfaces
- General Setup
- Branching System
- How to Create Pull Requests
- How to Switch Branches
- Code Reviews
- Reverting Commits
- Singleton Pattern
- Software Installations
- Necessary IntelliJ Plugins
- Vendordeps
- Setting Up New Projects
- Autoformatter Set Up
- Showbot Requirements
- Autonomous
- Calling a Command Based on a Button Press
- CAN
- Clearing Sticky Faults
- Current Limits
- PID Config and Usage
- Robot.java, TeleopInit, DisabledInit
- RoboRio Ports
- SetDefaultCommand
- Wait for Time
- SlewRateLimiter
- LEDs
- InstantCommand
- PhotonVision
- Apriltags
- Camera Display on Shuffleboard
- Object Detection
- Raspberry Pi
- Network Tables
- List of Network Tables (2023)
Up to date as of SJ2, end of 2023 season