You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// create the normal Spark MAX objectSparkMaxmax = newSparkMAX(10, MotorType.kBrushless);
// create the Spark MAX sim objectSparkMaxSimmaxSim = newSparkMaxSim(max, maxGearbox);
ElevatorSimm_elevatorSim =
newElevatorSim(
m_elevatorGearbox,
Constants.kElevatorGearing,
Constants.kCarriageMass,
Constants.kElevatorDrumRadius,
Constants.kMinElevatorHeightMeters,
Constants.kMaxElevatorHeightMeters,
true,
0,
0.01,
0.0);
publicvoidsimulationPeriodic() {
// In this method, we update our simulation of what our elevator is doing// First, we set our "inputs" (voltages)m_elevatorSim.setInput(maxSim.getAppliedOutput() * RobotController.getBatteryVoltage());
// Next, we update it. The standard loop time is 20ms.m_elevatorSim.update(0.020);
// Now, we update the Spark FlexflexSim.iterate(
Units.radiansPerSecondToRotationsPerMinute( // motor velocity, in RPMm_elevatorSim.getVelocityRadPerSec()),
RobotController.getBatteryVoltage(), // Simulated battery voltage, in Volts0.02); // Time interval, in Seconds
}
The text was updated successfully, but these errors were encountered:
Each subsystem should have a
simulationPeriodic
method:Docs on simulating Spark MAX and Flex devices: https://docs.revrobotics.com/revlib/spark/sim/simulation-getting-started#simulating-spark-max-and-flex-devices
Elevator sim example: https://docs.wpilib.org/en/stable/docs/software/wpilib-tools/robot-simulation/physics-sim.html#usage-in-user-code
Example:
The text was updated successfully, but these errors were encountered: