示例#1
0
def test_altitude_ok(monkeypatch):
    """test_altitude_ok()
    """
    def new_Auv_init(self):
        class new_Auv_MOOS(object):
            def publish_variable(self, variable, value, dummy):
                pass

        self._auv_data = dict()
        self._auv_data['NAV_ALTITUDE'] = 5.0

        self._current_waypoint = dict()
        self._current_waypoint['x'] = 0.0
        self._current_waypoint['y'] = 0.0
        self._current_waypoint['depth'] = 0.0

        self.auv_control = new_Auv_MOOS()

    from auv.auv import Auv
    monkeypatch.setattr(Auv, '__init__', new_Auv_init)

    from auv_bonus_xprize.settings import config
    config['auv']['min_altitude_meters'] = '2.5'
    config['variables']['altitude'] = 'NAV_ALTITUDE'

    auv = Auv()

    assert auv.altitude_safety() == 0.0
示例#2
0
def test_on_the_waypoint(monkeypatch, mocker):
    """test_on_the_waypoint()
    """

    from auv_bonus_xprize.settings import config
    config['auv']['distance_tolerance'] = '2.0'
    config['auv']['depth_tolerance'] = '1.0'
    config['variables']['easting_x'] = 'NAV_X'
    config['variables']['northing_y'] = 'NAV_Y'
    config['variables']['set_heading'] = 'DESIRED_HEADING'
    config['variables']['set_depth'] = 'DESIRED_DEPTH'
    config['variables']['set_speed'] = 'DESIRED_SPEED'
    config['variables']['depth'] = 'NAV_DEPTH'
    config['variables']['heading'] = 'NAV_HEADING'
    config['variables']['speed'] = 'NAV_SPEED'

    from auv.auv import variables_list

    def new_Auv_init(self):
        class new_Auv_MOOS(object):
            def publish_variable(self, variable, value, dummy):
                pass

        self._auv_data = dict()
        for variable_name in variables_list():
            self._auv_data[variable_name] = None

        self._current_waypoint = dict()
        self._current_waypoint['x'] = 0.0
        self._current_waypoint['y'] = 0.0
        self._current_waypoint['depth'] = 0.0

        self.auv_control = new_Auv_MOOS()

    from auv.auv import Auv
    monkeypatch.setattr(Auv, '__init__', new_Auv_init)

    auv = Auv()

    monkeypatch.setattr(auv, '_auv_data', {
        'NAV_X': 10.0,
        'NAV_Y': 10.0,
        'NAV_DEPTH': 5.0
    })
    mocker.patch.object(auv, 'altitude_safety', return_value=0.0)

    waypoint = (10, 10, 5, 90)
    assert auv.move_toward_waypoint(waypoint) == 'DONE'

    waypoint = (11, 10, 5, 90)
    assert auv.move_toward_waypoint(waypoint) == 'DONE'
def test_constrain_search_area(monkeypatch, mocker, auv_position):
    """test_constrain_search_area()
    """

    from auv_bonus_xprize.auv_main_loop import constrain_search_area

    from auv.auv import variables_list

    def new_Auv_init(self):
        class new_Auv_MOOS(object):
            def publish_variable(self, variable, value, dummy):
                pass

        self._auv_data = dict()
        for variable_name in variables_list():
            self._auv_data[variable_name] = None

        self.auv_control = new_Auv_MOOS()

    from auv.auv import Auv
    monkeypatch.setattr(Auv,
                        '__init__',
                        new_Auv_init)

    from auv_bonus_xprize.settings import config

    easting_x = config['variables']['easting_x']
    northing_y = config['variables']['northing_y']
    depth = config['variables']['depth']
    auv = Auv()
    monkeypatch.setattr(auv,
                        '_auv_data',
                        {easting_x: auv_position[0],
                         northing_y: auv_position[1],
                         depth: auv_position[2]})

    config['starting']['set'] = '90'
    config['search']['min_depth_meters'] = '5.0'
    config['search']['up_current_offset'] = '5.0'
    config['search']['vertex_offset'] = '10.0'
    config['search']['min_depth_offset'] = '10.0'

    constrain_search_area(auv, object())
    assert config['starting']['auv_position_utm'] == '95.0,200.0'
    assert config['search']['min_depth_meters'] == '5.0'

    monkeypatch.setattr(auv,
                        '_auv_data',
                        {easting_x: auv_position[0],
                         northing_y: auv_position[1],
                         depth: 25.0})

    constrain_search_area(auv, object())
    assert config['search']['min_depth_meters'] == '15.0'
    assert config['starting']['northwest_utm'] == '85.0,210.0'
    assert config['starting']['northeast_utm'] == '105.0,210.0'
    assert config['starting']['southeast_utm'] == '105.0,190.0'
    assert config['starting']['southwest_utm'] == '85.0,190.0'
示例#4
0
def main_loop():
    """main_loop()

    The main logic loop for the AUV control system.
    """

    logging.debug('Instantiating the SearchSpace() object')
    search_space = SearchSpace()
    search_space.set_search_boundaries()
    search_space.set_current_velocity()

    logging.debug('Instantiating the Auv() object')
    auv = Auv()
    auv.watchdog.reset()
    logging.debug('Waiting until the AUV is connected')
    while not auv.auv_control.connected:
        sleep(1.0)
    logging.debug('AUV is connected')

    system_state = AUVState.WaitingToStart

    logging.debug('Starting the state loop')
    auv.watchdog.reset()
    while system_state not in [AUVState.AbortMission,
                               AUVState.ReportResults]:

        if limit_reached(auv):
            system_state = AUVState.AbortMission
            break

        system_state = state_function[system_state](
            auv,
            search_space)

        auv.watchdog.reset()

    state_function[system_state](auv, search_space)
def test_turn_toward_heading(monkeypatch, mocker):
    """test_turn_toward_heading()
    """

    from auv.auv import variables_list

    def new_Auv_init(self):
        class new_Auv_MOOS(object):
            def publish_variable(self, variable, value, dummy):
                pass

        self._auv_data = dict()
        for variable_name in variables_list():
            self._auv_data[variable_name] = None

        self._current_waypoint = dict()
        self._current_waypoint['x'] = 0.0
        self._current_waypoint['y'] = 0.0
        self._current_waypoint['depth'] = 0.0

        self.auv_control = new_Auv_MOOS()

    from auv.auv import Auv
    monkeypatch.setattr(Auv, '__init__', new_Auv_init)

    from auv_bonus_xprize.settings import config
    config['auv']['spiral_amount'] = '20'

    auv = Auv()

    assert auv.turn_toward_heading(90, 100) == 110
    assert auv.turn_toward_heading(100, 100) == 120
    assert auv.turn_toward_heading(100, 90) == 80
    assert auv.turn_toward_heading(350, 10) == 10
    assert auv.turn_toward_heading(10, 350) == 350
    assert auv.turn_toward_heading(90, 10) == 70
示例#6
0
def test_distance_to_waypoint(monkeypatch, mocker, auv_position, auv_waypoint):
    """test_distance_to_waypoint()
    """

    from auv.auv import variables_list

    def new_Auv_init(self):
        class new_Auv_MOOS(object):
            def publish_variable(self, variable, value, dummy):
                pass

        self._auv_data = dict()
        for variable_name in variables_list():
            self._auv_data[variable_name] = None

        self._current_waypoint = dict()
        self._current_waypoint['x'] = 0.0
        self._current_waypoint['y'] = 0.0
        self._current_waypoint['depth'] = 0.0

        self.auv_control = new_Auv_MOOS()

    from auv.auv import Auv
    monkeypatch.setattr(Auv, '__init__', new_Auv_init)

    from auv_bonus_xprize.settings import config

    easting_x = config['variables']['easting_x']
    northing_y = config['variables']['northing_y']
    depth = config['variables']['depth']
    auv = Auv()
    monkeypatch.setattr(
        auv, '_auv_data', {
            easting_x: auv_waypoint[0],
            northing_y: auv_waypoint[1],
            depth: auv_waypoint[2]
        })
    mocker.patch.object(auv, 'altitude_safety', return_value=0.0)

    auv._current_waypoint['x'] = auv_waypoint[0]
    auv._current_waypoint['y'] = auv_waypoint[1]
    auv._current_waypoint['depth'] = auv_waypoint[2]
    assert auv.distance_to_waypoint() == 0.0

    auv._current_waypoint['x'] = auv_waypoint[0]
    auv._current_waypoint['y'] = auv_waypoint[1] + 5.0
    auv._current_waypoint['depth'] = auv_waypoint[2]
    assert auv.distance_to_waypoint() == 5.0

    auv._current_waypoint['x'] = auv_waypoint[0]
    auv._current_waypoint['y'] = auv_waypoint[1]
    auv._current_waypoint['depth'] = auv_waypoint[2] + 5.0
    assert auv.distance_to_waypoint() == 0.0
示例#7
0
Test the methods:

    wait_to_start
    enable_steering
    plume_detected
    surface

"""

import logging
from time import sleep

from auv_bonus_xprize.settings import config
from auv.auv import Auv

auv = Auv()

while not auv.auv_control.connected:
    print('Waiting to connect')
    sleep(1.0)

logging.debug('wait_to_start() {0}'.format(
    config['starting']['auv_position_utm']))
while auv.wait_to_start():
    auv.plume_detected()
    sleep(10)

logging.debug('enable_steering()')
auv.enable_steering()

auv.plume_detected()
import logging
from time import sleep, time

from auv_bonus_xprize.settings import config
from auv_bonus_xprize.auv_main_loop import limit_reached
from auv.auv import Auv

waypts = list()
# start        750214.5,1987358.1
waypts.append((750214.5, 1987370.1, 4.0, 0))  # 12 m north
waypts.append((750189.5, 1987370.1, 4.0, 0))  # 25 m west, 12 m north
waypts.append((750189.5, 1987345.1, 4.0, 0))  # 25 m west, 13 m south
waypts.append((750214.5, 1987345.1, 4.0, 0))  # 13 m south
waypts.append((750214.5, 1987358.1, 4.0, 0))  #

auv = Auv()
auv.strobe('OFF')
auv.watchdog.stop()

while not auv.auv_control.connected:
    print('Waiting to connect')
    sleep(1.0)

PAUSE = float(config['starting']['start_delay_secs'])
logging.debug('Pausing for {0} seconds'.format(PAUSE))
sleep(PAUSE)

auv.watchdog.reset()
logging.debug('enable_steering()')
auv.enable_steering()
auv.plume_detected()