forked from robotpy/pyfrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update simulation and physics for 2020
* Adjust drivetrain physics to match wpilib.drive expectations * Use wpilib geometry and kinematics objects instead of raw floats
- Loading branch information
Showing
13 changed files
with
366 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from os.path import abspath, dirname, join | ||
|
||
import halsim_gui | ||
import inspect | ||
import logging | ||
|
||
logger = logging.getLogger("pyfrc.sim") | ||
|
||
|
||
class PyFrcSim: | ||
""" | ||
Runs the robot using WPILib's GUI HAL Simulator | ||
""" | ||
|
||
def __init__(self, parser): | ||
pass | ||
|
||
def run(self, options, robot_class, **static_options): | ||
halsim_gui.loadExtension() | ||
|
||
# initialize physics, attach to the user robot class | ||
from ..physics.core import PhysicsInterface, PhysicsInitException | ||
|
||
robot_file = abspath(inspect.getfile(robot_class)) | ||
robot_path = dirname(robot_file) | ||
|
||
try: | ||
physics = PhysicsInterface._create(robot_path) | ||
if physics: | ||
robot_class._simulationInit = physics._simulationInit | ||
robot_class._simulationPeriodic = physics._simulationPeriodic | ||
|
||
# run the robot | ||
return robot_class.main(robot_class) | ||
|
||
except PhysicsInitException: | ||
return False |
Oops, something went wrong.