Video Display Help

#region VEXcode Generated Robot Configuration
from vex import *
import urandom

# Brain should be defined by default
brain=Brain()

# Robot configuration code
controller_1 = Controller(PRIMARY)
digital_out_a = DigitalOut(brain.three_wire_port.a)


# wait for rotation sensor to fully initialize
wait(30, MSEC)


# Make random actually random
def initializeRandomSeed():
    wait(100, MSEC)
    random = brain.battery.voltage(MV) + brain.battery.current(CurrentUnits.AMP) * 100 + brain.timer.system_high_res()
    urandom.seed(int(random))
      
# Set random seed 
initializeRandomSeed()


def play_vexcode_sound(sound_name):
    # Helper to make playing sounds from the V5 in VEXcode easier and
    # keeps the code cleaner by making it clear what is happening.
    print("VEXPlaySound:" + sound_name)
    wait(5, MSEC)

# add a small delay to make sure we don't print in the middle of the REPL header
wait(200, MSEC)
# clear the console to make sure we don't have the REPL in the console
print("\033[2J")

#endregion VEXcode Generated Robot Configuration
from vex import *
brain = Brain()
controller_1 = Controller(PRIMARY)
digital_out_a = DigitalOut(brain.three_wire_port.a)
digital_out_b = DigitalOut(brain.three_wire_port.b)

left_motor_1 = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)
left_motor_2 = Motor(Ports.PORT2, GearSetting.RATIO_18_1, False)
left_motor_3 = Motor(Ports.PORT3, GearSetting.RATIO_18_1, False)
left_motors = MotorGroup(left_motor_1, left_motor_2, left_motor_3)

right_motor_1 = Motor(Ports.PORT4, GearSetting.RATIO_18_1, True)
right_motor_2 = Motor(Ports.PORT5, GearSetting.RATIO_18_1, True)
right_motor_3 = Motor(Ports.PORT6, GearSetting.RATIO_18_1, True)
right_motors = MotorGroup(right_motor_1, right_motor_2, right_motor_3)

conveyor_motor_1 = Motor(Ports.PORT7, GearSetting.RATIO_18_1,True)
conveyor_motor_1.set_velocity(100,PERCENT)

drivetrain = DriveTrain(left_motors, right_motors, 319.19, 295, 40, MM, 1)
drivetrain.set_drive_velocity(100, PERCENT)

fps = 10  # Change this value to adjust the frame rate
delay_time = 1000 // fps  # Calculate delay in milliseconds

while True:
    for frame_number in range(8, 4945):  # 4945 is exclusive, so it stops at 4944
        # Format the frame filename as 'frame_0008.png', 'frame_0009.png', etc.
        frame_filename = f"frame_{frame_number:04d}.png"

        # Draw the image from file
        brain.screen.draw_image_from_file(frame_filename, 0, 0)

        # Check for controller inputs
        if controller_1.buttonL1.pressing():
            digital_out_a.set(True)
            digital_out_b.set(True)
        elif controller_1.buttonR1.pressing():
            digital_out_a.set(False)
            digital_out_b.set(False)

        if controller_1.buttonB.pressing():
            conveyor_motor_1.spin(REVERSE)
        else:
            conveyor_motor_1.stop()

        left_velocity = controller_1.axis3.position() + controller_1.axis1.position()
        right_velocity = controller_1.axis3.position() - controller_1.axis1.position()

        drivetrain.set_drive_velocity(left_velocity, PERCENT)
        drivetrain.set_drive_velocity(right_velocity, PERCENT)

        drivetrain.drive(FORWARD)

        # Add a delay to control frame rate
        wait(delay_time, MSEC)  # Ensure that delay_time is correctly defined earlier in your code

Idk what is wrong but it gives me a invalid syntax error at line 67 please let me know what is wrong.

Well, this is line 67

frame_filename = f"frame_{frame_number:04d}.png"

we (that is the version of micropython we use) do not support f-strings

4 Likes