Skip to content

Commit 35f0e39

Browse files
committed
Initialize Field object before physics engine
- Allows physics engine constructor to access field
1 parent 4d96857 commit 35f0e39

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pyfrc/physics/core.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ def __init__(self, physics_module):
148148
self.log_init_errors = True
149149

150150
def _simulationInit(self, robot):
151+
152+
# reset state first so that the PhysicsEngine constructor can use it
153+
self.field = wpilib.Field2d()
154+
wpilib.SmartDashboard.putData("Field", self.field)
155+
156+
self.last_tm = None
157+
151158
# look for a class called PhysicsEngine
152159
try:
153160
PhysicsEngine = self.module.PhysicsEngine
@@ -171,12 +178,6 @@ def _simulationInit(self, robot):
171178
logger.exception("Error creating user's PhysicsEngine object")
172179
raise PhysicsInitException()
173180

174-
# reset state
175-
self.field = wpilib.Field2d()
176-
wpilib.SmartDashboard.putData("Field", self.field)
177-
178-
self.last_tm = None
179-
180181
def _simulationPeriodic(self):
181182
now = wpilib.Timer.getFPGATimestamp()
182183
last_tm = self.last_tm

0 commit comments

Comments
 (0)