Skip to content
Open
Changes from all commits
Commits
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
35 changes: 33 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@

package frc.robot;

import org.ironmaple.simulation.SimulatedArena;
import java.util.List;

import org.ironmaple.simulation.SimulatedArena;
import org.ironmaple.simulation.gamepieces.GamePiece;
import org.ironmaple.simulation.seasonspecific.crescendo2024.CrescendoNoteOnField;
import org.ironmaple.simulation.seasonspecific.rebuilt2026.RebuiltFuelOnField;
import org.ironmaple.simulation.seasonspecific.reefscape2025.ReefscapeAlgaeOnField;
import org.json.simple.parser.Yytoken;

import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.StructArrayPublisher;
import edu.wpi.first.wpilibj.AnalogPotentiometer;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.TimedRobot;
Expand Down Expand Up @@ -117,11 +128,31 @@ public void testPeriodic() {}

/** This function is called once when the robot is first started up. */
@Override
public void simulationInit() {}
public void simulationInit() {
for (int xCnt = 0; xCnt < 4; xCnt++){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this stuff somewhere else?

double x = 3 + xCnt * 0.15;
for (int yCnt = 0; yCnt < 6; yCnt++){
double y = 3 + yCnt * 0.15;
SimulatedArena.getInstance().addGamePiece(new RebuiltFuelOnField(new Translation2d(x, y)));

}
}


}


/** This function is called periodically whilst in simulation. */
StructArrayPublisher<Pose3d> fuelPoses = NetworkTableInstance.getDefault()
.getStructArrayTopic("MyPoseArray", Pose3d.struct)
.publish();
@Override
public void simulationPeriodic() {
SimulatedArena.getInstance().simulationPeriodic();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimulatedArena.getInstance().simulationPeriodic() is also called inside MapleSimSwervePhysics.update(), so calling it here as well may advance the arena twice (or at mismatched rates) and desync game-piece/robot simulation behavior. Consider ensuring the arena is stepped exactly once per simulation loop.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


fuelPoses.accept(SimulatedArena.getInstance()
.getGamePiecesArrayByType("Fuel"));
}


}
Loading