Needs example of python script to run drone using pix4flow with no gps

needs example of python script to run drone using pix4flow with no gps
mport time
import math
import numpy as np
from dronekit import connect, VehicleMode, LocationGlobalRelative

Connect to the vehicle

connection_string = ‘/dev/ttyACM0’ # Replace with your connection string
vehicle = connect(connection_string, baud=921600, wait_ready=True)

Set vehicle mode to GUIDED and ARMED

vehicle.mode = VehicleMode(‘GUIDED’)
vehicle.armed = True

Wait until the vehicle is armed and in GUIDED mode

while not vehicle.mode.name == ‘GUIDED’ or not vehicle.armed:
time.sleep(1)

Take off to a height of 5 meters

target_altitude = 5
vehicle.simple_takeoff(target_altitude)

Wait until the vehicle reaches the target altitude

while True:
current_altitude = vehicle.rangefinder.distance
if current_altitude >= target_altitude * 0.95:
break
time.sleep(1)

Disable GPS and use Pix4Flow for position estimation

vehicle.parameters[‘EKF_GPS_TYPE’] = 3
vehicle.parameters[‘EK2_GPS_TYPE’] = 3
vehicle.parameters[‘EK2_FLOW_DELAYCOMP’] = 1
vehicle.parameters[‘EK2_FLOW_USE_HGT’] = 1

Wait for the Pix4Flow camera to start streaming data

while not vehicle.groundspeed:
time.sleep(0.1)

Set the maximum ground speed to 1 m/s

vehicle.parameters[‘WPNAV_SPEED’] = 100

Move forward for 5 seconds

start_time = time.time()
while time.time() - start_time < 5:
vehicle.send_mavlink(vehicle.message_factory.set_position_target_local_ned_encode(
time_boot_ms=int(time.time() * 1000),
target_system=vehicle._vehicle_id,
target_component=0,
coordinate_frame=8,
type_mask=4039,
vx=1,
vy=0,
vz=0,
yaw_rate=0,
))
time.sleep(0.1)

Turn right for 5 seconds

start_time = time.time()
while time.time() - start_time < 5:
vehicle.send_mavlink(vehicle.message_factory.set_position_target_local_ned_encode(
time_boot_ms=int(time.time() * 1000),
target_system=vehicle._vehicle_id,
target_component=0,
coordinate_frame=8,
type_mask=4039,
vx=0,
vy=0,
vz=0,
yaw_rate=-math.pi/4,
))
time.sleep(0.1)

Move forward for 5 seconds

start_time = time.time()
while time.time() - start_time < 5:
vehicle.send_mavlink(vehicle.message_factory.set_position_target_local_ned_encode(
time_boot_ms=int(time.time() * 1000),
target_system=vehicle._vehicle_id,
target_component=0,
coordinate_frame=8,
type_mask=4039,
vx=1,
vy=0,
vz=0,
yaw_rate=0,
))
time.sleep(0.1)

Turn left for 5 seconds

start_time = time.time()
while time.time() - start_time < 5:
vehicle.send_mavlink(vehicle.message_factory.set_position_target_local_ned_encode(
time_boot_ms=int(time.time() * 1000),
target_system=vehicle._vehicle_id,
target_component=0,
coordinate_frame