Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions tests/sitl/test_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
import time
import sys
import os
from testlib import assert_equals

def current_milli_time():
return int(round(time.time() * 1000))

def test_timeout(local_connect):
v = local_connect().get_vehicles()[0]

print "Read vehicle param 'THR_MIN': %s" % v.parameters['THR_MIN']
value = v.parameters['THR_MIN']
assert_equals(type(value), float)

print "Write vehicle param 'THR_MIN' : 50"
start = current_milli_time()
v.parameters['THR_MIN']=50
v.parameters['THR_MIN'] = value + 10
end = current_milli_time()

print "Read new value of param 'THR_MIN': %s" % v.parameters['THR_MIN']

# TODO
newvalue = v.parameters['THR_MIN']
assert_equals(type(newvalue), float)
assert_equals(newvalue, value + 10)

# TODO once this issue is fixed
# assert end - start < 1000, 'time to set parameter was %s, over 1s' % (end - start,)
26 changes: 13 additions & 13 deletions tests/sitl/test_goto.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ def arm_and_takeoff(aTargetAltitude):
Arms vehicle and fly to aTargetAltitude.
"""

print "Basic pre-arm checks"
# print "Basic pre-arm checks"
# Don't let the user try to fly autopilot is booting
if vehicle.mode.name == "INITIALISING":
print "Waiting for vehicle to initialise"
# print "Waiting for vehicle to initialise"
time.sleep(1)
while vehicle.gps_0.fix_type < 2:
print "Waiting for GPS...:", vehicle.gps_0.fix_type
# print "Waiting for GPS...:", vehicle.gps_0.fix_type
time.sleep(1)

print "Arming motors"
# print "Arming motors"
# Copter should arm in GUIDED mode
vehicle.mode = VehicleMode("GUIDED")
vehicle.flush()

i = 60
while not api.exit and vehicle.mode.name != 'GUIDED' and i > 0:
print " Waiting for guided %s seconds..." % (i,)
# print " Waiting for guided %s seconds..." % (i,)
time.sleep(1)
i = i - 1

Expand All @@ -46,49 +46,49 @@ def arm_and_takeoff(aTargetAltitude):

i = 60
while not api.exit and not vehicle.armed and vehicle.mode.name == 'GUIDED' and i > 0:
print " Waiting for arming %s seconds..." % (i,)
# print " Waiting for arming %s seconds..." % (i,)
time.sleep(1)
i = i - 1

# Failure will result in arming but immediately landing
assert vehicle.armed
assert_equals(vehicle.mode.name, 'GUIDED')

print "Taking off!"
# print "Taking off!"
vehicle.commands.takeoff(aTargetAltitude) # Take off to target altitude
vehicle.flush()

# Wait until the vehicle reaches a safe height before
# processing the goto (otherwise the command after
# Vehicle.commands.takeoff will execute immediately).
while not api.exit:
print " Altitude: ", vehicle.location.alt
# print " Altitude: ", vehicle.location.alt
# Test for altitude just below target, in case of undershoot.
if vehicle.location.alt >= aTargetAltitude * 0.95:
print "Reached target altitude"
break;
# print "Reached target altitude"
break

assert_equals(vehicle.mode.name, 'GUIDED')
time.sleep(1)

arm_and_takeoff(10)

print "Going to first point..."
# print "Going to first point..."
point1 = Location(-35.361354, 149.165218, 20, is_relative=True)
vehicle.commands.goto(point1)
vehicle.flush()

# sleep so we can see the change in map
time.sleep(3)

print "Going to second point..."
# print "Going to second point..."
point2 = Location(-35.363244, 149.168801, 20, is_relative=True)
vehicle.commands.goto(point2)
vehicle.flush()

# sleep so we can see the change in map
time.sleep(3)

print "Returning to Launch"
# print "Returning to Launch"
vehicle.mode = VehicleMode("RTL")
vehicle.flush()
12 changes: 0 additions & 12 deletions tests/sitl/test_simple.py

This file was deleted.

25 changes: 25 additions & 0 deletions tests/sitl/test_simpledemo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
This test represents a simple demo for testing.
Feel free to copy and modify at your leisure.
"""

from droneapi.lib import VehicleMode
from pymavlink import mavutil
import time
import sys
import os
from testlib import assert_equals

# This test runs first!
def test_parameter(local_connect):
v = local_connect().get_vehicles()[0]

# Perform a simple parameter check
assert_equals(type(v.parameters['THR_MIN']), float)

# This test runs second. Add as many tests as you like
def test_mode(local_connect):
v = local_connect().get_vehicles()[0]

# Ensure Mode is an instance of VehicleMode
assert isinstance(v.mode, VehicleMode)