Skip to content

Commit

Permalink
Update simulation and physics for 2020
Browse files Browse the repository at this point in the history
* Adjust drivetrain physics to match wpilib.drive expectations
* Use wpilib geometry and kinematics objects instead of raw floats
  • Loading branch information
virtuald committed Mar 2, 2020
1 parent c7fc6c7 commit c7aa185
Show file tree
Hide file tree
Showing 13 changed files with 366 additions and 724 deletions.
37 changes: 37 additions & 0 deletions pyfrc/mains/cli_sim.py
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
Loading

0 comments on commit c7aa185

Please sign in to comment.