def test_fence_breach_failsafe(self, checkGPS=True):
     wait_seconds(self.DELAY)
     self.mavproxy.send('fence load %sRegressionFence\n' % self.resource_path)
     wait_seconds(self.DELAY)
     self.mavproxy.send('fence enable\n')
     wait_seconds(5)
     assert testutils.check_mode(self, 'GUIDED')
     if checkGPS:
         assert testutils.check_GPS(self), "GPS Failsafe test failed."
    def test_heartbeat_failsafe(self, checkGPS=True):

        self.mavproxy.send('fence disable\n')
        wait_seconds(self.DELAY)
        self.mavproxy.send('set heartbeat 0\n')
        wait_seconds(self.DELAY)
        assert testutils.check_mode(self, 'RTL', 3, delay=21)
        if checkGPS:
            assert testutils.check_GPS(self), "GPS Failsafe test failed."
    def test_heartbeat_failsafe(self, checkGPS=True):

        self.mavproxy.send('fence disable\n')
        wait_seconds(self.DELAY)
        self.mavproxy.send('set heartbeat 0\n')
        wait_seconds(self.DELAY)
        assert testutils.check_mode(self, 'RTL', 3, delay=21)
        if checkGPS:
            assert testutils.check_GPS(self), "GPS Failsafe test failed."
예제 #4
0
def test_fence_breach_failsafe(self, checkGPS=True):
    wait_seconds(self.DELAY)
    self.mavproxy.send('fence load %sRegressionFence\n' % self.resource_path)
    wait_seconds(self.DELAY)
    self.mavproxy.send('fence enable\n')
    wait_seconds(5)
    assert testutils.check_mode(self, 'GUIDED')
    if checkGPS:
        assert testutils.check_GPS(self), "GPS Failsafe test failed."
    def test_battery_current_failsafe(self, checkGPS=True):

        self.oldCurrentValue = testutils.get_old_value(self, 'FS_BATT_MAH')

        wait_seconds(self.DELAY)
        self.mavproxy.send('param set FS_BATT_MAH 123456\n')
        #Should trigger immediately
        assert testutils.check_mode(self, 'RTL', delay=1)
        if checkGPS:
            assert testutils.check_GPS(self), "GPS Failsafe test failed."
    def test_battery_current_failsafe(self, checkGPS=True):

        self.oldCurrentValue = testutils.get_old_value(self, 'FS_BATT_MAH')

        wait_seconds(self.DELAY)
        self.mavproxy.send('param set FS_BATT_MAH 123456\n')
        #Should trigger immediately
        assert testutils.check_mode(self, 'RTL', delay=1)
        if checkGPS:
            assert testutils.check_GPS(self), "GPS Failsafe test failed."
예제 #7
0
def check_overrides(cls, startMode):
    #TODO: Why isnt setup running?
    cls.mavproxy.send('set heartbeat 1\n')
    wait_seconds(cls.DELAY)
    cls.mavproxy.send('mode AUTO\n')
    wait_seconds(cls.DELAY)
    print("STARTING %s OVERRIDE TESTS" % startMode)
    cls.mavproxy.send('wp set 3\n')
    wait_seconds(cls.DELAY)

    testList = [test_battery_current_failsafe,
    #cls.test_battery_voltage_failsafe,
    test_gps_failsafe,
    test_fence_breach_failsafe,
    test_heartbeat_failsafe
    ]

    testResults = {}


    testutils.wait_altitude(cls, 1400, 1500, timeout=180)

    for test in testList:

        print("Running %s" % test.__name__)
        try:

            print("Starting try")

            wait_seconds(cls.DELAY)
            print("Test starting.")
            cls.setup(altCheck=False)
            print("GOING UP")
            cls.mavproxy.send('wp set 3\n')
            testutils.wait_altitude(cls, 1300, 1500, timeout=50)
            wait_seconds(cls.DELAY)
            testutils.wait_altitude(cls, 1300, 1500, timeout=50)
            print("NOW UP")
            cls.mavproxy.send('mode %s\n' % startMode)
            testutils.check_mode(cls, '%s' % startMode)
            wait_seconds(cls.DELAY)
            cls.mavproxy.send('fence disable\n')
            wait_seconds(cls.DELAY)
            test(cls, False)
            wait_seconds(cls.DELAY)
            cls.mavproxy.send('fence disable\n')
            wait_seconds(cls.DELAY)
            cls.teardown()
            print("Test finished.")
            wait_seconds(cls.DELAY)

        #Exception is thrown by test's assert if the failsafe RTL is not triggered
        except Exception as e:

            wait_seconds(cls.DELAY)
            print("Failsafe didn't trip -- this means %s override is working" % startMode)
            print(e)
            success = True
            wait_seconds(cls.DELAY)
        else:

            wait_seconds(cls.DELAY)
            print("Failsafe tripped -- this shouldn't happen")
            success = False
            wait_seconds(cls.DELAY)
        finally:

            testResults[test.__name__] = success

    print testResults
    print '%s overrides successfully passed: %r' %(startMode, (not False in testResults.values()))
    assert not False in testResults.values()
예제 #8
0
def check_overrides(cls, startMode):
    #TODO: Why isnt setup running?
    cls.mavproxy.send('set heartbeat 1\n')
    wait_seconds(cls.DELAY)
    cls.mavproxy.send('mode AUTO\n')
    wait_seconds(cls.DELAY)
    print("STARTING %s OVERRIDE TESTS" % startMode)
    cls.mavproxy.send('wp set 3\n')
    wait_seconds(cls.DELAY)

    testList = [
        test_battery_current_failsafe,
        #cls.test_battery_voltage_failsafe,
        test_gps_failsafe,
        test_fence_breach_failsafe,
        test_heartbeat_failsafe
    ]

    testResults = {}

    testutils.wait_altitude(cls, 1400, 1500, timeout=180)

    for test in testList:

        print("Running %s" % test.__name__)
        try:

            print("Starting try")

            wait_seconds(cls.DELAY)
            print("Test starting.")
            cls.setup(altCheck=False)
            print("GOING UP")
            cls.mavproxy.send('wp set 3\n')
            testutils.wait_altitude(cls, 1300, 1500, timeout=50)
            wait_seconds(cls.DELAY)
            testutils.wait_altitude(cls, 1300, 1500, timeout=50)
            print("NOW UP")
            cls.mavproxy.send('mode %s\n' % startMode)
            testutils.check_mode(cls, '%s' % startMode)
            wait_seconds(cls.DELAY)
            cls.mavproxy.send('fence disable\n')
            wait_seconds(cls.DELAY)
            test(cls, False)
            wait_seconds(cls.DELAY)
            cls.mavproxy.send('fence disable\n')
            wait_seconds(cls.DELAY)
            cls.teardown()
            print("Test finished.")
            wait_seconds(cls.DELAY)

        #Exception is thrown by test's assert if the failsafe RTL is not triggered
        except Exception as e:

            wait_seconds(cls.DELAY)
            print("Failsafe didn't trip -- this means %s override is working" %
                  startMode)
            print(e)
            success = True
            wait_seconds(cls.DELAY)
        else:

            wait_seconds(cls.DELAY)
            print("Failsafe tripped -- this shouldn't happen")
            success = False
            wait_seconds(cls.DELAY)
        finally:

            testResults[test.__name__] = success

    print testResults
    print '%s overrides successfully passed: %r' % (startMode,
                                                    (not False
                                                     in testResults.values()))
    assert not False in testResults.values()