class SquareBot(): # Globals TOTAL_POWER = 70 # Configurations """Assumes the following: Left motor is connected to motor pin 1. Right motor is connected to motor pin 10. Bump sensor is connected to digital pin 1. """ left_wheels = vex.Motor(1) right_wheels = vex.Motor(10) bump_sensor = vex.DigitalInput(1) def main(self): while True: self.left_wheels.run(self.TOTAL_POWER) self.right_wheels.run(self.TOTAL_POWER) if self.bump_sensor.is_on(): self.back_and_turn() sys.sleep(1) def back_and_turn(self): # Back self.left_wheels.run(-self.TOTAL_POWER) self.right_wheels.run(-self.TOTAL_POWER) sys.sleep(3) # Turn right self.left_wheels.run(self.TOTAL_POWER) self.right_wheels.run(self.TOTAL_POWER / 2) sys.sleep(2)
def __init__(self): # Initialize hardware self.left_wheels = vex.Motor(10) self.right_wheels = vex.Motor(1) self.lline_track = vex.LineTracker(2) self.rline_track = vex.LineTracker(1) self.serial = vex.Serial(1, 9600) self.serial.write("begin") # Default power self.TOTAL_POWER = 60 # State can be one of [forward, on_tape, off_tape] self.state = "forward" self.lon_tape = False self.ron_tape = False # Keep track of coordinates self.square = Vector(0, 0) self.lcd_print(self.square) # Going to the right self.direction = Vector(1, 0) # Class timer object self.timer = timer.Timer()
def __init__(self): # Globals self.TOTAL_POWER = 30 self.left_wheels = vex.Motor(10) self.right_wheels = vex.Motor(1) self.bump_sensor = vex.DigitalInput(1) self.right_line_tracker = vex.LineTracker(1) self.left_line_tracker = vex.LineTracker(2) self.serial = vex.Serial(1, 9600) self.serial.write("begin") sys.sleep(2)
def __init__(self): # Configurations self.left_wheels = vex.Motor(10) self.right_wheels = vex.Motor(1) self.bump_front = vex.DigitalInput(1) self.bump_back = vex.DigitalInput(2) # State # Can be one of: # - loop # - back # - forward # - left # - right self.state = "loop" # Time Variables self.tick_count = 0 self.back_start = 0 self.left_start = 0 self.random_gen()
# VEX EDR Python-Project import sys import vex #region config ultrasonic_2 = vex.UltrasonicSensor(2, vex.UNIT_CM) output_9 = vex.DigitalOutput(9) input_10 = vex.DigitalInput(10) input_11 = vex.DigitalInput(11) motor_2 = vex.Motor(2) motor_3 = vex.Motor(3) motor_4 = vex.Motor(4) motor_5 = vex.Motor(5) #endregion config ultrasonic_2.set_unit_cm() def goForward(speed): motor_2.run(speed) motor_3.run(speed) motor_4.run(speed) motor_5.run(speed) def turnRight(speed): motor_2.run(-speed) motor_3.run(-speed) motor_4.run(speed) motor_5.run(speed)
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"8","name":"flipper","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":0},{"hwid":"9","name":"flywheel_","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":1},{"hwid":"10","name":"flywheel2","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":2},{"hwid":"11","name":"rightFront_","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":3},{"hwid":"12","name":"rightBack","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":4},{"hwid":"13","name":"leftFront","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":5},{"hwid":"14","name":"intake","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":6},{"hwid":"15","name":"leftBack","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":7},{"hwid":"triport_adi","name":"triport_22","typeName":"triport","extraConfig":null,"bufferIndex":8},{"hwid":"drivetrain","name":"DRC","typeName":"drivetrain","extraConfig":{"leftMotorHwId":"12","rightMotorHwId":"15","wheelTravel":319.1764,"trackWidth":292.1},"bufferIndex":9},{"hwid":"controller","name":"DRC_Controler","typeName":"controller_one","extraConfig":null,"bufferIndex":10},{"hwid":"Axis1","name":"axis1","typeName":"controller_axis","extraConfig":null,"bufferIndex":11},{"hwid":"Axis2","name":"axis2","typeName":"controller_axis","extraConfig":null,"bufferIndex":12},{"hwid":"Axis3","name":"axis3","typeName":"controller_axis","extraConfig":null,"bufferIndex":13},{"hwid":"Axis4","name":"axis4","typeName":"controller_axis","extraConfig":null,"bufferIndex":14},{"hwid":"ButtonL1","name":"buttonL1","typeName":"controller_button","extraConfig":null,"bufferIndex":15},{"hwid":"ButtonL2","name":"buttonL2","typeName":"controller_button","extraConfig":null,"bufferIndex":16},{"hwid":"ButtonR1","name":"buttonR1","typeName":"controller_button","extraConfig":null,"bufferIndex":17},{"hwid":"ButtonR2","name":"buttonR2","typeName":"controller_button","extraConfig":null,"bufferIndex":18},{"hwid":"ButtonUp","name":"buttonUp","typeName":"controller_button","extraConfig":null,"bufferIndex":19},{"hwid":"ButtonDown","name":"buttonDown","typeName":"controller_button","extraConfig":null,"bufferIndex":20},{"hwid":"ButtonLeft","name":"buttonLeft","typeName":"controller_button","extraConfig":null,"bufferIndex":21},{"hwid":"ButtonRight","name":"buttonRight","typeName":"controller_button","extraConfig":null,"bufferIndex":22},{"hwid":"ButtonX","name":"buttonX","typeName":"controller_button","extraConfig":null,"bufferIndex":23},{"hwid":"ButtonB","name":"buttonB","typeName":"controller_button","extraConfig":null,"bufferIndex":24},{"hwid":"ButtonY","name":"buttonY","typeName":"controller_button","extraConfig":null,"bufferIndex":25},{"hwid":"ButtonA","name":"buttonA","typeName":"controller_button","extraConfig":null,"bufferIndex":26}]}""" """__BLOCKLY__ <xml xmlns="http://www.w3.org/1999/xhtml"><block type="vexv5_start_autonomous" id="1" x="-651" y="-304"><next><block type="variables_set" id="#3*x1RAj!kl?=+XhIqCi"><field name="VAR">on</field><value name="VALUE"><block type="math_number" id="C@PRF5Vii]EY_w-cn~0L"><field name="NUM">1</field></block></value><next><block type="variables_set" id="ypT#5^o4}uYK1hh5zJ07"><field name="VAR">direction</field><value name="VALUE"><block type="math_number" id="yh;fH|LQ#ItYdoIlO[W1"><field name="NUM">1</field></block></value><next><block type="vexv5_drivetrain_set_velocity" id="Y%hmK+gvWn=yrO*-@M]!"><field name="p1">PCT</field><value name="p0"><block type="math_number" id="SLJ).@CSi74B}ip|sLvJ"><field name="NUM">75</field></block></value><next><block type="vexv5_drivetrain_drive_for" id="`WMUP[,wRTFcr0f:64.r"><field name="p0">REV</field><field name="p2">IN</field><value name="p1"><block type="math_number" id=",p`|9zzy)2TpvZBKG^Je"><field name="NUM">47</field></block></value><next><block type="vexv5_motor_rotate_for_time" id="BiK)JJ1m*:.2^%Gk+-an"><field name="WIDGET_ID">14</field><field name="p0">FWD</field><field name="p2">SEC</field><value name="p1"><block type="math_number" id="6MlppP^yLl]#o~C9|12U"><field name="NUM">0.5</field></block></value><next><block type="vexv5_drivetrain_drive_for" id="-|cxb3@;)z%OL^iiYLd`"><field name="p0">FWD</field><field name="p2">IN</field><value name="p1"><block type="math_number" id="LV=DikZG,cko61*BB2#e"><field name="NUM">47</field></block></value><next><block type="vexv5_drivetrain_turn" id="@X:.CQ|#=NeO/JBtW9@-"><field name="p0">LEFT</field></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type="procedures_defnoreturn" id="!Fu=)cfMVTDEPrhZQ;M[" x="588" y="-170"><field name="NAME">flyWheelControl</field><statement name="STACK"><block type="controls_if" id="WcNUrBCS`+~=2@0Jz2a^"><value name="IF0"><block type="vexv5_controller_button_pressing" id="ew%`5BSA9hk:15I[b3dH"><field name="WIDGET_ID">ButtonX</field></block></value><statement name="DO0"><block type="variables_set" id="dJe#R!Sx]dB[W_caUT86"><field name="VAR">on</field><value name="VALUE"><block type="math_arithmetic" id="/!3;Dn`;H?,,kaR^)6jF"><field name="OP">MULTIPLY</field><value name="A"><block type="variables_get" id="4tU`Ru0kQ;6NbA#JYx4;"><field name="VAR">on</field></block></value><value name="B"><block type="math_number" id="Jjk6W][/,5BLLkHOTHr1"><field name="NUM">-1</field></block></value></block></value><next><block type="sleep" id="(8JhzU_PEyW6waJ2?aoB"><value name="seconds"><block type="math_number" id="_FM6eRf?j]w-k1,c~YsE"><field name="NUM">0.3</field></block></value></block></next></block></statement><next><block type="controls_if" id="ogercc)`@[q:Std:XoG)"><mutation else="1"></mutation><value name="IF0"><block type="logic_compare" id="6[XNH}]I{C)vC)r7N-)@"><field name="OP">EQ</field><value name="A"><block type="variables_get" id="Wxz^NR)9I0I^Zt^olouZ"><field name="VAR">on</field></block></value><value name="B"><block type="math_number" id="+kqhREJjMwz~~%V%@nu*"><field name="NUM">-1</field></block></value></block></value><statement name="DO0"><block type="vexv5_motor_spin" id="M7v,i|Bhj:)0JteBwze^"><field name="WIDGET_ID">9</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="%5ftboWW-fRsRuo1HqMt"><field name="NUM">100</field></block></value><next><block type="vexv5_motor_spin" id="iGfRlI]rh4IM+`k^dak:"><field name="WIDGET_ID">10</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="2*HNvS0Rvlp{4Ljg}!0p"><field name="NUM">100</field></block></value></block></next></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="Cj*@4IRx0jkdE]dt^hkl"><field name="WIDGET_ID">9</field><field name="p0">COAST</field><next><block type="vexv5_motor_stop" id="z,8Z|qs1:ylINFLw9NkO"><field name="WIDGET_ID">10</field><field name="p0">COAST</field></block></next></block></statement></block></next></block></statement></block><block type="procedures_defnoreturn" id="rUpS9gAb;7OYNQ}!xg6w" x="-79" y="-101"><field name="NAME">driveControl</field><statement name="STACK"><block type="controls_if" id="|-T7GE9Jv;`?-v[)y?}5"><mutation else="1"></mutation><value name="IF0"><block type="logic_compare" id="X}prQHkPE=#MuFpt8HSN"><field name="OP">EQ</field><value name="A"><block type="variables_get" id="[3g:aJ6I`E9H6XFq2vVs"><field name="VAR">direction</field></block></value><value name="B"><block type="math_number" id="bJ,uL+EE%JWyl9SVoZ3h"><field name="NUM">-1</field></block></value></block></value><statement name="DO0"><block type="vexv5_motor_spin" id="Ib!@SU[aGebSxw8BgS%`"><field name="WIDGET_ID">11</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id=",{nN@Mpi4Z2T+1-tBu.b"><field name="WIDGET_ID">Axis2</field></block></value><next><block type="vexv5_motor_spin" id="by3;J[ZcJj/heY6)wpe2"><field name="WIDGET_ID">12</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="Ej:c`;eGGN;mJnf0}z[P"><field name="WIDGET_ID">Axis2</field></block></value><next><block type="vexv5_motor_spin" id="~TxGT}Bmwibc51X@{ZLS"><field name="WIDGET_ID">13</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="#.5{Q,:%nkE!-C5lT#Aq"><field name="WIDGET_ID">Axis3</field></block></value><next><block type="vexv5_motor_spin" id="}xrH8Eg:SMg@#xM=ScQ1"><field name="WIDGET_ID">15</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="jI*NV~;3OUzMm_)NF8_;"><field name="WIDGET_ID">Axis3</field></block></value></block></next></block></next></block></next></block></statement><statement name="ELSE"><block type="vexv5_motor_spin" id="b?,)b#`7+Xc1~u=tkF7c"><field name="WIDGET_ID">15</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="!mpX%rerW).w:k)ppzV0"><field name="WIDGET_ID">Axis2</field></block></value><next><block type="vexv5_motor_spin" id="3otNKZ+,5BzV5E12YhDK"><field name="WIDGET_ID">13</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="q[0N-xHd):|fnU;_Lo;6"><field name="WIDGET_ID">Axis2</field></block></value><next><block type="vexv5_motor_spin" id="TmJ{A[e12h+^*pu91v*F"><field name="WIDGET_ID">12</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="bL|s4sUDQb7yd0(+i;^e"><field name="WIDGET_ID">Axis3</field></block></value><next><block type="vexv5_motor_spin" id="EyUpU@Rv}4Xexia|s`i~"><field name="WIDGET_ID">11</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="vexv5_controller_axis_position" id="|oPY/;](2DWnCn~BPWp+"><field name="WIDGET_ID">Axis3</field></block></value></block></next></block></next></block></next></block></statement></block></statement></block><block type="vexv5_start_drivercontrol" id="3" x="1119" y="-93"><next><block type="sleep" id="[;/D2g78w0t}NfUXLJEh"><value name="seconds"><block type="math_number" id="L.J||N:|yPCEOD4jVQ53"><field name="NUM">0.2</field></block></value><next><block type="controls_forever" id="5"><statement name="DO"><block type="procedures_callnoreturn" id="9s*sBg6YV+L]I27xi1ze"><mutation name="DriverSwitch"></mutation><next><block type="procedures_callnoreturn" id="j3d,2`yJWDc7i+x+t(9~"><mutation name="ballController"></mutation><next><block type="procedures_callnoreturn" id="q-*]ME.:YaFdf9c%%_L^"><mutation name="driveControl"></mutation><next><block type="procedures_callnoreturn" id="N2%7`Lu,3y_#j98?37`;"><mutation name="flyWheelControl"></mutation><next><block type="procedures_callnoreturn" id="50H~4/}Uo2yQ?:.r3BKT"><mutation name="flip"></mutation></block></next></block></next></block></next></block></next></block></statement></block></next></block></next></block><block type="procedures_defnoreturn" id="oZ-r]53NJdE`OS/hw^5B" x="596" y="202"><field name="NAME">DriverSwitch</field><statement name="STACK"><block type="controls_if" id="%bnqH!RONZGKwCjgo_F%"><value name="IF0"><block type="vexv5_controller_button_pressing" id="){#YaT/.}bxsr{mg#]+4"><field name="WIDGET_ID">ButtonLeft</field></block></value><statement name="DO0"><block type="variables_set" id="7il}5+8b-1}g=F:Il2c;"><field name="VAR">direction</field><value name="VALUE"><block type="math_arithmetic" id="n*A!X,]Oa]AYV~XCLH?J"><field name="OP">MULTIPLY</field><value name="A"><block type="variables_get" id="aWz_G|a`^dsP@:Q4u?x^"><field name="VAR">direction</field></block></value><value name="B"><block type="math_number" id="pH]bI5cDIO4Xo-]t.9wz"><field name="NUM">-1</field></block></value></block></value><next><block type="sleep" id="KnaJ;(;m6Q1NMU)iCoZK"><value name="seconds"><block type="math_number" id="~Z`Y[;/@B?F-:!(?X(Tc"><field name="NUM">0.25</field></block></value></block></next></block></statement></block></statement></block><block type="procedures_defnoreturn" id="K-9)Le26Q12nPXD4~9-S" x="593" y="368"><field name="NAME">ballController</field><statement name="STACK"><block type="controls_if" id="r/WnDinTw|k@FFr`Pw1u"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="k~lowos3sGf/_SY[t@}4"><field name="WIDGET_ID">ButtonL1</field></block></value><statement name="DO0"><block type="vexv5_motor_spin" id="NF5}M5tGYUmO.v17V@xF"><field name="WIDGET_ID">14</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="@X@u/Znyt!#`o.?@Zi5q"><field name="NUM">100</field></block></value></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="wc:H9]1McSFpTo#|jXZ/"><field name="WIDGET_ID">ButtonL2</field></block></value><statement name="DO1"><block type="vexv5_motor_spin" id="q@cO(n[t?A~lo=%CUD.N"><field name="WIDGET_ID">14</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="@/uM:y?2*vm6=*X0_0w8"><field name="NUM">100</field></block></value></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="wz;[zOxfX0j3(kFj}DPJ"><field name="WIDGET_ID">14</field><field name="p0">BRAKE</field></block></statement></block></statement></block><block type="procedures_defnoreturn" id="e[~]K_+TpT%7B6)#8o^K" x="573" y="635"><field name="NAME">flip</field><statement name="STACK"><block type="controls_if" id="loow;+,SCcP6!+}`2+[A"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id=",N]hNzoLQMyU#jlh%@H{"><field name="WIDGET_ID">ButtonR1</field></block></value><statement name="DO0"><block type="vexv5_motor_spin" id="ATSedODTkqf2/f+=Q]t?"><field name="WIDGET_ID">8</field><field name="p0">FWD</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="r%A6JjvUl;3vVlT.NuYd"><field name="NUM">25</field></block></value></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="#X/,yJ.[@~aMPQ`5iEgz"><field name="WIDGET_ID">ButtonR2</field></block></value><statement name="DO1"><block type="vexv5_motor_spin" id="G)o7b*hE^Y|.|rr+MO:T"><field name="WIDGET_ID">8</field><field name="p0">REV</field><field name="p2">PCT</field><value name="p1"><block type="math_number" id="#~V2tsmL_}n3NG=7h}Ge"><field name="NUM">25</field></block></value></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="Q^-U7NmXm.QIx/UXL8)8"><field name="WIDGET_ID">8</field><field name="p0">BRAKE</field></block></statement></block></statement></block></xml> """ import vex import sys #region config brain = vex.Brain() flipper = vex.Motor(vex.Ports.PORT8, vex.GearSetting.RATIO18_1, False) flywheel_ = vex.Motor(vex.Ports.PORT9, vex.GearSetting.RATIO18_1, False) flywheel2 = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, True) rightFront_ = vex.Motor(vex.Ports.PORT11, vex.GearSetting.RATIO18_1, True) rightBack = vex.Motor(vex.Ports.PORT12, vex.GearSetting.RATIO18_1, True) leftFront = vex.Motor(vex.Ports.PORT13, vex.GearSetting.RATIO18_1, False) intake = vex.Motor(vex.Ports.PORT14, vex.GearSetting.RATIO18_1, False) leftBack = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, False) DRC = vex.Drivetrain(rightBack, leftBack, 319.1764, 292.1, vex.DistanceUnits.MM) DRC_Controler = vex.Controller(vex.ControllerType.PRIMARY) #endregion config on = None direction = None competition = vex.Competition() def auto(): global on, direction on = 1
# VEX EDR Python-Project - BEST Robotics import vex import sys #Notes Removed to preserve a fast download/compile time. #CONFIGURE START joystick1 = vex.Joystick() right = vex.Motor(2) left = vex.Motor(3) elevator = vex.Motor(4) servo = vex.Servo(5) auto = vex.Motor(6) #CONFIGURE END joystick1.set_deadband(15) while True: #--------------------------------- #STANDARD (MANUAL COMMANDS) #--------------------------------- #DRIVETRAIN CODE (FINAL) left.run(joystick1.axis2()) right.run(joystick1.axis3()) #ELEVATOR CODE (FINAL) #DOWN
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"joystick","name":"joystick","typeName":"joystick_one","extraConfig":null,"bufferIndex":0},{"hwid":"5U","name":"b5up","typeName":"joystick_button","extraConfig":null,"bufferIndex":1},{"hwid":"5D","name":"b5down","typeName":"joystick_button","extraConfig":null,"bufferIndex":2},{"hwid":"6U","name":"b6up","typeName":"joystick_button","extraConfig":null,"bufferIndex":3},{"hwid":"6D","name":"b6down","typeName":"joystick_button","extraConfig":null,"bufferIndex":4},{"hwid":"7U","name":"b7up","typeName":"joystick_button","extraConfig":null,"bufferIndex":5},{"hwid":"7D","name":"b7down","typeName":"joystick_button","extraConfig":null,"bufferIndex":6},{"hwid":"7L","name":"b7left","typeName":"joystick_button","extraConfig":null,"bufferIndex":7},{"hwid":"7R","name":"b7right","typeName":"joystick_button","extraConfig":null,"bufferIndex":8},{"hwid":"8U","name":"b8up","typeName":"joystick_button","extraConfig":null,"bufferIndex":9},{"hwid":"8D","name":"b8down","typeName":"joystick_button","extraConfig":null,"bufferIndex":10},{"hwid":"8L","name":"b8left","typeName":"joystick_button","extraConfig":null,"bufferIndex":11},{"hwid":"8R","name":"b8right","typeName":"joystick_button","extraConfig":null,"bufferIndex":12},{"hwid":"Axis1:x","name":"axis1","typeName":"joystick_axis","extraConfig":null,"bufferIndex":13},{"hwid":"Axis2:y","name":"axis2","typeName":"joystick_axis","extraConfig":null,"bufferIndex":14},{"hwid":"Axis3:y","name":"axis3","typeName":"joystick_axis","extraConfig":null,"bufferIndex":15},{"hwid":"Axis4:x","name":"axis4","typeName":"joystick_axis","extraConfig":null,"bufferIndex":16},{"hwid":"AccelX","name":"accelX","typeName":"joystick_axis","extraConfig":null,"bufferIndex":17},{"hwid":"AccelY","name":"accelY","typeName":"joystick_axis","extraConfig":null,"bufferIndex":18}]}""" # Imports the packages import sys import vex # Defines the joystick joystick = vex.Joystick() # Defines all motors left_motor = vex.Motor(2) right_motor = vex.Motor(3) scooper_motor = vex.Motor(4) # Main loop def driverMode(): while True: # Assigning joystick mappings for all the motors if joystick.b5down(): right_motor(100) elif joystick.b5up(): right_motor(-100) elif joystick.b6down(): left_motor(100) elif joystick.b6up(): left_motor(-100) elif joystick.b8up(): scooper_motor(100) elif joystick.b8right(): scooper_motor(-100)
import vex, sys, timer #region config line_tracker_1 = vex.LineTracker(1) line_tracker_2 = vex.LineTracker(2) right_wheel = vex.Motor(1) left_wheel = vex.Motor(2, True) claw_tower = vex.Motor(3) claw_open = vex.Motor(4) ultrasonic = vex.UltrasonicSensor(1, vex.UNIT_CM) joystick = vex.Joystick() green_light = vex.DigitalOutput(10) yellow_light = vex.DigitalOutput(11) red_light = vex.DigitalOutput(12) #endregion config mode = 0 # main thread joystick.set_deadband(10) no_strafe = 50 / 50 is_fast = True while True: green_light.on() if joystick.b7down(): mode = 0 elif joystick.b7left():
import vex import sys #region config bump_ = vex.DigitalInput(5) limit = vex.DigitalInput(8) right_sensor = vex.LineTracker(1) left_sensor = vex.LineTracker(2) right_motor = vex.Motor(2) left_motor = vex.Motor(3) #endregion config # main thread sys.wait_for(bump_.is_on) right_motor.run(20) left_motor.run(20) while True: if right_sensor.line_tracker_percent() > 70: right_motor.off() elif left_sensor.percent() > 70: left_motor.off() elif limit.is_on(): break else: right_motor.run(20) left_motor.run(20) while True: if bump_.is_on(): break else: right_motor.off()
# VEX EDR Python-Project import sys import vex #region config left = vex.Motor(1) flywheelLeft = vex.Motor(2) rampIntake = vex.Motor(3) flyWheelRight = vex.Motor(4) intakeWheels = vex.Motor(6) right = vex.Motor(10) joystick = vex.Joystick() timer = 0 enableHighFlywheelTimer = False highFlywheelBuildUpTimer = 0 enableLowFlywheelTimer = False lowFlywheelBuildUpTimer = 0 #endregion config while True: timer += 0.0022 straight = joystick.axis3() steering = joystick.axis1() left.run(-straight + steering) right.run(straight + steering) # print(timer) if(joystick.b6up()): # high speed flywheel
import sys import vex from vex import * import math # Robot Setup ----------------------------------------------------------------- wheelTravel = 310 # circumference of the wheel (mm) trackWidth = 370 # width of the chassis (mm) turnSpeed = 25 # how fast the robot will turn (%) movementSpeed = 50 # how fast the robot will go forwards and back (%) brain = vex.Brain() controller = vex.Controller(vex.ControllerType.PRIMARY) twoBar = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) leftMotor = vex.Motor(vex.Ports.PORT14, vex.GearSetting.RATIO18_1, False) rightMotor = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, True) flywheelOne = vex.Motor(vex.Ports.PORT9, vex.GearSetting.RATIO18_1, True) flywheelTwo = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, False) intake = vex.Motor(vex.Ports.PORT16, vex.GearSetting.RATIO18_1, False) loader = vex.Motor(vex.Ports.PORT11, vex.GearSetting.RATIO18_1, False) sonar = vex.Sonar(brain.three_wire_port.c) sonarLeft = vex.Sonar(brain.three_wire_port.e) sonarRight = vex.Sonar(brain.three_wire_port.g) dt = vex.Drivetrain(leftMotor, rightMotor, wheelTravel, trackWidth, vex.DistanceUnits.MM) # Robot Class -----------------------------------------------------------------
# Imports --------------------------------------------------------------------- import sys import vex from vex import * import math # Robot Setup ----------------------------------------------------------------- controller = vex.Controller(vex.ControllerType.PRIMARY) leftOne = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) leftTwo = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True) rightOne = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO18_1, True) rightTwo = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO18_1, False) steering = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, False) # Main ------------------------------------------------------------------------ #moves the robot forwards def moveForwards(time, power): #time measured in milliseconds, power measured in 0-100 percentage newPower = math.fabs(power) leftOne.spin(vex.DirectionType.FWD, newPower, vex.VelocityUnits.PCT) leftTwo.spin(vex.DirectionType.FWD, newPower, vex.VelocityUnits.PCT) rightOne.spin(vex.DirectionType.FWD, newPower, vex.VelocityUnits.PCT) rightTwo.spin(vex.DirectionType.FWD, newPower, vex.VelocityUnits.PCT) sys.sleep(time)
import sys import vex from vex import * import math brain = vex.Brain() leftMotor = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) rightMotor = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True) controller = vex.Controller(vex.ControllerType.PRIMARY) def stopMotors(): leftMotor.stop(vex.BrakeType.BRAKE) rightMotor.stop(vex.BrakeType.BRAKE) def goForwards(): leftMotor.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.PCT) rightMotor.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.PCT) def goBackwards(): leftMotor.spin(vex.DirectionType.REV, 100, vex.VelocityUnits.PCT) rightMotor.spin(vex.DirectionType.REV, 100, vex.VelocityUnits.PCT) while True: if controller.axis3.value() > 10: goForwards() elif controller.axis3.value() < -10:
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"triport_adi","name":"triport_22","typeName":"triport","extraConfig":null,"bufferIndex":0},{"hwid":"drivetrain","name":"dt","typeName":"drivetrain","extraConfig":null,"bufferIndex":1}]}""" # VEX V5 Python Project import sys import vex from vex import * print(vex.__file__) #region config brain = vex.Brain() #endregion config brain.installed() left_wheel = vex.Motor()
# Imports import sys import math import vex # Motors leftMotor = vex.Motor(1) rightMotor = vex.Motor(2, True) # Controller controller = vex.Joystick() # Functions def stopMotors(): leftMotor.off() rightMotor.off() def goForwards(): leftMotor.run(100) rightMotor.run(100) def goBackwards(): leftMotor.run(-100) rightMotor.run(-100)
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"1","name":"rearLeft","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":0},{"hwid":"2","name":"rearRight_","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":1},{"hwid":"triport_adi","name":"triport_22","typeName":"triport","extraConfig":null,"bufferIndex":2},{"hwid":"drivetrain","name":"dt","typeName":"drivetrain","extraConfig":{"leftMotorHwId":"1","rightMotorHwId":"2","wheelTravel":319.1764,"trackWidth":320.675},"bufferIndex":3},{"hwid":"controller","name":"con","typeName":"controller_one","extraConfig":null,"bufferIndex":4},{"hwid":"Axis1","name":"axis1","typeName":"controller_axis","extraConfig":null,"bufferIndex":5},{"hwid":"Axis2","name":"axis2","typeName":"controller_axis","extraConfig":null,"bufferIndex":6},{"hwid":"Axis3","name":"axis3","typeName":"controller_axis","extraConfig":null,"bufferIndex":7},{"hwid":"Axis4","name":"axis4","typeName":"controller_axis","extraConfig":null,"bufferIndex":8},{"hwid":"ButtonL1","name":"buttonL1","typeName":"controller_button","extraConfig":null,"bufferIndex":9},{"hwid":"ButtonL2","name":"buttonL2","typeName":"controller_button","extraConfig":null,"bufferIndex":10},{"hwid":"ButtonR1","name":"buttonR1","typeName":"controller_button","extraConfig":null,"bufferIndex":11},{"hwid":"ButtonR2","name":"buttonR2","typeName":"controller_button","extraConfig":null,"bufferIndex":12},{"hwid":"ButtonUp","name":"buttonUp","typeName":"controller_button","extraConfig":null,"bufferIndex":13},{"hwid":"ButtonDown","name":"buttonDown","typeName":"controller_button","extraConfig":null,"bufferIndex":14},{"hwid":"ButtonLeft","name":"buttonLeft","typeName":"controller_button","extraConfig":null,"bufferIndex":15},{"hwid":"ButtonRight","name":"buttonRight","typeName":"controller_button","extraConfig":null,"bufferIndex":16},{"hwid":"ButtonX","name":"buttonX","typeName":"controller_button","extraConfig":null,"bufferIndex":17},{"hwid":"ButtonB","name":"buttonB","typeName":"controller_button","extraConfig":null,"bufferIndex":18},{"hwid":"ButtonY","name":"buttonY","typeName":"controller_button","extraConfig":null,"bufferIndex":19},{"hwid":"ButtonA","name":"buttonA","typeName":"controller_button","extraConfig":null,"bufferIndex":20}]}""" # VEX V5 Python Project import sys import vex from vex import * #region config brain = vex.Brain() rearLeft = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, True) rearRight_ = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, False) dt = vex.Drivetrain(rearLeft, rearRight_, 319.1764, 320.675, vex.DistanceUnits.MM) con = vex.Controller(vex.ControllerType.PRIMARY) #endregion config #code rearLeft.stop(vex.BrakeType.COAST) rearRight_.stop(vex.BrakeType.COAST) dt.drive_for(vex.DirectionType.FWD, 100, vex.DistanceUnits.CM, 90, vex.VelocityUnits.PCT) rearLeft.stop(vex.BrakeType.COAST) rearRight_.stop(vex.BrakeType.BRAKE) rearLeft.rotate_for_time(vex.DirectionType.FWD, 1.5, vex.TimeUnits.SEC, 75, vex.VelocityUnits.PCT) dt.drive_for(vex.DirectionType.FWD, 50, vex.DistanceUnits.CM, 75, vex.VelocityUnits.PCT) rearRight_.rotate_for_time(vex.DirectionType.FWD, 1.5, vex.TimeUnits.SEC, 75, vex.VelocityUnits.PCT) rearLeft.stop(vex.BrakeType.COAST) dt.drive_for(vex.DirectionType.FWD, 40, vex.DistanceUnits.CM, 75,
#!/usr/bin/python3 # imports the necessary libraries import sys # THE NEXT LINE IS ONLY FOR DOCUMENTATIONS import fakesys as sys import timer import vex # import sys # MOTORS _claw = vex.Motor(2) _forwardLeft = vex.Motor(3, True) _forwardRight = vex.Motor(4) _wrist = vex.Motor(5) _backRight = vex.Motor(6) _backLeft = vex.Motor(7, True) # JOYSTICK joystick = vex.Joystick() joystick.set_deadband(15) # VARIBALES # global variables AUTO_TIME = 5 WRIST_UP_POWER = 50 WRIST_DOWN_POWER = -(50) CLAW_CLOSE_POWER = 50
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"triport_adi","name":"triport_22","typeName":"triport","extraConfig":null,"bufferIndex":0},{"hwid":"drivetrain","name":"dt","typeName":"drivetrain","extraConfig":null,"bufferIndex":1}]}""" import vex import sys #region config brain = vex.Brain() left_Wheel = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) right_Wheel = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, False) lyft = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO18_1, False) top_Left = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO18_1, False) top_Right = vex.Motor(vex.Ports.PORT5, vex.GearSetting.RATIO18_1, True) left_Tickler = vex.Motor(vex.Ports.PORT6, vex.GearSetting.RATIO18_1, False) right_Tickler = vex.Motor(vex.Ports.PORT7, vex.GearSetting.RATIO18_1, False) dt = vex.Drivetrain(top_Left, top_Right, 319.1764, 292.1, vex.DistanceUnits.MM) con = vex.Controller(vex.ControllerType.PRIMARY) #endregion config # main thread while True: right_Wheel.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)), vex.VelocityUnits.PCT) left_Wheel.spin(vex.DirectionType.FWD, (con.axis3.position(vex.PercentUnits.PCT)), vex.VelocityUnits.PCT) if con.buttonUp.pressing(): lyft.spin(vex.DirectionType.FWD, 40, vex.VelocityUnits.RPM) lyft.stop(vex.BrakeType.BRAKE) if con.buttonDown.pressing(): lyft.spin(vex.DirectionType.REV, 40, vex.VelocityUnits.RPM)
import sys import vex import math brain = vex.Brain() competition = vex.Competition() controller1 = vex.Controller(vex.ControllerType.PRIMARY) controller2 = vex.Controller(vex.ControllerType.PARTNER) leftFront = vex.Motor(vex.Ports.PORT17, vex.GearSetting.RATIO18_1, False) leftBack = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, False) rightBack = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, True) rightFront = vex.Motor(vex.Ports.PORT18, vex.GearSetting.RATIO18_1, True) swerve = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, True) catapult = vex.Motor(vex.Ports.PORT13, vex.GearSetting.RATIO36_1, True) intake = vex.Motor(vex.Ports.PORT14, vex.GearSetting.RATIO18_1, True) flipper = vex.Motor(vex.Ports.PORT20, vex.GearSetting.RATIO18_1, True) vision1 = vex.Vision(vex.Ports.PORT11) green = vex.VisionSignature(1, -1375, -1011, -1193, -5539, -4449, -4994, 3, 0) class PID: kP = 0 kI = 0 kD = 0 prevTime = 0
import vex #region config brain = vex.Brain() motor_1 = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) motor_2 = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, False) con = vex.Controller(vex.ControllerType.PRIMARY) #endregion config con.set_deadband(5) #region actions while True: motor_2_power = 0 motor_1_power = 0 # axis2: Linear Control power = con.axis2.position() * 1.5 if power != 0: motor_2_power = -(power/2) # axis2: Linear Control power = con.axis3.position() * 1.5 if power != 0: motor_1_power = -(power/2) # buttonUp: Forward if con.buttonUp.pressing(): motor_1_power = -60 motor_2_power = -60
# VEX V5 Python-Project with Competition Template import sys import vex from vex import * brain = vex.Brain() dev = vex.Devices() motor = vex.Motor(vex.Ports.PORT11, vex.GearSetting.RATIO18_1, True) con = vex.Controller(vex.ControllerType.PRIMARY) competition = vex.Competition() def pre_auton(): pass def autonomous(): ''' motor.rotate_for_time (vex.DirectionType.FWD, 5, TimeUnits.SEC, 50, VelocityUnits.PCT )''' print 'bye'
import vex import sys # stuff so my text editor doesn't want to kill me; ignore this #class Loader(): # def run(h): # pass # pass #loader = Loader() #region config testb = vex.LimitSwitch(1) loader = vex.Motor(2) motor_right = vex.Motor(3) motor_left = vex.Motor(4) tube_servo = vex.Servo(5) joystick = vex.Joystick() #endregion config def move_motors(): if joystick. loader.run(100) sys.wait_for(lambda: not testb.is_on()) loader.off() def drop_ball(): tube_servo.position(50) sys.sleep(0.1) tube_servo.position(15) def theta_move():
import sys import vex import math from math import * from vex import * brain = vex.Brain(); motor_right = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True) motor_left = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, False) con = vex.Controller(vex.ControllerType.PRIMARY) con.set_deadband(10) #so that slight motion of controller does not disturb anything dt = vex.Drivetrain(motor_left, motor_right, 319.1764, 292.1, vex.distanceUnits.mm) knock_flags() def knock_flags(): # set our standard velocity dt.setVelocity(20,vex.velocityUnits.pct) # advance four feet dt.driveFor(vex.directionType.fwd,48,vex.distanceUnits.in) vex.sleep(1) ''' # retreat two feet dt.driveFor(vex.directionType.rev,24,vex.distanceUnits.in) vex.sleep(1)
def __init__(self): self.base_m = vex.Motor(2) self.claw_m = vex.Motor(6) self.shoulder_m = vex.Motor(3) self.arm_m = vex.Motor(7) self.joystick = vex.Joystick()
# VEX V5 Python Project import sys import vex from vex import * # region config brain = vex.Brain() Motor = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, False) # dev = vex.Devices()sonic_sensor.py # con = vex.Controller(vex.ControllerType.PRIMARY) pot = vex.Pot(brain.three_wire_port.h) # endregion config def autonomous(): while True: potvalue = pot.value(RotationUnits.DEG) print(potvalue) if potvalue < 100: Motor.spin(vex.DirectionType.FWD, 0, vex.VelocityUnits.PCT) else: Motor.spin(vex.DirectionType.FWD, 40, vex.VelocityUnits.PCT) # if bumper_b.pressing() == 0: # Motor.spin(vex.DirectionType.FWD, 40, vex.VelocityUnits.PCT) # # else: # Motor.spin(vex.DirectionType.FWD, 0, vex.VelocityUnits.PCT) # sys.sleep(1)
"""__CONFIG__ {"version":20,"widgetInfos":[{"hwid":"1","name":"Right_Drive","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":0},{"hwid":"4","name":"rightup","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":1},{"hwid":"5","name":"leftdown","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":2},{"hwid":"6","name":"leftup","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":3},{"hwid":"7","name":"rightdown","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":true},"bufferIndex":4},{"hwid":"10","name":"Left_Drive","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":5},{"hwid":"20","name":"Claw","typeName":"motor","extraConfig":{"gearSetting":1,"reverse":false},"bufferIndex":6},{"hwid":"triport_adi","name":"triport_22","typeName":"triport","extraConfig":null,"bufferIndex":7},{"hwid":"drivetrain","name":"dt","typeName":"drivetrain","extraConfig":{"leftMotorHwId":"10","rightMotorHwId":"1","wheelTravel":319.1764,"trackWidth":292.1},"bufferIndex":8},{"hwid":"controller","name":"con","typeName":"controller_one","extraConfig":null,"bufferIndex":9},{"hwid":"Axis1","name":"axis1","typeName":"controller_axis","extraConfig":null,"bufferIndex":10},{"hwid":"Axis2","name":"axis2","typeName":"controller_axis","extraConfig":null,"bufferIndex":11},{"hwid":"Axis3","name":"axis3","typeName":"controller_axis","extraConfig":null,"bufferIndex":12},{"hwid":"Axis4","name":"axis4","typeName":"controller_axis","extraConfig":null,"bufferIndex":13},{"hwid":"ButtonL1","name":"buttonL1","typeName":"controller_button","extraConfig":null,"bufferIndex":14},{"hwid":"ButtonL2","name":"buttonL2","typeName":"controller_button","extraConfig":null,"bufferIndex":15},{"hwid":"ButtonR1","name":"buttonR1","typeName":"controller_button","extraConfig":null,"bufferIndex":16},{"hwid":"ButtonR2","name":"buttonR2","typeName":"controller_button","extraConfig":null,"bufferIndex":17},{"hwid":"ButtonUp","name":"buttonUp","typeName":"controller_button","extraConfig":null,"bufferIndex":18},{"hwid":"ButtonDown","name":"buttonDown","typeName":"controller_button","extraConfig":null,"bufferIndex":19},{"hwid":"ButtonLeft","name":"buttonLeft","typeName":"controller_button","extraConfig":null,"bufferIndex":20},{"hwid":"ButtonRight","name":"buttonRight","typeName":"controller_button","extraConfig":null,"bufferIndex":21},{"hwid":"ButtonX","name":"buttonX","typeName":"controller_button","extraConfig":null,"bufferIndex":22},{"hwid":"ButtonB","name":"buttonB","typeName":"controller_button","extraConfig":null,"bufferIndex":23},{"hwid":"ButtonY","name":"buttonY","typeName":"controller_button","extraConfig":null,"bufferIndex":24},{"hwid":"ButtonA","name":"buttonA","typeName":"controller_button","extraConfig":null,"bufferIndex":25}]}""" """__BLOCKLY__ <xml xmlns="http://www.w3.org/1999/xhtml"><block type="vexv5_start_autonomous" id="+`-8#WHI-uN6akLo6?VE" x="-94" y="64"><next><block type="vexv5_drivetrain_set_velocity" id="j+%WeLUyxpCr?7]mbTc2"><field name="p1">PCT</field><value name="p0"><block type="math_number" id="Q|qr=A(xU:fcoej9KORE"><field name="NUM">100</field></block></value><next><block type="vexv5_drivetrain_drive_for" id="Y%VR5=]nq=f^JRO9S{TN"><field name="p0">REV</field><field name="p2">CM</field><value name="p1"><block type="math_number" id="(K=;aoAl[LdG:x7gwaO0"><field name="NUM">50</field></block></value><next><block type="vexv5_drivetrain_drive_for" id="oYM/UzGUMBhXr[yfa1Y0"><field name="p0">FWD</field><field name="p2">CM</field><value name="p1"><block type="math_number" id="jUYf:{e6*xnq0Ektym#;"><field name="NUM">15</field></block></value></block></next></block></next></block></next></block><block type="vexv5_start_drivercontrol" id="5;~Y~/yCZ5xOIoHpAS=|" x="250" y="50"><next><block type="controls_forever" id="vXrx=98HQ[+m]Jf}Ep_@"><statement name="DO"><block type="controls_if" id="aI;2:msCrA2tuS/E,M@t"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="ZoD.f{21O]MPRYt3VDH5"><field name="WIDGET_ID">ButtonR1</field></block></value><statement name="DO0"><block type="spin_without_velocity" id="BlfcHiel#GMMTIicgO4."><field name="WIDGET_ID">4</field><field name="p0">FWD</field></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="um*~JQSkAC.8OiNShd|A"><field name="WIDGET_ID">ButtonR2</field></block></value><statement name="DO1"><block type="spin_without_velocity" id="@.O3tAo^6#/f25(.}Y0U"><field name="WIDGET_ID">4</field><field name="p0">REV</field></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="c]!Sk;B9X;gdbHWLBB)N"><field name="WIDGET_ID">4</field><field name="p0">HOLD</field></block></statement><next><block type="controls_if" id="rY~u=ui_8@;a3]4]et,c"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="*#BHM}uXPRovJ`-ANBc^"><field name="WIDGET_ID">ButtonR1</field></block></value><statement name="DO0"><block type="spin_without_velocity" id="^.0|9i1aer3syqFa]~x~"><field name="WIDGET_ID">5</field><field name="p0">FWD</field></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="EOmA5PYNG9},K9b!{]{,"><field name="WIDGET_ID">ButtonR2</field></block></value><statement name="DO1"><block type="spin_without_velocity" id="dx^#(lm8Tj:NxFww^qiY"><field name="WIDGET_ID">5</field><field name="p0">REV</field></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="rsj?-2BSAQzZ_/a(HM`Y"><field name="WIDGET_ID">5</field><field name="p0">HOLD</field></block></statement><next><block type="controls_if" id="BtCNezY#[04Nf1(|sa*a"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="A}W]kCcc{3;iW9/BM)J,"><field name="WIDGET_ID">ButtonR1</field></block></value><statement name="DO0"><block type="spin_without_velocity" id="2=YU[s8q)#T+Vn}]_RL="><field name="WIDGET_ID">6</field><field name="p0">FWD</field></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="ZwR~:K:A+yJCuDpMvQ4t"><field name="WIDGET_ID">ButtonR2</field></block></value><statement name="DO1"><block type="spin_without_velocity" id="eA7%K4%[I99Y@V=bbIe9"><field name="WIDGET_ID">6</field><field name="p0">REV</field></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="=.)@h)#qx4dxCgkgOPW]"><field name="WIDGET_ID">6</field><field name="p0">HOLD</field></block></statement><next><block type="controls_if" id="?@(fVKzGP?+!OVmy6wk~"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="~vMvaw31.5~eg]3[UOAd"><field name="WIDGET_ID">ButtonR1</field></block></value><statement name="DO0"><block type="spin_without_velocity" id="z*aU}}c/gSCYhofgyzut"><field name="WIDGET_ID">7</field><field name="p0">FWD</field></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="*dZXvOZo/y/+|MC-rHh1"><field name="WIDGET_ID">ButtonR2</field></block></value><statement name="DO1"><block type="spin_without_velocity" id="YNdNybwI@,eO~}YL_q)g"><field name="WIDGET_ID">7</field><field name="p0">REV</field></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id=")Kf8b`hF6Q/S/Lvhpc5g"><field name="WIDGET_ID">7</field><field name="p0">HOLD</field></block></statement><next><block type="variables_set" id="ASMq36V2IJij1Lt9oejx"><field name="VAR">LeftMotorSpeed</field><value name="VALUE"><block type="math_arithmetic" id="_pcWM9d!v]NpJ9YWzIIe"><field name="OP">MULTIPLY</field><value name="A"><block type="vexv5_controller_axis_position" id="yXK40,oh,?wE#r_6}*_`"><field name="WIDGET_ID">Axis3</field></block></value><value name="B"><block type="math_number" id=":;FBhxfnGJ6ThQT*fQH{"><field name="NUM">0.5</field></block></value></block></value><next><block type="controls_if" id="ZrF@,:Hj-z6SeH=t;[}I"><mutation else="1"></mutation><value name="IF0"><block type="logic_compare" id=":,)%Vdu-Eng^GZ{zxS}o"><field name="OP">GT</field><value name="A"><block type="math_single" id="1Q?jrlZ`6uLX%8?4;W7Z"><field name="OP">ABS</field><value name="NUM"><block type="variables_get" id="Mg_`T7.K*:]EO]_!1Bbp"><field name="VAR">LeftMotorSpeed</field></block></value></block></value><value name="B"><block type="math_number" id="Q1ho*jfSz[tXjHxUSYms"><field name="NUM">5</field></block></value></block></value><statement name="DO0"><block type="vexv5_motor_set_velocity" id="7r%+nbcNRLzNva8itL;^"><field name="WIDGET_ID">10</field><field name="p1">PCT</field><value name="p0"><block type="variables_get" id="Df8inE:1o9IHI^}xA[vl"><field name="VAR">LeftMotorSpeed</field></block></value><next><block type="spin_without_velocity" id="Xjly8Ndv`UG}}Lq-#p2L"><field name="WIDGET_ID">10</field><field name="p0">FWD</field></block></next></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="fc4RoZWk@/#rt|pe/abp"><field name="WIDGET_ID">10</field><field name="p0">HOLD</field></block></statement><next><block type="variables_set" id="{m7MF@jRi9qQ4td[P+p*"><field name="VAR">RightMotorSpeed</field><value name="VALUE"><block type="math_arithmetic" id="wM=P_aZulm6l%)Y9T0;N"><field name="OP">MULTIPLY</field><value name="A"><block type="vexv5_controller_axis_position" id="RJ3:jYM~8Wh^2`v9#XhG"><field name="WIDGET_ID">Axis2</field></block></value><value name="B"><block type="math_number" id="|pA)AyW.LV^iM!LRm)C2"><field name="NUM">0.5</field></block></value></block></value><next><block type="controls_if" id="(sKNDt0O9Lb#V}Cp+vVK"><mutation else="1"></mutation><value name="IF0"><block type="logic_compare" id="gsl5DN(OOAI#ISvV%QAW"><field name="OP">GT</field><value name="A"><block type="math_single" id="YM-.x#{Q!|:u=YSv81p;"><field name="OP">ABS</field><value name="NUM"><block type="variables_get" id="HnOuUIAFr(.+)5w5kF[`"><field name="VAR">RightMotorSpeed</field></block></value></block></value><value name="B"><block type="math_number" id="hT]=AX/Q,HhYTq~KwmqQ"><field name="NUM">5</field></block></value></block></value><statement name="DO0"><block type="vexv5_motor_set_velocity" id="V`#o64|Dxg*DwBedEk^="><field name="WIDGET_ID">1</field><field name="p1">PCT</field><value name="p0"><block type="variables_get" id="B|e4zU/[~4T`*S?T]nKp"><field name="VAR">RightMotorSpeed</field></block></value><next><block type="spin_without_velocity" id="xqIC_aMRvlB/)Jg#.-FL"><field name="WIDGET_ID">1</field><field name="p0">FWD</field></block></next></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="wkg0K[I5P4BjlwYBStU}"><field name="WIDGET_ID">1</field><field name="p0">HOLD</field></block></statement><next><block type="controls_if" id=":OJQ6D~_EP*E]KR%e[p6"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="vexv5_controller_button_pressing" id="{06)ed(w}8C){%MW_/[,"><field name="WIDGET_ID">ButtonL1</field></block></value><statement name="DO0"><block type="spin_without_velocity" id="D[Lt?t!Q_.Lqh5yOBvL%"><field name="WIDGET_ID">20</field><field name="p0">FWD</field></block></statement><value name="IF1"><block type="vexv5_controller_button_pressing" id="XnQ0g4S([ETFz@^IPgtI"><field name="WIDGET_ID">ButtonL2</field></block></value><statement name="DO1"><block type="spin_without_velocity" id="uF;MQ0.2p/,MS)g8hLn3"><field name="WIDGET_ID">20</field><field name="p0">REV</field></block></statement><statement name="ELSE"><block type="vexv5_motor_stop" id="*Y%LKCRpyWfhzJ|LM2_H"><field name="WIDGET_ID">20</field><field name="p0">HOLD</field></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></next></block></xml> """ import vex import math #region config brain = vex.Brain() Right_Drive = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, True) rightup = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO18_1, False) leftdown = vex.Motor(vex.Ports.PORT5, vex.GearSetting.RATIO18_1, False) leftup = vex.Motor(vex.Ports.PORT6, vex.GearSetting.RATIO18_1, True) rightdown = vex.Motor(vex.Ports.PORT7, vex.GearSetting.RATIO18_1, True) Left_Drive = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, False) Claw = vex.Motor(vex.Ports.PORT20, vex.GearSetting.RATIO18_1, False) dt = vex.Drivetrain(Left_Drive, Right_Drive, 319.1764, 292.1, vex.DistanceUnits.MM) con = vex.Controller(vex.ControllerType.PRIMARY) #endregion config LeftMotorSpeed = None RightMotorSpeed = None competition = vex.Competition() def auto(): dt.set_velocity(100, vex.VelocityUnits.PCT)