Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 __init__(self, robot):
self.joystick = wpilib.Joystick(0)
JoystickButton(self.joystick, 12).whenPressed(LowGoal(robot))
JoystickButton(self.joystick, 10).whenPressed(Collect(robot))
JoystickButton(self.joystick, 11).whenPressed(SetPivotSetpoint(robot, Pivot.SHOOT))
JoystickButton(self.joystick, 9).whenPressed(SetPivotSetpoint(robot, Pivot.SHOOT_NEAR))
DoubleButton(self.joystick, 2, 3).whenActive(Shoot(robot))
#SmartDashboard Buttons
SmartDashboard.putData("Drive Forward", DriveForward(robot,2.25))
SmartDashboard.putData("Drive Backward", DriveForward(robot,-2.25))
SmartDashboard.putData("Start Rollers", SetCollectionSpeed(robot,Collector.FORWARD))
SmartDashboard.putData("Stop Rollers", SetCollectionSpeed(robot,Collector.STOP))
SmartDashboard.putData("Reverse Rollers", SetCollectionSpeed(robot,Collector.REVERSE))
import wpilib
lstick = wpilib.Joystick(1)
rstick = wpilib.Joystick(2)
stick3 = wpilib.Joystick(3)
shifter1 = wpilib.Solenoid(7, 1)
shifter2 = wpilib.Solenoid(7, 2)
leftFrontMotor = wpilib.CANJaguar(2)
leftRearMotor = wpilib.CANJaguar(7)
rightFrontMotor = wpilib.CANJaguar(4)
rightRearMotor = wpilib.CANJaguar(6)
compressor = wpilib.Compressor(8,1)
drive = wpilib.RobotDrive(leftFrontMotor, leftRearMotor,
rightFrontMotor, rightRearMotor)
def checkRestart():
def createObjects(self):
# #INITIALIZE JOYSTICKS##
self.joystick1 = wpilib.Joystick(0)
self.joystick2 = wpilib.Joystick(1)
# #INITIALIZE MOTORS##
self.lf_motor = wpilib.CANTalon(5)
self.lr_motor = wpilib.CANTalon(10)
self.rf_motor = wpilib.CANTalon(15)
self.rr_motor = wpilib.CANTalon(20)
self.robot_drive = wpilib.RobotDrive(self.lf_motor, self.lr_motor, self.rf_motor, self.rr_motor)
self.leftArm = wpilib.CANTalon(25)
self.rightArm = wpilib.CANTalon(30)
self.leftBall = wpilib.Talon(9)
self.winchMotor = wpilib.Talon(0)