Skip to content

Commit

Permalink
Begin creating tests #16
Browse files Browse the repository at this point in the history
  • Loading branch information
RexBerry committed Oct 26, 2022
1 parent e7e6afa commit 2c9a946
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flight/avoidance/opensitl_multiple_drones.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd ../../../PX4-Autopilot
export PX4_HOME_LAT=37.9490953
export PX4_HOME_LON=-91.7848293
#export PX4_SIM_SPEED_FACTOR=1.5
make px4_sitl_default
gnome-terminal -- /bin/sh -c "./Tools/simulation/sitl_multiple_run.sh 2; ./Tools/simulation/jmavsim/jmavsim_run.sh -l"
gnome-terminal -- ./Tools/simulation/jmavsim/jmavsim_run.sh -p 4561 -l
57 changes: 57 additions & 0 deletions flight/avoidance/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System


async def run():

drone = System()
print("Will connect")
await drone.connect(system_address="udp://:14540")
print("Connected")

status_text_task = asyncio.ensure_future(print_status_text(drone))

print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print(f"-- Connected to drone!")
break

print("Waiting for drone to have a global position estimate...")
async for health in drone.telemetry.health():
if health.is_global_position_ok and health.is_home_position_ok:
print("-- Global position estimate OK")
break

print("-- Arming")
await drone.action.arm()

print("-- Taking off")
await drone.action.takeoff()

await asyncio.sleep(10)

print("-- Landing")
await drone.action.land()

status_text_task.cancel()



async def print_status_text(drone):
try:
async for status_text in drone.telemetry.status_text():
print(f"Status: {status_text.type}: {status_text.text}")
except asyncio.CancelledError:
return


if __name__ == "__main__":
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
asyncio.run(run())

0 comments on commit 2c9a946

Please sign in to comment.