Skip to content

Instantly share code, notes, and snippets.

@ArchdukeTim
Created February 17, 2016 05:38
Show Gist options
  • Save ArchdukeTim/6bdd441709271bb24ba4 to your computer and use it in GitHub Desktop.
Save ArchdukeTim/6bdd441709271bb24ba4 to your computer and use it in GitHub Desktop.
from pyfrc.physics.drivetrains import four_motor_drivetrain
import wpilib
class PhysicsEngine:
def __init__(self, controller):
self.controller = controller
def update_sim(self, hal_data, now, tm_diff):
# Simulate the arm
# Simulate the drivetrain
lf_motor = -hal_data['CAN'][1]['value']/1023
lr_motor = -hal_data['CAN'][2]['value']/1023
rf_motor = -hal_data['CAN'][3]['value']/1023
rr_motor = -hal_data['CAN'][4]['value']/1023
fwd, rcw = four_motor_drivetrain(lr_motor, rr_motor, lf_motor, rf_motor)
self.controller.drive(fwd, rcw, tm_diff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment