Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pass
def disabledPeriodic(self):
"""Called every 20ms in disabled mode"""
pass
def teleopInit(self):
"""Called only at the beginning of teleoperated mode"""
pass
def teleopPeriodic(self):
"""Called every 20ms in teleoperated mode"""
if __name__ == "__main__":
wpilib.run(MyRobot)
def disabledPeriodic(self):
'''Called every 20ms in disabled mode'''
pass
def teleopInit(self):
'''Called only at the beginning of teleoperated mode'''
pass
def teleopPeriodic(self):
'''Called every 20ms in teleoperated mode'''
# Move a motor with a Joystick
self.motor.set(self.lstick.getY())
if __name__ == '__main__':
wpilib.run(MyRobot)
self.drive.move(.5, 0)
# Debug stuff
if not self.ds.isFMSAttached():
if self.joystick1.getRawButton(10):
self.drive.angle_rotation(35)
elif self.joystick1.getRawButton(9): #this could prove problematic if the robot is backwards
self.drive.angle_rotation(0)
elif self.joystick2.getRawButton(10):
self.drive.enable_camera_tracking()
self.drive.align_to_tower()
if __name__ == '__main__':
wpilib.run(MyRobot)
# send telemetry data array back to NT
self.telemetry = (
now,
battery,
autospeed,
l_motor_volts,
r_motor_volts,
l_encoder_position,
r_encoder_position,
l_encoder_rate,
r_encoder_rate,
)
if __name__ == "__main__":
wpilib.run(MyRobot)
def operatorControl(self):
'''Runs the motors with Mecanum drive.'''
self.robotDrive.setSafetyEnabled(True)
while self.isOperatorControl() and self.isEnabled():
# Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
# This sample does not use field-oriented drive, so the gyro input is set to zero.
self.robotDrive.mecanumDrive_Cartesian(self.stick.getX(),
self.stick.getY(),
self.stick.getZ(), 0);
wpilib.Timer.delay(0.005) # wait 5ms to avoid hogging CPU cycles
if __name__ == '__main__':
wpilib.run(MyRobot)
# command motors to do things
self.arm_motor.set(autospeed)
# send telemetry data array back to NT
self.telemetry = (
now,
battery,
autospeed,
motor_volts,
encoder_position,
encoder_rate
)
if __name__ == "__main__":
wpilib.run(MyRobot)
self.autonomous_command.start()
def autonomousPeriodic(self):
"""This function is called periodically during autonomous."""
command.Scheduler.getInstance().run()
def teleopPeriodic(self):
"""This function is called periodically during operator control."""
command.Scheduler.getInstance().run()
def testPeriodic(self):
"""This function is called periodically during test mode."""
wpilib.LiveWindow.run()
if __name__ == "__main__":
wpilib.run(MyRobot)
if self.auto_loop_counter < 100:
self.robot_drive.drive(-0.5, 0) # Drive forwards at half speed
self.auto_loop_counter += 1
else:
self.robot_drive.drive(0, 0) #Stop robot
def teleopPeriodic(self):
"""This function is called periodically during operator control."""
self.robot_drive.arcadeDrive(self.stick)
def testPeriodic(self):
"""This function is called periodically during test mode."""
wpilib.LiveWindow.run()
if __name__ == "__main__":
wpilib.run(MyRobot)