Iβve tried that and it does not seem to work. What is the problem? Thank you in advance.
Full Code
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββRobotics βββββββββββββββββββ
# ββββββββββββββ Is The βββββββββββββββββββ
# ββββββββββββββ Best βββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# ββββββββββββββββββββββββββββββββββββββββββ
# _______β__________ββββββββββββββ
# ______β_______________ββββββββ
# _____β________________ββββββββ
# ____β___________ββββββββββββββββββ
# ___β
# __β______βββββββββββββββββββββββββββββββββββ
# _β______βββββββββββββββββββββββββββββββββββ
# ββββ___βββββββββββββββββββββββββββββββββββ
# ββββ__βββββββββββββββββββββββββββββββββββ
# βββ__βββββββββββββββββββββββββββββββββββ
# ββ
# VEX V5 Python Project with Competition Template
import sys
import vex
from vex import *
#region config
brain = vex.Brain()
Right_Front = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO18_1, True)
Right_Back = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO18_1, True)
Left_Front = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO18_1, False)
Left_Back = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO18_1, False)
Tilt = vex.Motor(vex.Ports.PORT7, vex.GearSetting.RATIO18_1, False)
Intake_Left = vex.Motor(vex.Ports.PORT10, vex.GearSetting.RATIO18_1, True)
Intake_Right = vex.Motor(vex.Ports.PORT20, vex.GearSetting.RATIO18_1, False)
Autton_1 = vex.Limit(brain.three_wire_port.a)
Autton_2 = vex.Limit(brain.three_wire_port.b)
Autton_3 = vex.Limit(brain.three_wire_port.c)
Autton_4 = vex.Limit(brain.three_wire_port.d)
Autton_5 = vex.Limit(brain.three_wire_port.e)
Autton_6 = vex.Limit(brain.three_wire_port.f)
Autton_7 = vex.Limit(brain.three_wire_port.g)
Autton_8 = vex.Limit(brain.three_wire_port.h)
con = vex.Controller(vex.ControllerType.PRIMARY)
#endregion config
Right = None
Left = None
Drive_Speed = None
Speed = None
def Drive(Right, Left, Drive_Speed):
Right_Front.set_velocity(Drive_Speed, vex.VelocityUnits.PCT)
Right_Back.set_velocity(Drive_Speed, vex.VelocityUnits.PCT)
Left_Front.set_velocity(Drive_Speed, vex.VelocityUnits.PCT)
Left_Back.set_velocity(Drive_Speed, vex.VelocityUnits.PCT)
Right_Front.start_rotate_for(vex.DirectionType.FWD, Right, vex.RotationUnits.REV)
Right_Back.start_rotate_for(vex.DirectionType.FWD, Right, vex.RotationUnits.REV)
Left_Front.start_rotate_for(vex.DirectionType.FWD, Left, vex.RotationUnits.REV)
Left_Back.rotate_for(vex.DirectionType.FWD, Left, vex.RotationUnits.REV)
def Turn_Intake(Speed):
Intake_Left.spin(vex.DirectionType.FWD, Speed, vex.VelocityUnits.PCT)
Intake_Right.spin(vex.DirectionType.FWD, Speed, vex.VelocityUnits.PCT)
# Creates a competition object that allows access to Competition methods.
competition = vex.Competition()
def pre_auton():
# All activities that occur before competition start
# Example: setting initial positions
pass
# Autton_5 is Red Procted
# Autton_6 is Red UnProcted
# Autton_7 is Blue Procted
# Autton_8 is Blue UnProcted
def autonomous():
if Autton_5.pressing():
Drive(1, 1, 50)
Drive(-1, -1, 50)
elif Autton_6.pressing():
Drive(1, 1, 50)
Drive(-1, -1, 50)
elif Autton_7.pressing():
Drive(1, 1, 50)
Drive(-1, -1, 50)
elif Autton_8.pressing():
Drive(1, 1, 50)
Drive(-1, -1, 50)
elif Autton_1.pressing():
# Turn_Intake(None)
# Drive(None, None, None)
# Turn_Intake(None)
# Drive(None, None, None)
# Drive(None, None, None)
# sys.sleep(1)
# Drive(None, None, None)
# Drive(None, None, None)
# Drive(None, None, None)
# Turn_Intake(None)
# Drive(None, None, None)
# Drive(None, None, None)
# Drive(None, None, None)
brain.screen.print_line(1, 'No Jumper in Programed Port!')
con.screen.set_cursor(1, 1)
con.screen.print_('No Jumper in Programed Port!')
elif Autton_2.pressing():
brain.screen.print_line(1, 'No Jumper in Programed Port!')
con.screen.set_cursor(1, 1)
con.screen.print_('No Jumper in Programed Port!')
elif Autton_3.pressing():
brain.screen.print_line(1, 'No Jumper in Programed Port!')
con.screen.set_cursor(1, 1)
con.screen.print_('No Jumper in Programed Port!')
elif Autton_4.pressing():
brain.screen.print_line(1, 'No Jumper in Programed Port!')
con.screen.set_cursor(1, 1)
con.screen.print_('No Jumper in Programed Port!')
else:
brain.screen.print_line(1, 'No Jumper In The Robot!')
con.screen.set_cursor(1, 1)
con.screen.print_('No Jumper!')
pass
pass
def drivercontrol():
# Place drive control code here, inside the loop
# This code will run onece:
Intake = 0
while True:
# This code will repete
# This is the main loop for the driver control.
# Drive the robot using tank drive
con.set_deadband(10, vex.PercentUnits.PCT)
# Right_Front.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)*0.65), vex.VelocityUnits.PCT)
# Right_Back.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)*0.65), vex.VelocityUnits.PCT)
# Left_Front.spin(vex.DirectionType.FWD, (con.axis3.position(vex.PercentUnits.PCT)*0.65), vex.VelocityUnits.PCT)
# Left_Back.spin(vex.DirectionType.FWD, (con.axis3.position(vex.PercentUnits.PCT)*0.65), vex.VelocityUnits.PCT)
Right_Front.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)/100)**3)*100, vex.VelocityUnits.PCT)
Left_Front.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)/100)**3)*100, vex.VelocityUnits.PCT)
Right_Back.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)/100)**3)*100, vex.VelocityUnits.PCT)
Left_Back.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)/100)**3)*100, vex.VelocityUnits.PCT)
# Move the tilt tray if the buttons get pushed
if con.buttonA.pressing():
Tilt.spin(vex.DirectionType.FWD, 30, vex.VelocityUnits.PCT)
elif con.buttonB.pressing():
Tilt.spin(vex.DirectionType.REV, 30, vex.VelocityUnits.PCT)
else:
Tilt.stop(vex.BrakeType.COAST)
Tilt.spin(vex.DirectionType.REV, 0, vex.VelocityUnits.PCT)
Tilt.stop
#Spin the intake if the burrons are pushed
if con.buttonL1.pressing():
Intake_Left.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.RPM)
elif con.buttonL2.pressing():
Intake_Left.spin(vex.DirectionType.REV, 100, vex.VelocityUnits.RPM)
else:
Intake_Left.spin(vex.DirectionType.FWD, 0, vex.VelocityUnits.RPM)
if con.buttonR1.pressing():
Intake_Right.spin(vex.DirectionType.FWD, 100, vex.VelocityUnits.RPM)
elif con.buttonR2.pressing():
Intake_Right.spin(vex.DirectionType.REV, 100, vex.VelocityUnits.RPM)
else:
Intake_Right.spin(vex.DirectionType.FWD, 0, vex.VelocityUnits.RPM)
sys.sleep(0.2)
pass
# Do not adjust the lines below
# Set up (but don't start) callbacks for autonomous and driver control periods.
competition.autonomous(autonomous)
competition.drivercontrol(drivercontrol)
# Run the pre-autonomous function.
pre_auton()
# Robot Mesh Studio runtime continues to run until all threads and
# competition callbacks are finished.