Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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 -----------------------------------------------------------------


class Robot:

    x = 0  # x coordinate
    y = 0  # y coordinate
    angle = 0  # current angle of the robot

    # object instantiation
    def __init__(self, dt, turn, speed):

        self.drivetrain = dt  #sets the drivetrain variable
        self.turnSpeed = turn
Exemplo n.º 3
0
"""

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
  direction = 1
  DRC.set_velocity(75, vex.VelocityUnits.PCT)
  DRC.drive_for(vex.DirectionType.REV, 47, vex.DistanceUnits.IN)
  intake.rotate_for_time(vex.DirectionType.FWD, 0.5, vex.TimeUnits.SEC)
"""__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,
Exemplo n.º 5
0
# VEX V5 Python-Project with Competition Template
#Imports
import sys
import vex
import math

#Variables
brain = vex.Brain()
dev = vex.Devices()
motor_right = vex.Motor(vex.Ports.PORT11, vex.GearSetting.RATIO18_1, True)
motor_left = vex.Motor(vex.Ports.PORT20, vex.GearSetting.RATIO18_1, False)
motor_claw = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, True)
motor_arm = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True)
con = vex.Controller(vex.ControllerType.PRIMARY)
driveTrain = vex.Drivetrain(motor_left, motor_right, 319.1764, 292.1,
                            vex.DistanceUnits.CM)
con.set_deadband(10)
print("A welcome change!")


#Procedures
def pre_auton():
    # All activities that occur before competition start
    # Example: setting initial positions
    pass


#*******************************************************************************
def ToCm(value, units):
    if units == "FEET":
        return value * 12 * 2.54
Exemplo n.º 6
0
"""__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)
<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)
    dt.drive_for(vex.DirectionType.REV, 50, vex.DistanceUnits.CM)
    dt.drive_for(vex.DirectionType.FWD, 15, vex.DistanceUnits.CM)