Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def createObjects(self):
self.driveStick = xbox_controller.XboxController(0)
# If the robot is a simulation
if MyRobot.isSimulation():
# Change motors to default jaguars
self.lf_motor = wpilib.Jaguar(1)
self.lr_motor = wpilib.Jaguar(2)
self.rf_motor = wpilib.Jaguar(3)
self.rr_motor = wpilib.Jaguar(4)
# Set up drive train
self.drive = wpilib.RobotDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor)
def createObjects(self):
self.driveStick = xbox_controller.XboxController(0)
# If the robot is a simulation
if MyRobot.isSimulation():
# Change motors to default jaguars
self.lf_motor = wpilib.Jaguar(1)
self.lr_motor = wpilib.Jaguar(2)
self.rf_motor = wpilib.Jaguar(3)
self.rr_motor = wpilib.Jaguar(4)
# Set up drive train
self.drive = wpilib.RobotDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor)
def robotInit(self):
"""Robot-wide initialization code should go here"""
self.lstick = wpilib.Joystick(0)
# Left front
self.arm_motor = ctre.WPI_TalonSRX(1)
self.arm_motor.setInverted(False)
self.arm_motor.setSensorPhase(False)
#
# Configure encoder related functions -- getpos and getrate should return
# feet and feet/s
#
encoder_constant = (
(1 / self.ENCODER_PULSE_PER_REV) * self.PULLEY_DIAMETER * math.pi
)
self.arm_motor.configSelectedFeedbackSensor(
def robotInit(self):
"""Robot-wide initialization code should go here"""
self.lstick = wpilib.Joystick(0)
# Left front
left_front_motor = ctre.WPI_TalonSRX(1)
left_front_motor.setInverted(False)
left_front_motor.setSensorPhase(False)
self.left_front_motor = left_front_motor
# Right front
right_front_motor = ctre.WPI_TalonSRX(2)
right_front_motor.setInverted(False)
right_front_motor.setSensorPhase(False)
self.right_front_motor = right_front_motor
# Left rear -- follows front
left_rear_motor = ctre.WPI_TalonSRX(3)
left_rear_motor.setInverted(False)
import wpilib
lstick = wpilib.Joystick(1)
motor = wpilib.CANJaguar(8)
def CheckRestart():
if lstick.GetRawButton(10):
raise RuntimeError("Restart")
class MyRobot(wpilib.SimpleRobot):
def Disabled(self):
while self.IsDisabled():
CheckRestart()
wpilib.Wait(0.01)
def Autonomous(self):
self.GetWatchdog().SetEnabled(False)
while self.IsAutonomous() and self.IsEnabled():
def robotInit(self):
'''Robot initialization function'''
# object that handles basic drive operations
self.myRobot = wpilib.RobotDrive(0, 1)
self.myRobot.setExpiration(0.1)
# joysticks 1 & 2 on the driver station
self.leftStick = wpilib.Joystick(0)
self.rightStick = wpilib.Joystick(1)
import wpilib
lstick = wpilib.Joystick(1)
rstick = wpilib.Joystick(2)
lmotor = wpilib.CANJaguar(3)
rmotor = wpilib.CANJaguar(5)
drive = wpilib.RobotDrive(lmotor, rmotor)
def CheckRestart():
if lstick.GetRawButton(10):
raise RuntimeError("Restart")
class MyRobot(wpilib.SimpleRobot):
def Disabled(self):
while self.IsDisabled():
CheckRestart()
wpilib.Wait(0.01)
def robotInit(self):
"""Robot-wide initialization code should go here"""
self.lstick = wpilib.Joystick(0)
left_front_motor = wpilib.Spark(1)
left_front_motor.setInverted(False)
right_front_motor = wpilib.Spark(2)
right_front_motor.setInverted(False)
left_rear_motor = wpilib.Spark(3)
left_rear_motor.setInverted(False)
right_rear_motor = wpilib.Spark(4)
right_rear_motor.setInverted(False)
#
# Configure drivetrain movement
#
def RobotInit(self):
wpilib.Wait(0.25)
winchControl.SetOutputRange(-1.0, 1.0)
kickerEncoder.Start()
leftDriveEncoder.Start()
rightDriveEncoder.Start()
compressor.Start()
def Disabled(self):
while self.IsDisabled():
CheckRestart()
wpilib.Wait(0.01)