Function execution issue with VEXCode VR

I have the following code below:

def angle_to(x, y):
    dx = x - gps.x_position(MM)
    dy = y - gps.y_position(MM)
    return 90 - math.degrees(math.atan2(dy, dx))

def distance_to(x, y):
    dx = x - gps.x_position(MM)
    dy = y - gps.y_position(MM)
    return math.hypot(dx, dy)

def drive_towards_xy(x, y, target_heading=None, reverse=False, intake=False, wait_time=1.5):
    if intake:
        intake_motor.spin(FORWARD)

    d = distance_to(x, y)
    a = angle_to(x, y)

    if reverse:
        drivetrain.turn_to_heading(float(270 - a), DEGREES)
        drivetrain.drive_for(REVERSE, float(d), MM)
    else:
        drivetrain.turn_to_heading(float(90 - a), DEGREES)
        drivetrain.drive_for(FORWARD, float(d), MM)  

    if target_heading is not None:
        drivetrain.turn_to_heading(target_heading, DEGREES)

    if intake:
        intake_motor.stop()
        
# Add project code in "main"
def main():
    drivetrain.set_drive_velocity(100, PERCENT)
    drivetrain.set_turn_velocity(100, PERCENT)
    arm_motor.set_velocity(100, PERCENT)
    intake_motor.set_velocity(100, PERCENT)

    arm_motor.spin_to_position(6, TURNS)

    drive_towards_xy(-600, -300, target_heading=0, intake=True)
   

# VR threads TEST — Do not delete
vr_thread(main)

At the moment, the drive_towards_xy function does nothing. But when I write async before the call to drive_towards_xy, it starts working. I’m assuming that vexcode vr is doing something behind in the background that I’m not aware of, and that the issue i’m facing is a bug within vexcode vr itself. what should I do?

  • abi