When I start the code it immediately goes back to the program screen. I know the fault is in driver program because before i added parts of code from controller express into the driver program it worked. I am using robot mesh.
these are the parts I added
motor_left_power = 0
motor_right_power = 0
move = joystick.axis1()
steer = joystick.axis3()
if move != 0 cor steer != 0:
motor_right_power = move - steer
if move != 0 or steer != 0:
motor_left_power = move + steer
motor_right.spin(vex.DirectionType.FWD, motor_right_power)
motor_left.spin(vex.DirectionType.FWD, motor_right_power)
this is the full code
import vex
import sys
#region config
brain = vex.Brain()
motor_right = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, False)
motor_left = vex.Motor(vex.Ports.PORT16, vex.GearSetting.RATIO18_1, True)
dt = vex.Drivetrain(motor_left, motor_right, 319.1764, 292.1, vex.DistanceUnits.MM)
con = vex.Controller(vex.ControllerType.PRIMARY)
#endregion config
competition = vex.Competition()
def driver():
# Place drive control code here, inside the loop
while True:
motor_left_power = 0
motor_right_power = 0
# This is the main loop for the driver control.
# Each time through the loop you should update motor
# movements based on input from the controller.
#motor_left.spin(vex.DirectionType.FWD, (con.axis3.position(vex.PercentUnits.PCT)), vex.VelocityUnits.PCT)
#motor_right.spin(vex.DirectionType.FWD, (con.axis2.position(vex.PercentUnits.PCT)), vex.VelocityUnits.PCT)
move = joystick.axis1()
steer = joystick.axis3()
if move != 0 cor steer != 0:
motor_right_power = move - steer
if move != 0 or steer != 0:
motor_left_power = move + steer
motor_right.spin(vex.DirectionType.FWD, motor_right_power)
motor_left.spin(vex.DirectionType.FWD, motor_right_power)
competition.drivercontrol(driver)
def auto():
# Place autonomous code here
dt.drive_for(vex.DirectionType.FWD, 24, vex.DistanceUnits.IN)
dt.turn_for(vex.TurnType.LEFT, 180, vex.RotationUnits.DEG)
dt.drive_for(vex.DirectionType.FWD, 24, vex.DistanceUnits.IN)
dt.turn_for(vex.TurnType.LEFT, 180, vex.RotationUnits.DEG)
competition.autonomous(auto)
# main thread
# All activities that occur before competition start
# Example: setting initial positions
con.set_deadband(5, vex.PercentUnits.PCT)
dt.set_velocity(20, vex.VelocityUnits.PCT)