├── tests ├── __init__.py ├── context.py ├── test_basic.py ├── test_advanced.py └── test_DataHandler.py ├── MANIFEST.in ├── scripts ├── MissionPlan │ ├── TaskLog.txt │ ├── SwarmInfoLog.txt │ ├── TaskManagerLog.txt │ ├── TaskAllocationLog.txt │ ├── Stage_1_Attack.txt │ ├── Stage_1_Return.txt │ └── Stage_3_Attack.txt ├── __init__.py ├── Task.pyc ├── _lapjv.so ├── app_rc.pyc ├── output.pyc ├── img │ ├── Capture.bmp │ ├── capure.png │ ├── baesystems_logo.png │ ├── cranfield_logo.png │ ├── Cranfield_Logo_2.png │ ├── competition.area.png │ ├── GUI_MISSION_OVERVIEW.png │ └── GUI_Mission_Overview.png ├── __pycache__ │ ├── Task.cpython-36.pyc │ ├── StageOne.cpython-36.pyc │ ├── EnemyStatus.cpython-36.pyc │ ├── StageThree.cpython-36.pyc │ ├── FriendStatus.cpython-36.pyc │ ├── MissionStateMachine.cpython-36.pyc │ ├── StageOneStateMachine.cpython-36.pyc │ └── StageThreeStateMachine.cpython-36.pyc ├── app.qrc ├── TaskStatusInfo.py ├── EnemyStatus.py ├── MissionStateMachine.py ├── Agent.py ├── FriendStatus.py ├── StageOneStateMachine.py ├── publisher.py ├── StageThreeStateMachine.py ├── lapjv.h ├── Enemy.py ├── Task.py ├── FrameConvertor.py ├── _lapjv.pyx ├── GUI.py └── StageThree.py ├── Include ├── lap-master │ ├── lap │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── cost_eps.csv.gz │ │ │ ├── test_arr_loop.py │ │ │ └── test_utils.py │ │ ├── .gitignore │ │ ├── __init__.pyc │ │ ├── __init__.py │ │ ├── lapjv.h │ │ └── _lapjv.pyx │ ├── .gitignore │ ├── tools │ │ ├── travis.sh │ │ ├── build_versions.py │ │ ├── travis_section_def.sh │ │ ├── header.py │ │ └── travis_before_install.sh │ ├── MANIFEST.in │ ├── bench │ │ ├── bench.sh │ │ ├── matrix_nnz.py │ │ ├── overview_sparse.py │ │ ├── overview_dense.py │ │ ├── matrix_dense_hard.py │ │ └── matrix_sparse.py │ ├── RELEASING.md │ ├── .travis.yml │ ├── LICENSE │ ├── appveyor.yml │ ├── README.md │ └── setup.py ├── munkres-1.0.12.dist-info │ ├── INSTALLER │ ├── top_level.txt │ ├── munkres.pyc │ ├── WHEEL │ ├── RECORD │ ├── metadata.json │ └── README.md └── python-statemachine │ ├── tests │ ├── __init__.py │ ├── test_callable_instance.py │ ├── test_mixins.py │ ├── test_registry.py │ ├── test_state_callbacks.py │ ├── conftest.py │ ├── test_transitions.py │ └── test_multiple_destinations.py │ ├── docs │ ├── authors.rst │ ├── history.rst │ ├── readme.rst │ ├── contributing.rst │ ├── usage.rst │ ├── index.rst │ ├── installation.rst │ ├── Makefile │ └── make.bat │ ├── python_statemachine.egg-info │ ├── not-zip-safe │ ├── dependency_links.txt │ ├── top_level.txt │ └── SOURCES.txt │ ├── statemachine │ ├── utils.py │ ├── __init__.py │ ├── mixins.py │ ├── registry.py │ └── exceptions.py │ ├── MANIFEST.in │ ├── setup.cfg │ ├── AUTHORS.rst │ ├── LICENSE │ ├── setup.py │ ├── HISTORY.rst │ ├── CONTRIBUTING.rst │ └── README.rst ├── msg ├── SwarmInfo.msg ├── RewardMessage.msg ├── TaskStatusMessage.msg ├── TargetInformation.msg ├── InitMessage.msg ├── SystemStatusMessage.msg ├── Detection.msg ├── EnemyInfo.msg ├── SwarmInformation.msg ├── TaskMessage.msg ├── AgentInfo.msg └── TaskStatusInformation.msg ├── requirements.txt ├── Makefile ├── img ├── .directory ├── capure.png ├── Capture.bmp ├── Cranfield_Logo_2.png ├── System_Overview.png ├── baesystems_logo.png ├── cranfield_logo.png ├── Statemachine_main.png └── GUI_MISSION_OVERVIEW.png ├── docs ├── index.rst ├── make.bat ├── Makefile └── conf.py ├── package.xml ├── README.md └── CMakeLists.txt /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | -------------------------------------------------------------------------------- /scripts/MissionPlan/TaskLog.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/MissionPlan/SwarmInfoLog.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/MissionPlan/TaskManagerLog.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Include/lap-master/lap/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/MissionPlan/TaskAllocationLog.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | #from Main import main -------------------------------------------------------------------------------- /Include/lap-master/lap/.gitignore: -------------------------------------------------------------------------------- 1 | _lapjv.cpp 2 | -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | munkres 2 | -------------------------------------------------------------------------------- /msg/SwarmInfo.msg: -------------------------------------------------------------------------------- 1 | AgentInfo[] friendlies 2 | EnemyInfo[] enemies 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | python-statemachine 2 | lap 3 | munkres==1.0.12 4 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /Include/python-statemachine/python_statemachine.egg-info/not-zip-safe: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /msg/RewardMessage.msg: -------------------------------------------------------------------------------- 1 | uint8 agentIdx 2 | int8 TaskType 3 | bool newReward 4 | -------------------------------------------------------------------------------- /Include/python-statemachine/python_statemachine.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /msg/TaskStatusMessage.msg: -------------------------------------------------------------------------------- 1 | uint8 agentIdx 2 | int8 TaskType 3 | bool TaskStatus 4 | -------------------------------------------------------------------------------- /Include/lap-master/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | build 3 | python_lapjv.egg-info 4 | MANIFEST 5 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /Include/python-statemachine/python_statemachine.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | statemachine 2 | -------------------------------------------------------------------------------- /msg/TargetInformation.msg: -------------------------------------------------------------------------------- 1 | uint8[] fooId 2 | int8[3] fooPos 3 | int8[] fooTimestamp 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | init: 2 | pip2 install -r requirements.txt 3 | 4 | test: 5 | nosetests tests 6 | -------------------------------------------------------------------------------- /msg/InitMessage.msg: -------------------------------------------------------------------------------- 1 | uint8 agentId 2 | float64[3] homeLocation 3 | float64 nominalHeading 4 | -------------------------------------------------------------------------------- /msg/SystemStatusMessage.msg: -------------------------------------------------------------------------------- 1 | uint8 agentIdx 2 | int8 TaskType 3 | bool systemWorkingStatus 4 | -------------------------------------------------------------------------------- /img/.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | PreviewsShown=true 3 | Timestamp=2019,4,1,17,44,37 4 | Version=4 5 | -------------------------------------------------------------------------------- /img/capure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/capure.png -------------------------------------------------------------------------------- /img/Capture.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/Capture.bmp -------------------------------------------------------------------------------- /scripts/Task.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/Task.pyc -------------------------------------------------------------------------------- /msg/Detection.msg: -------------------------------------------------------------------------------- 1 | uint8 detectionId 2 | float64[3] position 3 | float64 confidence 4 | float64 timestamp 5 | -------------------------------------------------------------------------------- /scripts/_lapjv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/_lapjv.so -------------------------------------------------------------------------------- /scripts/app_rc.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/app_rc.pyc -------------------------------------------------------------------------------- /scripts/output.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/output.pyc -------------------------------------------------------------------------------- /img/Cranfield_Logo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/Cranfield_Logo_2.png -------------------------------------------------------------------------------- /img/System_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/System_Overview.png -------------------------------------------------------------------------------- /img/baesystems_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/baesystems_logo.png -------------------------------------------------------------------------------- /img/cranfield_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/cranfield_logo.png -------------------------------------------------------------------------------- /msg/EnemyInfo.msg: -------------------------------------------------------------------------------- 1 | uint8 agentId 2 | float64 confidence 3 | float64[3] agentPosition 4 | float64[3] agentVelocity 5 | -------------------------------------------------------------------------------- /scripts/img/Capture.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/Capture.bmp -------------------------------------------------------------------------------- /scripts/img/capure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/capure.png -------------------------------------------------------------------------------- /img/Statemachine_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/Statemachine_main.png -------------------------------------------------------------------------------- /img/GUI_MISSION_OVERVIEW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/img/GUI_MISSION_OVERVIEW.png -------------------------------------------------------------------------------- /scripts/img/baesystems_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/baesystems_logo.png -------------------------------------------------------------------------------- /scripts/img/cranfield_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/cranfield_logo.png -------------------------------------------------------------------------------- /scripts/img/Cranfield_Logo_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/Cranfield_Logo_2.png -------------------------------------------------------------------------------- /scripts/img/competition.area.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/competition.area.png -------------------------------------------------------------------------------- /Include/lap-master/lap/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/Include/lap-master/lap/__init__.pyc -------------------------------------------------------------------------------- /scripts/img/GUI_MISSION_OVERVIEW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/GUI_MISSION_OVERVIEW.png -------------------------------------------------------------------------------- /scripts/img/GUI_Mission_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/img/GUI_Mission_Overview.png -------------------------------------------------------------------------------- /msg/SwarmInformation.msg: -------------------------------------------------------------------------------- 1 | uint8[] friendlyId 2 | int8[] friendlyStatus 3 | int8[3] friendlyPos 4 | int8[] friendlyBatt 5 | float64[] timestamp 6 | -------------------------------------------------------------------------------- /msg/TaskMessage.msg: -------------------------------------------------------------------------------- 1 | uint8 agentId 2 | uint8 taskId 3 | uint8 targetId 4 | float64[3] taskLocation 5 | float64 taskDeadline 6 | float64 timestamp 7 | -------------------------------------------------------------------------------- /scripts/__pycache__/Task.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/Task.cpython-36.pyc -------------------------------------------------------------------------------- /Include/lap-master/tools/travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | section test 5 | python -m pytest $TEST_ARGS lap 6 | section_end test 7 | -------------------------------------------------------------------------------- /Include/lap-master/lap/tests/cost_eps.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/Include/lap-master/lap/tests/cost_eps.csv.gz -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/munkres.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/Include/munkres-1.0.12.dist-info/munkres.pyc -------------------------------------------------------------------------------- /Include/python-statemachine/docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use Python State Machine in a project:: 6 | 7 | import statemachine 8 | -------------------------------------------------------------------------------- /scripts/__pycache__/StageOne.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/StageOne.cpython-36.pyc -------------------------------------------------------------------------------- /scripts/__pycache__/EnemyStatus.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/EnemyStatus.cpython-36.pyc -------------------------------------------------------------------------------- /scripts/__pycache__/StageThree.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/StageThree.cpython-36.pyc -------------------------------------------------------------------------------- /scripts/__pycache__/FriendStatus.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/FriendStatus.cpython-36.pyc -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.29.0) 3 | Root-Is-Purelib: true 4 | Tag: py2-none-any 5 | Tag: py3-none-any 6 | 7 | -------------------------------------------------------------------------------- /scripts/__pycache__/MissionStateMachine.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/MissionStateMachine.cpython-36.pyc -------------------------------------------------------------------------------- /scripts/__pycache__/StageOneStateMachine.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/StageOneStateMachine.cpython-36.pyc -------------------------------------------------------------------------------- /scripts/__pycache__/StageThreeStateMachine.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohannesAutenrieb/mission_planning/HEAD/scripts/__pycache__/StageThreeStateMachine.cpython-36.pyc -------------------------------------------------------------------------------- /tests/context.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import sys 4 | import os 5 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 6 | 7 | import sample 8 | -------------------------------------------------------------------------------- /scripts/MissionPlan/Stage_1_Attack.txt: -------------------------------------------------------------------------------- 1 | 1;2;3; 2 | 4;5;6; 3 | 1;2;3; 4 | 1;2;3; 5 | 1;2;3; 6 | 1;2;3; 7 | 1;2;3; 8 | 1;2;3; 9 | 1;2;3; 10 | 1;2;3; 11 | 1;2;3; 12 | 1;2;3; 13 | 1;2;3; 14 | -------------------------------------------------------------------------------- /scripts/MissionPlan/Stage_1_Return.txt: -------------------------------------------------------------------------------- 1 | 1;2;3; 2 | 4;5;6; 3 | 1;2;3; 4 | 1;2;3; 5 | 1;2;3; 6 | 1;2;3; 7 | 1;2;3; 8 | 1;2;3; 9 | 1;2;3; 10 | 1;2;3; 11 | 1;2;3; 12 | 1;2;3; 13 | 1;2;3; 14 | -------------------------------------------------------------------------------- /scripts/MissionPlan/Stage_3_Attack.txt: -------------------------------------------------------------------------------- 1 | 1;2;3; 2 | 4;5;6; 3 | 1;2;3; 4 | 1;2;3; 5 | 1;2;3; 6 | 1;2;3; 7 | 1;2;3; 8 | 1;2;3; 9 | 1;2;3; 10 | 1;2;3; 11 | 1;2;3; 12 | 1;2;3; 13 | 1;2;3; 14 | -------------------------------------------------------------------------------- /msg/AgentInfo.msg: -------------------------------------------------------------------------------- 1 | uint8 agentId 2 | float64[3] agentPosition 3 | float64 agentHeading 4 | float64 agentBattery 5 | bool agentPayload 6 | bool agentTaskStatus 7 | uint8 agentTaskId 8 | bool agentWorkingStatus 9 | float64 taskDeadline 10 | -------------------------------------------------------------------------------- /Include/lap-master/tools/build_versions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | import numpy as np 6 | import Cython 7 | 8 | for m in (np, Cython): 9 | version = m.__version__ 10 | print(m.__name__.rjust(10), ' ', version) 11 | -------------------------------------------------------------------------------- /Include/python-statemachine/statemachine/utils.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | 5 | try: 6 | from django.utils.translation import ugettext 7 | except Exception: 8 | def ugettext(text): 9 | return text 10 | -------------------------------------------------------------------------------- /Include/lap-master/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include README.md 3 | include setup.cfg 4 | include setup.py 5 | include LICENSE 6 | recursive-include lap *.pyx *.pxd *.pxi *.py *.c *.cpp *.h *.md 7 | include lap/tests/*.gz 8 | global-exclude *~ 9 | global-exclude *.pyc 10 | -------------------------------------------------------------------------------- /msg/TaskStatusInformation.msg: -------------------------------------------------------------------------------- 1 | float64 lastUpdate 2 | int8 taskType 3 | uint8 agentId 4 | bool systemWorkingStatus 5 | int8[3] initialPostion 6 | int8[3] currentPostion 7 | int8[3] wayPoint 8 | float64 lastReward 9 | float64 taskDeadline 10 | float64 timestampOfTask 11 | uint8 targetId 12 | -------------------------------------------------------------------------------- /Include/lap-master/tools/travis_section_def.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | section () { 4 | echo -en "travis_fold:start:$1\r" 5 | tools/header.py $1 6 | } 7 | 8 | section_end () { 9 | echo -en "travis_fold:end:$1\r" 10 | } 11 | 12 | export -f section 13 | export -f section_end 14 | -------------------------------------------------------------------------------- /tests/test_basic.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .context import sample 4 | 5 | import unittest 6 | 7 | 8 | class BasicTestSuite(unittest.TestCase): 9 | """Basic test cases.""" 10 | 11 | def test_absolute_truth_and_meaning(self): 12 | assert True 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() -------------------------------------------------------------------------------- /Include/python-statemachine/MANIFEST.in: -------------------------------------------------------------------------------- 1 | 2 | include AUTHORS.rst 3 | 4 | include CONTRIBUTING.rst 5 | include HISTORY.rst 6 | include LICENSE 7 | include README.rst 8 | 9 | recursive-include tests * 10 | recursive-exclude * __pycache__ 11 | recursive-exclude * *.py[co] 12 | 13 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 14 | -------------------------------------------------------------------------------- /tests/test_advanced.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .context import sample 4 | 5 | import unittest 6 | 7 | 8 | class AdvancedTestSuite(unittest.TestCase): 9 | """Advanced test cases.""" 10 | 11 | def test_thoughts(self): 12 | self.assertIsNone(sample.hmm()) 13 | 14 | 15 | if __name__ == '__main__': 16 | unittest.main() 17 | -------------------------------------------------------------------------------- /Include/python-statemachine/statemachine/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals, absolute_import 3 | from .statemachine import StateMachine, State, Transition 4 | 5 | __author__ = """Fernando Macedo""" 6 | __email__ = 'fgmacedo@gmail.com' 7 | __version__ = '0.7.1' 8 | 9 | __all__ = ['StateMachine', 'State', 'Transition'] 10 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/index.rst: -------------------------------------------------------------------------------- 1 | Python State Machine 2 | ==================== 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | readme 10 | installation 11 | usage 12 | contributing 13 | authors 14 | history 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /Include/lap-master/tools/header.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | import sys 5 | 6 | screen_width = 50 7 | 8 | print('*' * screen_width) 9 | 10 | if len(sys.argv) > 1: 11 | header = ' '.join(sys.argv[1:]) 12 | header = header.replace('.', ' ') 13 | print('*', header.center(screen_width - 4), '*') 14 | print('*' * screen_width) 15 | -------------------------------------------------------------------------------- /scripts/app.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | img/Cranfield_Logo_2.png 5 | img/capure.png 6 | img/baesystems_logo.png 7 | 8 | 9 | img/competition.area.png 10 | img/Capture.bmp 11 | 12 | 13 | img/cranfield_logo.png 14 | 15 | 16 | -------------------------------------------------------------------------------- /Include/python-statemachine/setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.7.1 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | [bumpversion:file:statemachine/__init__.py] 11 | search = __version__ = '{current_version}' 12 | replace = __version__ = '{new_version}' 13 | 14 | [bdist_wheel] 15 | universal = 1 16 | 17 | [flake8] 18 | exclude = docs 19 | 20 | [egg_info] 21 | tag_build = 22 | tag_date = 0 23 | 24 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. sample documentation master file, created by 2 | sphinx-quickstart on Mon Apr 16 21:22:43 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to sample's documentation! 7 | ================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | 23 | -------------------------------------------------------------------------------- /Include/python-statemachine/AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * Fernando Macedo 9 | 10 | Contributors 11 | ------------ 12 | 13 | * Guilherme Nepomuceno 14 | 15 | 16 | Credits 17 | ------- 18 | 19 | This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. 20 | 21 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 22 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 23 | 24 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_callable_instance.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | import mock 5 | 6 | from statemachine.statemachine import CallableInstance 7 | 8 | 9 | def test_callable_should_override_kwargs(): 10 | target = mock.MagicMock(wil_be_overrided=1, will_be_proxied=2, z='text') 11 | proxy = CallableInstance(target, func=target.a_func, wil_be_overrided=3) 12 | 13 | assert proxy.wil_be_overrided == 3 14 | assert proxy.will_be_proxied == 2 15 | assert proxy.z == 'text' 16 | 17 | proxy(4, 5, k=6) 18 | 19 | target.a_func.assert_called_once_with(4, 5, k=6) 20 | -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | munkres.py,sha256=SbsDAxV-HGp8yI59YKSNqiZFUA8oMPScbm2wBS3lhms,27084 2 | munkres-1.0.12.dist-info/DESCRIPTION.rst,sha256=12R6FjY740YqW2jtzMpxuU3oP0oL1xA4SacinIwXQWk,8960 3 | munkres-1.0.12.dist-info/METADATA,sha256=9EgbnfV21FxFdcoGAbZh4FrwH4tGQyAdmtngdV4eC8s,9597 4 | munkres-1.0.12.dist-info/RECORD,, 5 | munkres-1.0.12.dist-info/WHEEL,sha256=o2k-Qa-RMNIJmUdIc7KU6VWR_ErNRbWNlxDIpl7lm34,110 6 | munkres-1.0.12.dist-info/metadata.json,sha256=b0Fvb9Pw0zNagMa5eE1OCSfzrZPHmmK4MD8nrR9jTTs,777 7 | munkres-1.0.12.dist-info/top_level.txt,sha256=nI3gH8MrXgul6rjrz7mx2htqkqjts-CcL3cQwCm8mN4,8 8 | munkres-1.0.12.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 9 | munkres.pyc,, 10 | -------------------------------------------------------------------------------- /scripts/TaskStatusInfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | import datetime 4 | 5 | class TaskStatusInfo(): 6 | 7 | def __init__(self, taskType, agentId, targetId, initialPosition, currentPosition, wayPoint, taskDeadline, timestamp): 8 | 9 | 10 | self.taskType = taskType 11 | self.agentId = agentId 12 | self.targetId = targetId 13 | self.agentTaskStatus = False 14 | self.systemWorkingStatus = True 15 | self.initialPosition = initialPosition 16 | self.currentPosition = currentPosition 17 | self.wayPoint = wayPoint 18 | self.lastReward = 0 19 | self.taskDeadline = taskDeadline 20 | self.timestampOfTask = timestamp 21 | 22 | -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/metadata.json: -------------------------------------------------------------------------------- 1 | {"classifiers": ["Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Software Development :: Libraries :: Python Modules"], "extensions": {"python.details": {"contacts": [{"email": "bmc@clapper.org", "name": "Brian Clapper", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "http://software.clapper.org/munkres/"}}}, "generator": "bdist_wheel (0.29.0)", "license": "Apache Software License", "metadata_version": "2.0", "name": "munkres", "summary": "munkres algorithm for the Assignment Problem", "version": "1.0.12"} -------------------------------------------------------------------------------- /Include/lap-master/bench/bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export PYTHONPATH=$LAPJV_OLD:$PYTHONPATH 4 | 5 | PYTEST_OPTS="-v -s --benchmark-sort=mean --benchmark-columns=mean,min,max,median,rounds,iterations" 6 | 7 | if [ ! -e matrix_dense_hard.json ]; then 8 | pytest $PYTEST_OPTS --benchmark-json=matrix_dense_hard.json matrix_dense_hard.py 9 | fi 10 | if [ ! -e matrix_sparse.json ]; then 11 | pytest $PYTEST_OPTS --benchmark-json=matrix_sparse.json matrix_sparse.py 12 | fi 13 | if [ ! -e matrix_nnz.json ]; then 14 | pytest $PYTEST_OPTS --benchmark-json=matrix_nnz.json matrix_nnz.py 15 | fi 16 | if [ ! -e overview_dense.json ]; then 17 | pytest $PYTEST_OPTS --benchmark-json=overview_dense.json overview_dense.py 18 | fi 19 | if [ ! -e overview_sparse.json ]; then 20 | pytest $PYTEST_OPTS --benchmark-json=overview_sparse.json overview_sparse.py 21 | fi 22 | -------------------------------------------------------------------------------- /Include/lap-master/RELEASING.md: -------------------------------------------------------------------------------- 1 | 1. Set version in lap/__init__.py to X.Y.Z 2 | 2. Create a source distribution: 3 | 4 | python setup.py sdist 5 | 6 | 3. Upload it to the test server (this requires setting up ~/.pypirc): 7 | 8 | twine upload --repository testpypi dist/* 9 | 10 | 4. Check install from test pypi into a venv: 11 | 12 | virtualenv test 13 | . test/bin/activate 14 | pip install numpy 15 | pip install --index-url https://test.pypi.org/simple/ lap 16 | 17 | 5. Make sure stuff works there: 18 | 19 | pip install pytest 20 | pip install scipy 21 | pytest $VIRTUAL_ENV/lib/python*/site-packages/lap/ 22 | 23 | 6. Tag and release on github: 24 | 25 | git tag vX.Y.Z 26 | git push origin vX.Y.Z 27 | 28 | And follow https://help.github.com/articles/creating-releases/ 29 | 30 | 7. Finally, upload to the live pypi server: 31 | 32 | twine upload dist/* 33 | -------------------------------------------------------------------------------- /Include/lap-master/lap/__init__.py: -------------------------------------------------------------------------------- 1 | """LAP 2 | ``lap`` is a linear assignment problem solver using Jonker-Volgenant 3 | algorithm for dense (LAPJV) or sparse (LAPMOD) matrices. 4 | 5 | Functions 6 | --------- 7 | 8 | lapjv 9 | Find optimal (minimum-cost) assignment for a dense cost matrix. 10 | lapmod 11 | Find optimal (minimum-cost) assignment for a sparse cost matrix. 12 | """ 13 | 14 | import sys 15 | 16 | __version__ = '0.5dev' 17 | 18 | try: 19 | __LAP_SETUP__ 20 | except NameError: 21 | __LAP_SETUP__ = False 22 | if __LAP_SETUP__: 23 | sys.stderr.write('Partial import of lap during the build process.\n') 24 | else: 25 | from ._lapjv import ( 26 | lapjv, 27 | LARGE_ as LARGE, 28 | FP_1_ as FP_1, FP_2_ as FP_2, FP_DYNAMIC_ as FP_DYNAMIC) 29 | from .lapmod import lapmod 30 | __all__ = ['lapjv', 'lapmod', 'FP_1', 'FP_2', 'FP_DYNAMIC', 'LARGE'] 31 | -------------------------------------------------------------------------------- /scripts/EnemyStatus.py: -------------------------------------------------------------------------------- 1 | class EnemyStatus(): 2 | 3 | def __init__(self): 4 | # Define the input data containers for foos: 5 | self.fooId = [1,2,3,4] 6 | self.fooPos = [[14,15,19],[2,3,6],[25,22,23],[28,17,18]] 7 | self.targetConfidence = [(0.56), (0.5), (0.7), (0.8)] 8 | self.attackStatus = [True, False, True, False] 9 | self.fooTimestamp = [] 10 | 11 | def get_fooId(self): 12 | return self.fooId 13 | def get_fooPos(self): 14 | return self.fooPos 15 | def get_fooTimestamp(self): 16 | return self.fooTimestamp 17 | 18 | ## Clarify if erase or append() to list 19 | 20 | ## Maybe not usefull under python 21 | def set_fooId(self, fooId): 22 | self.fooId = fooId 23 | def set_agentIdx(self, agentIdx): 24 | self.fooPos = agentIdx 25 | def set_fooTimestamp(self, fooTimestamp): 26 | self.fooTimestamp = fooTimestamp 27 | -------------------------------------------------------------------------------- /Include/python-statemachine/statemachine/mixins.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import unicode_literals, absolute_import 3 | 4 | try: 5 | from django.utils.translation import ugettext as _ 6 | except Exception: 7 | def _(text): 8 | return text 9 | from . import registry 10 | 11 | 12 | class MachineMixin(object): 13 | state_field_name = 'state' 14 | state_machine_name = None 15 | state_machine_attr = 'statemachine' 16 | 17 | def __init__(self, *args, **kwargs): 18 | super(MachineMixin, self).__init__(*args, **kwargs) 19 | if not self.state_machine_name: 20 | raise ValueError(_("{!r} is not a valid state machine name.").format( 21 | self.state_machine_name)) 22 | machine_cls = registry.get_machine_cls(self.state_machine_name) 23 | setattr( 24 | self, 25 | self.state_machine_attr, 26 | machine_cls(self, state_field=self.state_field_name) 27 | ) 28 | -------------------------------------------------------------------------------- /tests/test_DataHandler.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | from src import DataHandler 3 | import time 4 | 5 | 6 | class DataHandlerTest(TestCase): 7 | 8 | def setUp(self): 9 | self.handler = DataHandler() 10 | 11 | def test_get_foo_data(self): 12 | 13 | fooPackage = [] 14 | 15 | fooPackage.append([1, [52.06922871, -0.62585592, 5.02500000], time.time()]) 16 | fooPackage.append([2, [52.06904404, -0.62584519, 4.19575000], time.time()]) 17 | fooPackage.append([3, [52.06879343, -0.62585592, 52.06879343], time.time()]) 18 | 19 | # Verify if lists are created properly 20 | self.handler.get_foo_data(fooPackage) 21 | self.assertListEqual([1, 2, 3], self.handler.fooId) 22 | self.assertListEqual([[52.06922871, -0.62585592, 5.02500000], [52.06904404, -0.62584519, 4.19575000], 23 | [52.06879343, -0.62585592, 52.06879343]], self.handler.fooPos) 24 | self.assertListEqual(fooPackage[0][2], self.handler.fooTimestamp) -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_mixins.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | import pytest 4 | from statemachine.mixins import MachineMixin 5 | 6 | 7 | class MyModel(MachineMixin): 8 | state_machine_name = 'CampaignMachine' 9 | 10 | def __init__(self, **kwargs): 11 | for k, v in kwargs.items(): 12 | setattr(self, k, v) 13 | super(MyModel, self).__init__() 14 | 15 | def __repr__(self): 16 | return "{}({!r})".format(type(self).__name__, self.__dict__) 17 | 18 | 19 | def test_mixin_should_instantiate_a_machine(campaign_machine): 20 | model = MyModel(state='draft') 21 | assert isinstance(model.statemachine, campaign_machine) 22 | assert model.state == 'draft' 23 | assert model.statemachine.current_state == model.statemachine.draft 24 | 25 | 26 | def test_mixin_should_raise_exception_if_machine_class_does_not_exist(): 27 | class MyModelWithoutMachineName(MachineMixin): 28 | pass 29 | with pytest.raises(ValueError): 30 | MyModelWithoutMachineName() 31 | -------------------------------------------------------------------------------- /Include/python-statemachine/python_statemachine.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | AUTHORS.rst 2 | CONTRIBUTING.rst 3 | HISTORY.rst 4 | LICENSE 5 | MANIFEST.in 6 | README.rst 7 | setup.cfg 8 | setup.py 9 | docs/Makefile 10 | docs/authors.rst 11 | docs/conf.py 12 | docs/contributing.rst 13 | docs/history.rst 14 | docs/index.rst 15 | docs/installation.rst 16 | docs/make.bat 17 | docs/readme.rst 18 | docs/usage.rst 19 | python_statemachine.egg-info/PKG-INFO 20 | python_statemachine.egg-info/SOURCES.txt 21 | python_statemachine.egg-info/dependency_links.txt 22 | python_statemachine.egg-info/not-zip-safe 23 | python_statemachine.egg-info/top_level.txt 24 | statemachine/__init__.py 25 | statemachine/exceptions.py 26 | statemachine/mixins.py 27 | statemachine/registry.py 28 | statemachine/statemachine.py 29 | statemachine/utils.py 30 | tests/__init__.py 31 | tests/conftest.py 32 | tests/test_callable_instance.py 33 | tests/test_mixins.py 34 | tests/test_multiple_destinations.py 35 | tests/test_registry.py 36 | tests/test_state_callbacks.py 37 | tests/test_statemachine.py 38 | tests/test_transitions.py -------------------------------------------------------------------------------- /Include/python-statemachine/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2017, Fernando Macedo 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | 12 | -------------------------------------------------------------------------------- /Include/lap-master/tools/travis_before_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | export PIP_DEFAULT_TIMEOUT=60 5 | 6 | export TEST_ARGS="-v" 7 | 8 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 9 | section setup_osx_venv 10 | git clone https://github.com/matthew-brett/multibuild ~/multibuild 11 | source ~/multibuild/osx_utils.sh 12 | get_macpython_environment $TRAVIS_PYTHON_VERSION ~/venv 13 | section_end setup_osx_venv 14 | else 15 | section setup_linux_venv 16 | python -m pip install -U pip 17 | HAVE_VENV=$( 18 | python <<-EOL 19 | try: 20 | import venv 21 | print('1') 22 | except ImportError: 23 | pass 24 | EOL 25 | ) 26 | if [ "$HAVE_VENV" ]; then 27 | python -m venv ~/venv 28 | else 29 | python -m pip install -U virtualenv 30 | virtualenv -p python ~/venv 31 | fi 32 | section_end setup_linux_venv 33 | fi 34 | 35 | section install_requirements 36 | source ~/venv/bin/activate 37 | python -m pip install -U pip 38 | python -m pip install --retries 3 wheel 39 | python -m pip install --retries 3 pytest pytest-timeout cython numpy scipy 40 | python -m pip list 41 | section_end install_requirements 42 | 43 | set +ex 44 | -------------------------------------------------------------------------------- /Include/lap-master/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: true # required until https://github.com/travis-ci/travis-ci/issues/9069 gets resolved 2 | dist: xenial 3 | language: python 4 | python: 5 | - "2.7" 6 | - "3.6" 7 | - "3.7" 8 | matrix: 9 | include: 10 | - os: linux 11 | python: 2.7 12 | - os: linux 13 | python: 3.6 14 | - os: linux 15 | python: 3.7 16 | - os: osx 17 | osx_image: xcode7.3 18 | language: objective-c 19 | env: TRAVIS_PYTHON_VERSION=2.7 20 | - os: osx 21 | osx_image: xcode7.3 22 | language: objective-c 23 | env: TRAVIS_PYTHON_VERSION=3.6 24 | - os: osx 25 | osx_image: xcode7.3 26 | language: objective-c 27 | env: TRAVIS_PYTHON_VERSION=3.7 28 | before_install: 29 | - df -h 30 | - date 31 | - pwd 32 | - uname -a 33 | - source tools/travis_section_def.sh 34 | - source tools/travis_before_install.sh 35 | - which python; python --version 36 | - tools/build_versions.py 37 | install: 38 | - section build 39 | - python setup.py clean 40 | - python setup.py build_ext -i 41 | - section_end build 42 | script: tools/travis.sh 43 | notifications: 44 | email: 45 | on_success: change 46 | on_failure: change 47 | -------------------------------------------------------------------------------- /scripts/MissionStateMachine.py: -------------------------------------------------------------------------------- 1 | from statemachine import StateMachine, State 2 | 3 | class MissionStateMachine(StateMachine): 4 | 5 | # Defined States in the Mission State Machine 6 | init = State('init', initial=True) 7 | stageOne = State('stageOne') 8 | stageTwo = State('stageTwo') 9 | stageThree = State('stageThree') 10 | 11 | # Defined Transitions 12 | initEnd = init.to(stageOne) 13 | triggerOne = stageOne.to(stageTwo) 14 | triggerTwo = stageTwo.to(stageThree) 15 | 16 | # Executed when entering stages 17 | def on_enter_stageOne(self): 18 | print(":::: STAGE ONE ENTERED :::: ") 19 | 20 | def on_enter_stageTwo(self): 21 | print(":::: STAGE TWO ENTERED :::: ") 22 | 23 | def on_enter_stageThree(self): 24 | print(":::: STAGE THREE ENTERED :::: ") 25 | 26 | # Executed when exiting stages 27 | def on_exit_stageOne(self): 28 | print("S1:Transition to Stage 2") 29 | 30 | def on_exit_stageTwo(self): 31 | print("S2:Transition to Stage 3") 32 | 33 | def on_exit_stageThree(self): 34 | print(":::: SYSTEM SHUTDOWN :::: ") 35 | 36 | # Class to manage the states better 37 | class MissionState(object): 38 | def __init__(self, state): 39 | self.state = state 40 | -------------------------------------------------------------------------------- /scripts/Agent.py: -------------------------------------------------------------------------------- 1 | 2 | class Agent(): 3 | 4 | # Defined States in the Mission State Machine 5 | def __init__(self,agentId, agentPos, agentHeading, taskID, taskStatus, agentBattery, agentPayload): 6 | """ 7 | =========================================================== 8 | Constructor to create initial relevant Objects and global 9 | Variables of Agent instance 10 | =========================================================== 11 | :Parameters: None 12 | The Agents object is represented by a set of parameters: 13 | - AgentID (uint32) 14 | - AgentPosition ([3] List of float64) 15 | - AgentVelocity ([3] List of float64) 16 | - AgentHeading (float64) 17 | - AgentBattery (float64) 18 | - AgentPayload (bool) 19 | :return: None 20 | =========================================================== 21 | """ 22 | self.agentId = agentId 23 | self.agentPos = agentPos 24 | self.agentHeading = agentHeading 25 | self.taskID = taskID 26 | self.taskStatus = taskStatus 27 | self.agentBattery = agentBattery 28 | self.agentPayload = agentPayload 29 | self.agentWorkingStatus = True 30 | self.lastReward = 0 31 | -------------------------------------------------------------------------------- /Include/lap-master/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2017, Tomas Kazmar 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /scripts/FriendStatus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | class FriendStatus(): 4 | 5 | friendlyId =[] 6 | 7 | def __init__(self): 8 | #Define the input data containers for foos: 9 | self.friendlyId = [1,2,3,4,5,6,7,8] 10 | self.friendlyWorkingStatus =[True,True,True,True,True,True,True,True] 11 | self.friendlyTaskStatus = [False, False, False, False, False, False, False, False] 12 | self.friendlyTaskId = [1,2,3,4,5,6,7,8] 13 | self.friendlyPos = [[5,6,7],[8,9,10],[11,12,13],[1,2,3],[5,6,7],[8,9,10],[11,12,13],[14,15,16]] 14 | self.friendlyHeading = [1,1,1,1,1,1,1,1] 15 | self.friendlyBatt = [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5] 16 | self.friendlyPayload = [True,True,True,True,True,True,True,True] 17 | #self.friendlyW = 0 18 | #self.friendlyTimestamp = 0 19 | 20 | def get_fooId(self): 21 | return self.fooId 22 | def get_fooPos(self): 23 | return self.fooPos 24 | def get_fooTimestamp(self): 25 | return self.fooTimestamp 26 | 27 | ## Clarify if erase or append() to list 28 | # setattr(x, 'attr_name', s) 29 | ## Maybe not usefull under python 30 | def set_fooId(self, fooId): 31 | self.fooId = fooId 32 | def set_agentIdx(self, agentIdx): 33 | self.fooPos = agentIdx 34 | def set_fooTimestamp(self, fooTimestamp): 35 | self.fooTimestamp = fooTimestamp 36 | -------------------------------------------------------------------------------- /scripts/StageOneStateMachine.py: -------------------------------------------------------------------------------- 1 | from statemachine import StateMachine, State 2 | 3 | class StageOneStateMachine(StateMachine): 4 | 5 | # Defined States in the Mission State Machine 6 | startMotor = State('startMotor', initial=True) 7 | hover = State('hover') 8 | goToAOI = State('goToAOI') 9 | hoverInAOI = State('hoverInAOI') 10 | 11 | # Defined Transitions 12 | reachedAlitude = startMotor.to(hover) 13 | hoverTimeReached = hover.to(goToAOI) 14 | BackInAOI = goToAOI.to(hoverInAOI) 15 | 16 | # Executed when entering stages 17 | def on_enter_startMotor(self): 18 | print("S1:: Start motor ::") 19 | 20 | def on_enter_hover(self): 21 | print("S1:: Initial hover ::") 22 | 23 | def on_enter_goToAOI(self): 24 | print("S1:: Go to AoI ::") 25 | 26 | def on_enter_hoverInAOI(self): 27 | print("S1:: Hover in AoI ::") 28 | 29 | # Executed when exiting stages 30 | def on_exit_startMotor(self): 31 | print("S1: All agents reached altitude") 32 | 33 | def on_exit_hover(self): 34 | print("S1: Initial hover timeout") 35 | 36 | def on_exit_goToAOI(self): 37 | print("S1: All agents in AoI") 38 | 39 | def on_exit_hoverInAOI(self): 40 | print("S1: We are ready to defend hour honor!") 41 | 42 | # Class to manage the states better 43 | class StageOneState(object): 44 | def __init__(self, state): 45 | self.state = state 46 | -------------------------------------------------------------------------------- /scripts/publisher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2.7 2 | import rospy 3 | from mission_planning.msg import AgentInfo, EnemyInfo, SwarmInfo 4 | 5 | 6 | def talker(): 7 | pub = rospy.Publisher('SwarmInformation', SwarmInfo, queue_size=10) 8 | rospy.init_node("Halko", anonymous=True) 9 | rate = rospy.Rate(10) # 10hz 10 | 11 | 12 | swarm = SwarmInfo() 13 | 14 | agentList = [] 15 | enemyList = [] 16 | 17 | for i in range(0, 6): 18 | agent = AgentInfo() 19 | 20 | agent.agentId = i + 1 21 | agent.agentWorkingStatus = True 22 | agent.agentPosition = [3 * i + 1, 3 * i + 2, 3 * i + 3] 23 | agent.agentHeading = 0 24 | agent.agentTaskId = i + 1 25 | agent.agentTaskStatus = False 26 | agent.agentBattery = 0.5 27 | agent.agentPayload = True 28 | 29 | agentList.append(agent) 30 | 31 | for i in range(0, 2): 32 | enemy = EnemyInfo() 33 | enemy.agentId = i + 1 34 | enemy.agentPosition = [8 * i + 1, 8 * i + 2, 8 * i + 3] 35 | enemy.agentVelocity = [ 2, 3, 4] 36 | enemy.confidence = 0.75 37 | 38 | enemyList.append(enemy) 39 | 40 | swarm.friendlies = agentList 41 | swarm.enemies = enemyList 42 | 43 | while not rospy.is_shutdown(): 44 | 45 | pub.publish(swarm) 46 | rate.sleep() 47 | 48 | if __name__ == '__main__': 49 | try: 50 | talker() 51 | except rospy.ROSInterruptException: 52 | pass 53 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install Python State Machine, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install python-statemachine 16 | 17 | This is the preferred method to install Python State Machine, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for Python State Machine can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/fgmacedo/python-statemachine 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/fgmacedo/python-statemachine/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/fgmacedo/python-statemachine 51 | .. _tarball: https://github.com/fgmacedo/python-statemachine/tarball/master 52 | -------------------------------------------------------------------------------- /Include/python-statemachine/statemachine/registry.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | _REGISTRY = {} 4 | _initialized = False 5 | 6 | 7 | def register(cls): 8 | _REGISTRY[cls.__name__] = cls 9 | return cls 10 | 11 | 12 | def get_machine_cls(name): 13 | init_registry() 14 | return _REGISTRY[name] 15 | 16 | 17 | def init_registry(): 18 | global _initialized 19 | if not _initialized: 20 | load_modules(['statemachine', 'statemachines']) 21 | _initialized = True 22 | 23 | 24 | def _has_django(): 25 | try: 26 | import django # noqa 27 | return True 28 | except ImportError: 29 | # Not a django project 30 | pass 31 | return False 32 | 33 | 34 | def _autodiscover_modules(module_name): # pragma: no cover 35 | "Django 1.6 compat to provide `autodiscover_modules`" 36 | from django.conf import settings 37 | from django.utils.importlib import import_module 38 | 39 | for app in settings.INSTALLED_APPS: 40 | # Attempt to import the app's `module_name`. 41 | try: 42 | import_module('{app}.{module}'.format(app=app, module=module_name)) 43 | except Exception: 44 | pass 45 | 46 | 47 | def load_modules(modules=None): 48 | if not _has_django(): 49 | return 50 | try: # pragma: no cover 51 | from django.utils.module_loading import autodiscover_modules 52 | except ImportError: # pragma: no cover 53 | autodiscover_modules = _autodiscover_modules 54 | 55 | for module in modules: 56 | autodiscover_modules(module) 57 | -------------------------------------------------------------------------------- /scripts/StageThreeStateMachine.py: -------------------------------------------------------------------------------- 1 | from statemachine import StateMachine, State 2 | 3 | class StageThreeStateMachine(StateMachine): 4 | 5 | # Defined States in the Mission State Machine 6 | hoverAtCurrentPosition = State('hoverAtCurrentPosition', initial=True) 7 | goToWaypoint = State('goToWaypoint') 8 | landInAOI = State('landInAOI') 9 | waitOnGround = State('waitOnGround') 10 | 11 | 12 | # Defined Transitions 13 | hoverTimeReached = hoverAtCurrentPosition.to(goToWaypoint) 14 | reachedAOI = goToWaypoint.to(landInAOI) 15 | touchedGround = landInAOI.to(waitOnGround) 16 | 17 | 18 | # Executed when entering stages 19 | def on_enter_hoverAtCurrentPosition(self): 20 | print("S3:: Hover at current position ::") 21 | 22 | def on_enter_goToWaypoint(self): 23 | print("S3:: Go hostile AoI ::") 24 | 25 | def on_enter_landInAOI(self): 26 | print("S3:: Land in AoI ::") 27 | 28 | def on_enter_waitOnGround(self): 29 | print("S3:: Wait on the ground ::") 30 | 31 | 32 | # Executed when exiting stages 33 | def on_exit_hoverAtCurrentPosition(self): 34 | print("S3: Hover timeout") 35 | 36 | def on_exit_goToWaypoint(self): 37 | print("S3: All agents at landing position") 38 | 39 | def on_exit_landInAOI(self): 40 | print("S3: All agents on the ground") 41 | 42 | def on_exit_waitOnGround(self): 43 | print("S3: Disarmed") 44 | 45 | 46 | # Class to manage the states better 47 | class StageThreeState(object): 48 | def __init__(self, state): 49 | self.state = state 50 | -------------------------------------------------------------------------------- /Include/munkres-1.0.12.dist-info/README.md: -------------------------------------------------------------------------------- 1 | Munkres implementation for Python 2 | --------------------------------- 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ## Introduction 12 | 13 | The Munkres module provides an O(n^3) implementation of the Munkres algorithm 14 | (also called the [Hungarian algorithm][] or the Kuhn-Munkres algorithm). 15 | The algorithm models an assignment problem as an NxM cost matrix, where 16 | each element represents the cost of assigning the ith worker to the jth 17 | job, and it figures out the least-cost solution, choosing a single item 18 | from each row and column in the matrix, such that no row and no column are 19 | used more than once. 20 | 21 | This particular implementation is based on 22 | . 23 | 24 | [Hungarian algorithm]: http://en.wikipedia.org/wiki/Hungarian_algorithm 25 | 26 | See the docs on the [project page][] for more details. 27 | 28 | **WARNING**: As of version 1.1.0, _munkres_ no longer supports Python 2. 29 | If you need to use this package with Python 2, install an earlier version. 30 | See [the installation instructions](http://software.clapper.org/munkres/#installing) 31 | for details. 32 | 33 | [project page]: http://software.clapper.org/munkres/ 34 | 35 | ## Copyright 36 | 37 | © 2008-2019 Brian M. Clapper 38 | 39 | ## License 40 | 41 | Licensed under the Apache License, Version 2.0. See 42 | [LICENSE](LICENSE.md) for details. 43 | -------------------------------------------------------------------------------- /Include/lap-master/bench/matrix_nnz.py: -------------------------------------------------------------------------------- 1 | from pytest import mark 2 | from joblib import Memory 3 | 4 | from lap import lapmod, FP_1, FP_2, FP_DYNAMIC 5 | from lap.tests.test_utils import get_nnz_int 6 | 7 | max_time_per_benchmark = 20 8 | 9 | szs = [5000] 10 | nnzs = [10, 100, 500, 1000, 1500, 2000, 3000, 4000] 11 | seeds = [1299821, 15485867, 32452867, 49979693] 12 | 13 | 14 | cachedir = '/tmp/lapjv-cache' 15 | memory = Memory(cachedir=cachedir, verbose=1) 16 | 17 | 18 | @memory.cache 19 | def get_data(sz, nnz, seed, rng=100): 20 | return get_nnz_int(sz, nnz, rng=rng, seed=seed) 21 | 22 | 23 | @mark.timeout(max_time_per_benchmark) 24 | @mark.parametrize('sz,nnz,seed', [ 25 | (sz, nnz, seed) for sz in szs for nnz in nnzs for seed in seeds]) 26 | def test_MOD_c_3(benchmark, sz, nnz, seed): 27 | cc, ii, kk = get_data(sz, nnz, seed) 28 | benchmark( 29 | lapmod, sz, cc, ii, kk, 30 | fast=True, return_cost=False, fp_version=FP_DYNAMIC) 31 | 32 | 33 | @mark.timeout(max_time_per_benchmark) 34 | @mark.parametrize('sz,nnz,seed', [ 35 | (sz, nnz, seed) for sz in szs for nnz in nnzs for seed in seeds]) 36 | def test_MOD_c_1(benchmark, sz, nnz, seed): 37 | cc, ii, kk = get_data(sz, nnz, seed) 38 | benchmark( 39 | lapmod, sz, cc, ii, kk, 40 | fast=True, return_cost=False, fp_version=FP_1) 41 | 42 | 43 | @mark.timeout(max_time_per_benchmark) 44 | @mark.parametrize('sz,nnz,seed', [ 45 | (sz, nnz, seed) for sz in szs for nnz in nnzs for seed in seeds]) 46 | def test_MOD_c_2(benchmark, sz, nnz, seed): 47 | cc, ii, kk = get_data(sz, nnz, seed) 48 | benchmark( 49 | lapmod, sz, cc, ii, kk, 50 | fast=True, return_cost=False, fp_version=FP_2) 51 | -------------------------------------------------------------------------------- /Include/python-statemachine/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | from __future__ import print_function 4 | 5 | from setuptools import setup 6 | 7 | with open('README.rst') as readme_file: 8 | readme = readme_file.read() 9 | 10 | with open('HISTORY.rst') as history_file: 11 | history = history_file.read() 12 | 13 | long_description = readme + '\n\n' + history 14 | 15 | 16 | requirements = [] 17 | 18 | test_requirements = [] 19 | 20 | setup( 21 | name='python-statemachine', 22 | version='0.7.1', 23 | description="Python Finite State Machines made easy.", 24 | long_description=long_description, 25 | author="Fernando Macedo", 26 | author_email='fgmacedo@gmail.com', 27 | url='https://github.com/fgmacedo/python-statemachine', 28 | packages=[ 29 | 'statemachine', 30 | ], 31 | package_dir={'statemachine': 32 | 'statemachine'}, 33 | include_package_data=True, 34 | install_requires=requirements, 35 | license="MIT license", 36 | zip_safe=False, 37 | keywords='statemachine', 38 | classifiers=[ 39 | 'Development Status :: 3 - Alpha', 40 | 'Intended Audience :: Developers', 41 | 'License :: OSI Approved :: MIT License', 42 | 'Natural Language :: English', 43 | "Programming Language :: Python :: 2", 44 | 'Programming Language :: Python :: 2.7', 45 | 'Programming Language :: Python :: 3', 46 | 'Programming Language :: Python :: 3.4', 47 | 'Programming Language :: Python :: 3.5', 48 | 'Programming Language :: Python :: 3.6', 49 | 'Topic :: Software Development :: Libraries', 50 | ], 51 | test_suite='tests', 52 | tests_require=test_requirements 53 | ) 54 | -------------------------------------------------------------------------------- /Include/lap-master/appveyor.yml: -------------------------------------------------------------------------------- 1 | # AppVeyor.com is a Continuous Integration service to build and run tests under 2 | # Windows 3 | # 4 | # Adapted from the skimage project (https://github.com/scikit-image/scikit-image) 5 | 6 | environment: 7 | matrix: 8 | - PYTHON: C:\Python27 9 | - PYTHON: C:\Python27-x64 10 | - PYTHON: C:\Python36 11 | - PYTHON: C:\Python36-x64 12 | - PYTHON: C:\Python37 13 | - PYTHON: C:\Python37-x64 14 | 15 | matrix: 16 | fast_finish: true 17 | 18 | install: 19 | - ECHO "Filesystem root:" 20 | - ps: "ls \"C:/\"" 21 | 22 | - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" 23 | - "python -m pip install -U pip" 24 | 25 | # Check that we have the expected version and architecture for Python 26 | - "python --version" 27 | - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" 28 | - "pip --version" 29 | 30 | # Install the build and runtime dependencies of the project. 31 | - pip install --retries 3 -q wheel pytest pytest-timeout cython numpy scipy 32 | - pip list 33 | - python setup.py bdist_wheel bdist_wininst 34 | - ps: "ls dist" 35 | 36 | # Install the generated wheel package to test it 37 | - "pip install --pre --no-index --find-links dist/ lap" 38 | 39 | # Not a .NET project, we build lap in the install step instead 40 | build: false 41 | 42 | test_script: 43 | # Change to a non-source folder to make sure we run the tests on the 44 | # installed library. 45 | - "cd C:\\" 46 | 47 | # Run unit tests with pytest 48 | - "python -c \"import pytest; import os; from lap.tests import __file__ as d; d = os.path.dirname(d); pytest.main([d])\"" 49 | 50 | artifacts: 51 | # Archive the generated wheel package in the ci.appveyor.com build report. 52 | - path: dist\* 53 | 54 | #on_success: 55 | # - TODO: upload the content of dist/*.whl to a public wheelhouse 56 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_registry.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | import mock 5 | import pytest 6 | 7 | 8 | def test_should_register_a_state_machine(): 9 | from statemachine import StateMachine, State, registry 10 | 11 | class CampaignMachine(StateMachine): 12 | "A workflow machine" 13 | draft = State('Draft', initial=True) 14 | producing = State('Being produced') 15 | 16 | add_job = draft.to(draft) | producing.to(producing) 17 | produce = draft.to(producing) 18 | 19 | assert 'CampaignMachine' in registry._REGISTRY 20 | assert registry.get_machine_cls('CampaignMachine') == CampaignMachine 21 | 22 | 23 | @pytest.fixture() 24 | def django_autodiscover_modules(): 25 | import sys 26 | 27 | real_django = sys.modules.get('django') 28 | 29 | django = mock.MagicMock() 30 | module_loading = mock.MagicMock() 31 | auto_discover_modules = module_loading.autodiscover_modules 32 | 33 | sys.modules['django'] = django 34 | sys.modules['django.utils.module_loading'] = module_loading 35 | 36 | with mock.patch('statemachine.registry._autodiscover_modules', new=auto_discover_modules): 37 | yield auto_discover_modules 38 | 39 | del sys.modules['django'] 40 | del sys.modules['django.utils.module_loading'] 41 | if real_django: 42 | sys.modules['django'] = real_django 43 | 44 | 45 | def test_load_modules_should_call_autodiscover_modules(django_autodiscover_modules): 46 | from statemachine.registry import load_modules 47 | 48 | # given 49 | modules = ['a', 'c', 'statemachine', 'statemachines'] 50 | 51 | # when 52 | load_modules(modules) 53 | 54 | # then 55 | django_autodiscover_modules.assert_has_calls( 56 | mock.call(m) for m in modules 57 | ) 58 | -------------------------------------------------------------------------------- /Include/python-statemachine/HISTORY.rst: -------------------------------------------------------------------------------- 1 | History 2 | ======= 3 | 4 | 0.7.1 (2019-01-18) 5 | ------------------ 6 | 7 | * Fix Django integration for registry loading statemachine modules on Django1.7+. 8 | 9 | 10 | 0.7.0 (2018-04-01) 11 | ------------------ 12 | 13 | * New event callbacks: `on_enter_` and `on_exit_`. 14 | 15 | 0.6.2 (2017-08-25) 16 | ------------------ 17 | 18 | * Fix README. 19 | 20 | 21 | 0.6.1 (2017-08-25) 22 | ------------------ 23 | 24 | * Fix deploy issues. 25 | 26 | 27 | 0.6.0 (2017-08-25) 28 | ------------------ 29 | 30 | * Auto-discovering `statemachine`/`statemachines` under a Django project when 31 | they are requested using the mixin/registry feature. 32 | 33 | 0.5.1 (2017-07-24) 34 | ------------------ 35 | 36 | * Fix bug on ``CombinedTransition._can_run`` not allowing transitions to run if there are more than 37 | two transitions combined. 38 | 39 | 0.5.0 (2017-07-13) 40 | ------------------ 41 | 42 | * Custom exceptions. 43 | * Duplicated definition of ``on_execute`` callback is not allowed. 44 | * Fix bug on ``StateMachine.on_`` being called with extra ``self`` param. 45 | 46 | 0.4.2 (2017-07-10) 47 | ------------------ 48 | 49 | * Python 3.6 support. 50 | * Drop official support for Python 3.3. 51 | * `Transition` can be used as decorator for `on_execute` callback definition. 52 | * `Transition` can point to multiple destination states. 53 | 54 | 55 | 0.3.0 (2017-03-22) 56 | ------------------ 57 | 58 | * README getting started section. 59 | * Tests to state machine without model. 60 | 61 | 62 | 0.2.0 (2017-03-22) 63 | ------------------ 64 | 65 | * ``State`` can hold a value that will be assigned to the model as the state value. 66 | * Travis-CI integration. 67 | * RTD integration. 68 | 69 | 70 | 0.1.0 (2017-03-21) 71 | ------------------ 72 | 73 | * First release on PyPI. 74 | -------------------------------------------------------------------------------- /scripts/lapjv.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPJV_H 2 | #define LAPJV_H 3 | 4 | #define LARGE 1000000 5 | 6 | #if !defined TRUE 7 | #define TRUE 1 8 | #endif 9 | #if !defined FALSE 10 | #define FALSE 0 11 | #endif 12 | 13 | #define NEW(x, t, n) if ((x = (t *)malloc(sizeof(t) * (n))) == 0) { return -1; } 14 | #define FREE(x) if (x != 0) { free(x); x = 0; } 15 | #define SWAP_INDICES(a, b) { int_t _temp_index = a; a = b; b = _temp_index; } 16 | 17 | #if 0 18 | #include 19 | #define ASSERT(cond) assert(cond) 20 | #define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__) 21 | #define PRINT_COST_ARRAY(a, n) \ 22 | while (1) { \ 23 | printf(#a" = ["); \ 24 | if ((n) > 0) { \ 25 | printf("%f", (a)[0]); \ 26 | for (uint_t j = 1; j < n; j++) { \ 27 | printf(", %f", (a)[j]); \ 28 | } \ 29 | } \ 30 | printf("]\n"); \ 31 | break; \ 32 | } 33 | #define PRINT_INDEX_ARRAY(a, n) \ 34 | while (1) { \ 35 | printf(#a" = ["); \ 36 | if ((n) > 0) { \ 37 | printf("%d", (a)[0]); \ 38 | for (uint_t j = 1; j < n; j++) { \ 39 | printf(", %d", (a)[j]); \ 40 | } \ 41 | } \ 42 | printf("]\n"); \ 43 | break; \ 44 | } 45 | #else 46 | #define ASSERT(cond) 47 | #define PRINTF(fmt, ...) 48 | #define PRINT_COST_ARRAY(a, n) 49 | #define PRINT_INDEX_ARRAY(a, n) 50 | #endif 51 | 52 | 53 | typedef signed int int_t; 54 | typedef unsigned int uint_t; 55 | typedef double cost_t; 56 | typedef char boolean; 57 | typedef enum fp_t { FP_1 = 1, FP_2 = 2, FP_DYNAMIC = 3 } fp_t; 58 | 59 | extern int_t lapjv_internal( 60 | const uint_t n, cost_t *cost[], 61 | int_t *x, int_t *y); 62 | 63 | extern int_t lapmod_internal( 64 | const uint_t n, cost_t *cc, uint_t *ii, uint_t *kk, 65 | int_t *x, int_t *y, fp_t fp_version); 66 | 67 | #endif // LAPJV_H 68 | -------------------------------------------------------------------------------- /Include/lap-master/lap/lapjv.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPJV_H 2 | #define LAPJV_H 3 | 4 | #define LARGE 1000000 5 | 6 | #if !defined TRUE 7 | #define TRUE 1 8 | #endif 9 | #if !defined FALSE 10 | #define FALSE 0 11 | #endif 12 | 13 | #define NEW(x, t, n) if ((x = (t *)malloc(sizeof(t) * (n))) == 0) { return -1; } 14 | #define FREE(x) if (x != 0) { free(x); x = 0; } 15 | #define SWAP_INDICES(a, b) { int_t _temp_index = a; a = b; b = _temp_index; } 16 | 17 | #if 0 18 | #include 19 | #define ASSERT(cond) assert(cond) 20 | #define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__) 21 | #define PRINT_COST_ARRAY(a, n) \ 22 | while (1) { \ 23 | printf(#a" = ["); \ 24 | if ((n) > 0) { \ 25 | printf("%f", (a)[0]); \ 26 | for (uint_t j = 1; j < n; j++) { \ 27 | printf(", %f", (a)[j]); \ 28 | } \ 29 | } \ 30 | printf("]\n"); \ 31 | break; \ 32 | } 33 | #define PRINT_INDEX_ARRAY(a, n) \ 34 | while (1) { \ 35 | printf(#a" = ["); \ 36 | if ((n) > 0) { \ 37 | printf("%d", (a)[0]); \ 38 | for (uint_t j = 1; j < n; j++) { \ 39 | printf(", %d", (a)[j]); \ 40 | } \ 41 | } \ 42 | printf("]\n"); \ 43 | break; \ 44 | } 45 | #else 46 | #define ASSERT(cond) 47 | #define PRINTF(fmt, ...) 48 | #define PRINT_COST_ARRAY(a, n) 49 | #define PRINT_INDEX_ARRAY(a, n) 50 | #endif 51 | 52 | 53 | typedef signed int int_t; 54 | typedef unsigned int uint_t; 55 | typedef double cost_t; 56 | typedef char boolean; 57 | typedef enum fp_t { FP_1 = 1, FP_2 = 2, FP_DYNAMIC = 3 } fp_t; 58 | 59 | extern int_t lapjv_internal( 60 | const uint_t n, cost_t *cost[], 61 | int_t *x, int_t *y); 62 | 63 | extern int_t lapmod_internal( 64 | const uint_t n, cost_t *cc, uint_t *ii, uint_t *kk, 65 | int_t *x, int_t *y, fp_t fp_version); 66 | 67 | #endif // LAPJV_H 68 | -------------------------------------------------------------------------------- /scripts/Enemy.py: -------------------------------------------------------------------------------- 1 | class Enemy(): 2 | """ 3 | =========================================================== 4 | Enemy Class which represents a target object 5 | =========================================================== 6 | """ 7 | # Defined States in the Mission State Machine 8 | def __init__(self, agentId, agentPos, agentVel, confidence): 9 | """ 10 | =========================================================== 11 | Constructor to create initial relevant Objects and global 12 | Variables of Agent instance 13 | =========================================================== 14 | :Parameters: None 15 | The Agents object is represented by a set of parameters: 16 | - AgentID (uint32) 17 | - AgentPosition ([3] List of float64) 18 | - AgentVelocity ([3] List of float64) 19 | - Confidence (float64) 20 | :return: None 21 | =========================================================== 22 | """ 23 | # Timeframe for interpolation of target motion 24 | self.timeframe=10 25 | 26 | # object information 27 | self.agentId = agentId 28 | self.agentPos = agentPos 29 | self.agentVel = agentVel 30 | self.agentFuturePositon = self.get_futurePosition() 31 | self.confidence = confidence 32 | self.attackStatus = False 33 | 34 | 35 | # Getter Functions 36 | def get_futurePosition(self): 37 | """ 38 | =========================================================== 39 | Function which does a dead reckoning of the agents position 40 | in order to send a agent to a possible future position of 41 | the agent 42 | =========================================================== 43 | """ 44 | return ((self.agentPos[0]+self.agentVel[0]*self.timeframe), (self.agentPos[1]+self.agentVel[1]*self.timeframe), (self.agentPos[2]+self.agentVel[2]*self.timeframe)) 45 | 46 | 47 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_state_callbacks.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | import mock 5 | import pytest 6 | 7 | 8 | @pytest.fixture() 9 | def event_mock(): 10 | return mock.MagicMock() 11 | 12 | 13 | @pytest.fixture() 14 | def traffic_light_machine(event_mock): 15 | from statemachine import StateMachine, State 16 | 17 | class TrafficLightMachineStateEvents(StateMachine): 18 | "A traffic light machine" 19 | green = State('Green', initial=True) 20 | yellow = State('Yellow') 21 | red = State('Red') 22 | 23 | cycle = green.to(yellow) | yellow.to(red) | red.to(green) 24 | 25 | def on_enter_state(self, state): 26 | event_mock.on_enter_state(state) 27 | 28 | def on_exit_state(self, state): 29 | event_mock.on_exit_state(state) 30 | 31 | def on_enter_green(self): 32 | event_mock.on_enter_green() 33 | 34 | def on_exit_green(self): 35 | event_mock.on_exit_green() 36 | 37 | def on_enter_yellow(self): 38 | event_mock.on_enter_yellow() 39 | 40 | def on_exit_yellow(self): 41 | event_mock.on_exit_yellow() 42 | 43 | def on_enter_red(self): 44 | event_mock.on_enter_red() 45 | 46 | def on_exit_red(self): 47 | event_mock.on_exit_red() 48 | 49 | return TrafficLightMachineStateEvents 50 | 51 | 52 | class TestStateCallbacks(object): 53 | 54 | def test_should_call_on_enter_generic_state(self, event_mock, traffic_light_machine): 55 | machine = traffic_light_machine() 56 | machine.cycle() 57 | event_mock.on_enter_state.assert_called_once_with(machine.yellow) 58 | 59 | def test_should_call_on_exit_generic_state(self, event_mock, traffic_light_machine): 60 | machine = traffic_light_machine() 61 | machine.cycle() 62 | event_mock.on_exit_state.assert_called_once_with(machine.green) 63 | 64 | def test_should_call_on_enter_of_specific_state(self, event_mock, traffic_light_machine): 65 | machine = traffic_light_machine() 66 | machine.cycle() 67 | event_mock.on_enter_yellow.assert_called_once_with() 68 | 69 | def test_should_call_on_exit_of_specific_state(self, event_mock, traffic_light_machine): 70 | machine = traffic_light_machine() 71 | machine.cycle() 72 | event_mock.on_exit_green.assert_called_once_with() 73 | -------------------------------------------------------------------------------- /Include/lap-master/bench/overview_sparse.py: -------------------------------------------------------------------------------- 1 | from pytest import mark 2 | from joblib import Memory 3 | 4 | import numpy as np 5 | from lap import lapjv, lapmod 6 | from lap.lapmod import get_cost 7 | try: 8 | from lap_old import lapjv as lapjv_old 9 | except ImportError: 10 | print( 11 | '''If you get here, you do not have the old lapjv to compare to. 12 | git clone git@github.com:gatagat/lapjv.git lapjv-old 13 | cd lapjv-old 14 | git checkout old 15 | python setup.py build_ext -i 16 | mv lapjv lapjv_old 17 | And run the benchmark: 18 | LAPJV_OLD=lapjv-old bench.sh 19 | ''') 20 | lapjv_old = None 21 | from centrosome.lapjv import lapjv as lapjv_centrosome 22 | 23 | from lap.tests.test_utils import ( 24 | sparse_from_masked, 25 | sparse_from_masked_CS, 26 | get_sparse_int, 27 | get_platform_maxint 28 | ) 29 | 30 | cachedir = '/tmp/lapjv-cache' 31 | memory = Memory(cachedir=cachedir, verbose=1) 32 | 33 | 34 | @memory.cache 35 | def get_data(seed): 36 | cost, mask = get_sparse_int(5000, 1000, 0.01, hard=False, seed=seed) 37 | cost_ = cost.copy() 38 | cost_[~mask] = get_platform_maxint() 39 | opt = lapjv(cost_)[0] 40 | return cost, mask, opt 41 | 42 | seeds = [1299821, 15485867, 32452867, 49979693] 43 | 44 | 45 | def _get_cost_CS(cost, x): 46 | return cost[np.arange(cost.shape[0]), x].sum() 47 | 48 | 49 | @mark.parametrize('seed', seeds) 50 | def test_CSCY(benchmark, seed): 51 | cost, mask, opt = get_data(seed) 52 | i, j, cc = sparse_from_masked_CS(cost, mask) 53 | ret = benchmark(lapjv_centrosome, i, j, cc) 54 | assert _get_cost_CS(cost, ret[0]) == opt 55 | 56 | 57 | if lapjv_old is not None: 58 | @mark.parametrize('seed', seeds) 59 | def test_JV_old(benchmark, seed): 60 | cost, mask, opt = get_data(seed) 61 | cost[~mask] = get_platform_maxint() 62 | ret = benchmark(lapjv_old, cost) 63 | assert ret[0] == opt 64 | 65 | 66 | @mark.parametrize('seed', seeds) 67 | def test_JV(benchmark, seed): 68 | cost, mask, opt = get_data(seed) 69 | cost[~mask] = get_platform_maxint() 70 | ret = benchmark(lapjv, cost) 71 | assert ret[0] == opt 72 | 73 | 74 | @mark.parametrize('seed', seeds) 75 | def test_MOD_c(benchmark, seed): 76 | cost, mask, opt = get_data(seed) 77 | n, cc, ii, kk = sparse_from_masked(cost, mask) 78 | ret = benchmark(lapmod, n, cc, ii, kk, fast=True, return_cost=False) 79 | assert get_cost(n, cc, ii, kk, ret[0]) == opt 80 | -------------------------------------------------------------------------------- /Include/lap-master/bench/overview_dense.py: -------------------------------------------------------------------------------- 1 | from pytest import mark 2 | from joblib import Memory 3 | 4 | from lap import lapjv, lapmod 5 | from lap.lapmod import get_cost 6 | try: 7 | from lap_old import lapjv as lapjv_old 8 | except ImportError: 9 | print( 10 | '''If you get here, you do not have the old lapjv to compare to. 11 | git clone git@github.com:gatagat/lapjv.git lapjv-old 12 | cd lapjv-old 13 | git checkout old 14 | python setup.py build_ext -i 15 | mv lapjv lapjv_old 16 | And run the benchmark: 17 | LAPJV_OLD=lapjv-old bench.sh 18 | ''') 19 | lapjv_old = None 20 | from pymatgen.optimization.linear_assignment import LinearAssignment 21 | from centrosome.lapjv import lapjv as lapjv_centrosome 22 | 23 | from lap.tests.test_utils import ( 24 | sparse_from_dense, 25 | sparse_from_dense_CS, get_cost_CS, 26 | get_dense_int 27 | ) 28 | 29 | cachedir = '/tmp/lapjv-cache' 30 | memory = Memory(cachedir=cachedir, verbose=1) 31 | 32 | 33 | @memory.cache 34 | def get_data(seed): 35 | cost = get_dense_int(100, 1000, hard=True, seed=seed) 36 | opt = lapjv(cost)[0] 37 | return cost, opt 38 | 39 | seeds = [1299821, 15485867, 32452867, 49979693] 40 | 41 | 42 | if lapjv_old is not None: 43 | @mark.parametrize('seed', seeds) 44 | def test_JV_old(benchmark, seed): 45 | cost, opt = get_data(seed) 46 | ret = benchmark(lapjv_old, cost) 47 | assert ret[0] == opt 48 | 49 | 50 | @mark.parametrize('seed', seeds) 51 | def test_JV(benchmark, seed): 52 | cost, opt = get_data(seed) 53 | ret = benchmark(lapjv, cost) 54 | assert ret[0] == opt 55 | 56 | 57 | @mark.parametrize('seed', seeds) 58 | def test_MODPY(benchmark, seed): 59 | cost, opt = get_data(seed) 60 | n, cc, ii, kk = sparse_from_dense(cost) 61 | ret = benchmark(lapmod, n, cc, ii, kk, fast=False, return_cost=False) 62 | assert get_cost(n, cc, ii, kk, ret[0]) == opt 63 | 64 | 65 | @mark.parametrize('seed', seeds) 66 | def test_MOD_c(benchmark, seed): 67 | cost, opt = get_data(seed) 68 | n, cc, ii, kk = sparse_from_dense(cost) 69 | ret = benchmark(lapmod, n, cc, ii, kk, fast=True, return_cost=False) 70 | assert get_cost(n, cc, ii, kk, ret[0]) == opt 71 | 72 | 73 | @mark.parametrize('seed', seeds) 74 | def test_PMG(benchmark, seed): 75 | cost, opt = get_data(seed) 76 | ret = benchmark(LinearAssignment, cost) 77 | assert ret.min_cost == opt 78 | 79 | 80 | @mark.parametrize('seed', seeds) 81 | def test_CSCY(benchmark, seed): 82 | cost, opt = get_data(seed) 83 | i, j, cc = sparse_from_dense_CS(cost) 84 | ret = benchmark(lapjv_centrosome, i, j, cc) 85 | assert get_cost_CS(cost, ret[0]) == opt 86 | -------------------------------------------------------------------------------- /scripts/Task.py: -------------------------------------------------------------------------------- 1 | import time 2 | from enum import Enum 3 | 4 | class TaskType(Enum): 5 | """ 6 | =========================================================== 7 | Enum Structure Class for different Task Types 8 | =========================================================== 9 | """ 10 | TAKEOFF = 1 11 | WAYPOINT = 2 12 | PRELEASE = 3 13 | LAND = 4 14 | ABORTMISSION = 5 15 | RECOVERY= 6 16 | SYSTEMCHECK = 7 17 | ATTACK = 8 18 | 19 | class Task(): 20 | """ 21 | =========================================================== 22 | Task Class which represents a task object 23 | =========================================================== 24 | """ 25 | # Defined States in the Mission State Machine 26 | def __init__(self,agentIdx,targetId, taskType,wayPointLocation,taskDeadline): 27 | """ 28 | =========================================================== 29 | Constructor to create initial relevant Objects and global 30 | Variables of Agent instance 31 | =========================================================== 32 | :Parameters: None 33 | The Agents object is represented by a set of parameters: 34 | - agentIdx (uint32) 35 | - targetId (uint32) 36 | - wayPointLocation ([3] List of float64) 37 | - taskDeadline (float64) 38 | :return: None 39 | =========================================================== 40 | """ 41 | 42 | self.timestamp = time.time() 43 | self.agentIdx = agentIdx 44 | self.targetId = targetId 45 | self.taskType = taskType 46 | self.wayPointLocation = wayPointLocation 47 | self.taskDeadline = taskDeadline 48 | 49 | class InitMsg(): 50 | """ 51 | =========================================================== 52 | Init Message Class which represents a init message object 53 | =========================================================== 54 | """ 55 | # Initialization message with home location 56 | def __init__(self, agentIdx, homeLocation): 57 | """ 58 | =========================================================== 59 | Constructor to create initial relevant Objects and global 60 | Variables of Agent instance 61 | =========================================================== 62 | :Parameters: None 63 | The Agents object is represented by a set of parameters: 64 | - agentIdx (uint32) 65 | - targetId (uint32) 66 | - homeLocation ([3] List of float64) 67 | :return: None 68 | =========================================================== 69 | """ 70 | 71 | self.agentIdx = agentIdx 72 | self.homeLocation = homeLocation -------------------------------------------------------------------------------- /Include/lap-master/bench/matrix_dense_hard.py: -------------------------------------------------------------------------------- 1 | from pytest import mark 2 | from joblib import Memory 3 | 4 | from lap import lapjv, lapmod 5 | from lap.lapmod import get_cost 6 | try: 7 | from lap_old import lapjv as lapjv_old 8 | except ImportError: 9 | print( 10 | '''If you get here, you do not have the old lapjv to compare to. 11 | git clone git@github.com:gatagat/lapjv.git lapjv-old 12 | cd lapjv-old 13 | git checkout old 14 | python setup.py build_ext -i 15 | mv lapjv lapjv_old 16 | And run the benchmark: 17 | LAPJV_OLD=lapjv-old bench.sh 18 | ''') 19 | lapjv_old = None 20 | from centrosome.lapjv import lapjv as lapjv_centrosome 21 | from lap.tests.test_utils import ( 22 | get_dense_int, get_cost_CS, sparse_from_dense_CS, sparse_from_dense) 23 | 24 | max_time_per_benchmark = 20 25 | 26 | szs = [10, 100, 200, 500, 1000, 2000, 5000] 27 | rngs = [100, 1000, 10000, 100000] 28 | seeds = [1299821, 15485867, 32452867, 49979693] 29 | 30 | 31 | cachedir = '/tmp/lapjv-cache' 32 | memory = Memory(cachedir=cachedir, verbose=1) 33 | 34 | 35 | @memory.cache 36 | def get_hard_data(sz, rng, seed): 37 | cost = get_dense_int(sz, 100, hard=True, seed=seed) 38 | opt = lapjv(cost)[0] 39 | return cost, opt 40 | 41 | 42 | if lapjv_old is not None: 43 | @mark.timeout(max_time_per_benchmark) 44 | @mark.parametrize('sz,rng,seed', [ 45 | (sz, rng, seed) for sz in szs for rng in rngs for seed in seeds]) 46 | def test_JV_old(benchmark, sz, rng, seed): 47 | cost, opt = get_hard_data(sz, rng, seed) 48 | ret = benchmark(lapjv_old, cost) 49 | assert ret[0] == opt 50 | 51 | 52 | @mark.timeout(max_time_per_benchmark) 53 | @mark.parametrize('sz,rng,seed', [ 54 | (sz, rng, seed) for sz in szs for rng in rngs for seed in seeds]) 55 | def test_JV(benchmark, sz, rng, seed): 56 | cost, opt = get_hard_data(sz, rng, seed) 57 | ret = benchmark(lapjv, cost, return_cost=False) 58 | assert cost[range(cost.shape[0]), ret[0]].sum() == opt 59 | 60 | 61 | @mark.timeout(max_time_per_benchmark) 62 | @mark.parametrize('sz,rng,seed', [ 63 | (sz, rng, seed) for sz in szs for rng in rngs for seed in seeds]) 64 | def test_MOD_c(benchmark, sz, rng, seed): 65 | cost, opt = get_hard_data(sz, rng, seed) 66 | _, cc, ii, kk = sparse_from_dense(cost) 67 | ret = benchmark(lapmod, sz, cc, ii, kk, fast=True, return_cost=False) 68 | assert get_cost(sz, cc, ii, kk, ret[0]) == opt 69 | 70 | 71 | @mark.timeout(max_time_per_benchmark) 72 | @mark.parametrize('sz,rng,seed', [ 73 | (sz, rng, seed) for sz in szs for rng in rngs for seed in seeds]) 74 | def test_CSCY(benchmark, sz, rng, seed): 75 | cost, opt = get_hard_data(sz, rng, seed) 76 | i, j, cc = sparse_from_dense_CS(cost) 77 | ret = benchmark(lapjv_centrosome, i, j, cc) 78 | assert get_cost_CS(cost, ret[0]) == opt 79 | -------------------------------------------------------------------------------- /Include/lap-master/bench/matrix_sparse.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | from pytest import mark 4 | from joblib import Memory 5 | 6 | from lap import lapjv, lapmod 7 | try: 8 | from lap_old import lapjv as lapjv_old 9 | except ImportError: 10 | print( 11 | '''If you get here, you do not have the old lapjv to compare to. 12 | git clone git@github.com:gatagat/lapjv.git lapjv-old 13 | cd lapjv-old 14 | git checkout old 15 | python setup.py build_ext -i 16 | mv lapjv lapjv_old 17 | And run the benchmark: 18 | LAPJV_OLD=lapjv-old bench.sh 19 | ''') 20 | lapjv_old = None 21 | from centrosome.lapjv import lapjv as lapjv_centrosome 22 | from lap.tests.test_utils import ( 23 | sparse_from_masked, 24 | sparse_from_masked_CS, 25 | get_sparse_int, 26 | get_platform_maxint) 27 | 28 | max_time_per_benchmark = 15 29 | 30 | szs = [1000, 5000, 10000] 31 | sparsities = [0.5, 0.05, 0.005, 0.0005, 0.00005] 32 | seeds = [1299821, 15485867, 32452867, 49979693] 33 | 34 | 35 | cachedir = '/tmp/lapjv-cache' 36 | memory = Memory(cachedir=cachedir, verbose=1) 37 | 38 | 39 | @memory.cache 40 | def get_data(sz, sparsity, seed, rng=100): 41 | cost, mask = get_sparse_int(sz, rng, sparsity, hard=False, seed=seed) 42 | print('Requested sparsity %f generated %f' % (sparsity, mask.mean())) 43 | cost[~mask] = get_platform_maxint() 44 | return cost, mask 45 | 46 | 47 | if lapjv_old is not None: 48 | @mark.timeout(max_time_per_benchmark) 49 | @mark.parametrize('sz,sparsity,seed', [ 50 | (sz, sparsity, seed) 51 | for sz in szs for sparsity in sparsities for seed in seeds]) 52 | def test_JV_old(benchmark, sz, sparsity, seed): 53 | cost, mask = get_data(sz, sparsity, seed) 54 | benchmark(lapjv_old, cost) 55 | 56 | 57 | @mark.timeout(max_time_per_benchmark) 58 | @mark.parametrize('sz,sparsity,seed', [ 59 | (sz, sparsity, seed) 60 | for sz in szs for sparsity in sparsities for seed in seeds]) 61 | def test_JV(benchmark, sz, sparsity, seed): 62 | cost, mask = get_data(sz, sparsity, seed) 63 | benchmark(lapjv, cost, return_cost=False) 64 | 65 | 66 | @mark.timeout(max_time_per_benchmark) 67 | @mark.parametrize('sz,sparsity,seed', [ 68 | (sz, sparsity, seed) 69 | for sz in szs for sparsity in sparsities for seed in seeds]) 70 | def test_MOD_c(benchmark, sz, sparsity, seed): 71 | cost, mask = get_data(sz, sparsity, seed) 72 | _, cc, ii, kk = sparse_from_masked(cost, mask) 73 | benchmark(lapmod, sz, cc, ii, kk, fast=True, return_cost=False) 74 | 75 | 76 | @mark.timeout(max_time_per_benchmark) 77 | @mark.parametrize('sz,sparsity,seed', [ 78 | (sz, sparsity, seed) 79 | for sz in szs for sparsity in sparsities for seed in seeds]) 80 | def test_CSCY(benchmark, sz, sparsity, seed): 81 | cost, mask = get_data(sz, sparsity, seed) 82 | i, j, cc = sparse_from_masked_CS(cost, mask) 83 | benchmark(lapjv_centrosome, i, j, cc) 84 | -------------------------------------------------------------------------------- /Include/lap-master/lap/tests/test_arr_loop.py: -------------------------------------------------------------------------------- 1 | from pytest import approx 2 | 3 | import numpy as np 4 | from lap import lapmod, lapjv 5 | 6 | 7 | def prepare_sparse_cost(shape, cc, ii, jj, cost_limit): 8 | ''' 9 | Transform the given sparse matrix extending it to a square sparse matrix. 10 | 11 | Parameters 12 | ========== 13 | shape: tuple 14 | - cost matrix shape 15 | (cc, ii, jj): tuple of floats, ints, ints) 16 | - cost matrix in COO format, see [1] 17 | cost_limit: float 18 | 19 | Returns 20 | ======= 21 | cc, ii, kk 22 | - extended square cost matrix in CSR format 23 | 24 | 1. https://en.wikipedia.org/wiki/Sparse_matrix 25 | ''' 26 | assert cost_limit < np.inf 27 | n, m = shape 28 | cc_ = np.r_[cc, [cost_limit] * n, 29 | [cost_limit] * m, [0] * len(cc)] 30 | ii_ = np.r_[ii, np.arange(0, n, dtype=np.uint32), 31 | np.arange(n, n + m, dtype=np.uint32), n + jj] 32 | jj_ = np.r_[jj, np.arange(m, n + m, dtype=np.uint32), 33 | np.arange(0, m, dtype=np.uint32), m + ii] 34 | order = np.lexsort((jj_, ii_)) 35 | cc_ = cc_[order] 36 | kk_ = jj_[order] 37 | ii_ = ii_.astype(np.intp) 38 | ii_ = np.bincount(ii_, minlength=shape[0]-1) 39 | ii_ = np.r_[[0], np.cumsum(ii_)] 40 | ii_ = ii_.astype(np.uint32) 41 | assert ii_[-1] == 2 * len(cc) + n + m 42 | return cc_, ii_, kk_ 43 | 44 | 45 | def test_lapjv_arr_loop(): 46 | shape = (7, 3) 47 | cc = np.array([ 48 | 2.593883482138951146e-01, 3.080381437461217620e-01, 49 | 1.976243020727339317e-01, 2.462740976049606068e-01, 50 | 4.203993396282833528e-01, 4.286184525458427985e-01, 51 | 1.706431415909629434e-01, 2.192929371231896185e-01, 52 | 2.117769622802734286e-01, 2.604267578125001315e-01]) 53 | ii = np.array([0, 0, 1, 1, 2, 2, 5, 5, 6, 6]) 54 | jj = np.array([0, 1, 0, 1, 1, 2, 0, 1, 0, 1]) 55 | cost = np.empty(shape) 56 | cost[:] = 1000. 57 | cost[ii, jj] = cc 58 | opt, ind1, ind0 = lapjv(cost, extend_cost=True, return_cost=True) 59 | assert opt == approx(0.8455356917416, 1e-10) 60 | assert np.all(ind0 == [5, 1, 2]) or np.all(ind0 == [1, 5, 2]) 61 | 62 | 63 | def test_lapmod_arr_loop(): 64 | shape = (7, 3) 65 | cc = np.array([ 66 | 2.593883482138951146e-01, 3.080381437461217620e-01, 67 | 1.976243020727339317e-01, 2.462740976049606068e-01, 68 | 4.203993396282833528e-01, 4.286184525458427985e-01, 69 | 1.706431415909629434e-01, 2.192929371231896185e-01, 70 | 2.117769622802734286e-01, 2.604267578125001315e-01]) 71 | ii = np.array([0, 0, 1, 1, 2, 2, 5, 5, 6, 6]) 72 | jj = np.array([0, 1, 0, 1, 1, 2, 0, 1, 0, 1]) 73 | cost_limit = 1e3 74 | cc, ii, kk = prepare_sparse_cost(shape, cc, ii, jj, cost_limit) 75 | opt, ind1, ind0 = lapmod(len(ii)-1, cc, ii, kk, return_cost=True) 76 | ind1[ind1 >= shape[1]] = -1 77 | ind0[ind0 >= shape[0]] = -1 78 | ind1 = ind1[:shape[0]] 79 | ind0 = ind0[:shape[1]] 80 | assert opt == approx(4000.8455356917416, 1e-10) 81 | assert np.all(ind0 == [5, 1, 2]) or np.all(ind0 == [1, 5, 2]) 82 | -------------------------------------------------------------------------------- /scripts/FrameConvertor.py: -------------------------------------------------------------------------------- 1 | """ 2 | frame_module.py contains functions to convert between local battlefield 3 | co-coordinates and GPS co-coordinates 4 | """ 5 | import os 6 | import time 7 | import numpy as np 8 | from pyproj import Proj 9 | 10 | 11 | class FrameConvertor: 12 | def __init__(self): 13 | # Read battlefield waypoints from file 14 | f = open(self.getRelativeFilePath("Battlefield.txt")) 15 | lines = f.readlines() 16 | f.close() 17 | 18 | x0y0_GPS = np.array([float(i) for i in lines[0].split(',')]) 19 | x100y0_GPS = np.array([float(i) for i in lines[1].split(',')]) 20 | #x0y100_GPS = np.array([float(i) for i in lines[2].split(',')]) 21 | #x100y100_GPS = np.array([float(i) for i in lines[3].split(',')]) 22 | 23 | self.world = Proj(proj='tmerc', lon_0=x0y0_GPS[1], lat_0=x0y0_GPS[0], ellps='airy') 24 | #self.x_off,self.y_off = self.world(0,0,inverse=True) 25 | 26 | #x0y0_lcl = self.world(x0y0_GPS[1],x0y0_GPS[0]) 27 | x100y0_lcl = list(self.world(x100y0_GPS[1],x100y0_GPS[0])) 28 | #x0y100_lcl = self.world(x0y100_GPS[1],x0y100_GPS[0]) 29 | #x100y100_lcl = self.world(x100y100_GPS[1],x100y100_GPS[0]) 30 | 31 | self.tilt = np.arctan2(x100y0_lcl[1],x100y0_lcl[0]) 32 | 33 | 34 | def localToWorldFrame(self,pos): 35 | ''' To convert from the local battlefield coordinates to GPS''' 36 | lon, lat = self.world(pos[0],pos[1],inverse=True) # For AIRY ellipse 37 | 38 | worldPos = [lat, lon, pos[2]] 39 | 40 | return worldPos 41 | 42 | 43 | def worldToLocalFrame(self,gps,orient): 44 | ''' To convert from GPS to the local battlefield coordinates''' 45 | x,y = self.world(gps[1], gps[0]) # For AIRY ellipse 46 | 47 | localPos = [x, y, gps[2]] 48 | localHead = orient - self.tilt 49 | 50 | return localPos,localHead 51 | 52 | 53 | def getRelativeFilePath(self, relativePath): 54 | scriptDir = os.path.dirname(__file__) 55 | absFilePath = os.path.join(scriptDir, relativePath) 56 | return absFilePath 57 | 58 | if __name__ == "__main__": 59 | 60 | convertor = FrameConvertor() 61 | inputFilenames = ["takeoff_local.txt", "round1_landing_local.txt", "round2_landing_local.txt","round3_landing_local.txt"] 62 | outputFilenames = ["takeoff_global.txt", "round1_landing_global.txt", "round2_landing_global.txt", 63 | "round3_landing_global.txt"] 64 | 65 | for i in range(0,len(inputFilenames)): 66 | f = open(convertor.getRelativeFilePath(inputFilenames[i])) 67 | lines = f.readlines() 68 | f.close() 69 | f = open(convertor.getRelativeFilePath(outputFilenames[i]), 'a') 70 | 71 | for i in range(0, len(lines)): 72 | line = lines[i].split(" ") 73 | del line[-1] # delete last element with new line command 74 | id = line[0] 75 | localwaypoint[0] = line[1] 76 | localwaypoint[0] = line[2] 77 | localwaypoint = [float(x) for x in localwaypoint] 78 | globalwaypoint = convertor.localToWorldFrame(localwaypoint) 79 | f.write("%s %6.4f %6.4f" % (id, globalwaypoint[0], globalwaypoint[1])) 80 | f.close() 81 | 82 | 83 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | mission_planning 4 | 0.0.0 5 | The mission_planning package 6 | 7 | 8 | 9 | 10 | johannes 11 | 12 | 13 | 14 | 15 | 16 | TODO 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | catkin 52 | 53 | rospy 54 | std_msgs 55 | statemachine 56 | message_generation 57 | 58 | rospy 59 | std_msgs 60 | statemachine 61 | 62 | rospy 63 | std_msgs 64 | statemachine 65 | message_runtime 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Include/python-statemachine/statemachine/exceptions.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | from .utils import ugettext as _ 5 | 6 | 7 | class StateMachineError(Exception): 8 | "Base exception for this project, all exceptions that can be raised inherit from this class." 9 | 10 | 11 | class InvalidDefinition(StateMachineError): 12 | "The state machine has a definition error" 13 | 14 | 15 | class InvalidStateValue(InvalidDefinition): 16 | "The current model state value is not mapped to a state definition." 17 | 18 | def __init__(self, value): 19 | self.value = value 20 | msg = _("{!r} is not a valid state value.").format(value) 21 | super(InvalidStateValue, self).__init__(msg) 22 | 23 | 24 | class InvalidTransitionIdentifier(InvalidDefinition): 25 | "There's no transition with the given identifier." 26 | 27 | def __init__(self, identifier): 28 | self.identifier = identifier 29 | msg = _('{!r} is not a valid transition identifier').format(identifier) 30 | super(InvalidTransitionIdentifier, self).__init__(msg) 31 | 32 | 33 | class InvalidDestinationState(InvalidDefinition): 34 | """ 35 | In the case of multiple destination states, you've returned a state that is not in the 36 | possible destinations for the current transition. 37 | """ 38 | def __init__(self, transition, destination): 39 | self.transition = transition 40 | self.destination = destination 41 | msg = _('{destination.name} is not a possible destination state for ' 42 | '{transition.identifier} transition.').format( 43 | transition=transition, 44 | destination=destination, 45 | 46 | ) 47 | super(InvalidDestinationState, self).__init__(msg) 48 | 49 | 50 | class TransitionNotAllowed(StateMachineError): 51 | "The transition can't run from the current state." 52 | 53 | def __init__(self, transition, state): 54 | self.transition = transition 55 | self.state = state 56 | msg = _("Can't {} when in {}.").format( 57 | self.transition.identifier, 58 | self.state.name 59 | ) 60 | super(TransitionNotAllowed, self).__init__(msg) 61 | 62 | 63 | class MultipleStatesFound(StateMachineError): 64 | """ 65 | You have mapped a transition from one state to multiple states. In this case, there's no way 66 | to determine what is the desired destination state, so you must inform it when the transition 67 | is called. 68 | 69 | You can inform the transition on the `on_execute` callback. 70 | """ 71 | def __init__(self, transition): 72 | self.transition = transition 73 | msg = _('Multiple destinations, you must return the desired state as: ' 74 | '`return ` or `return , `.') 75 | super(MultipleStatesFound, self).__init__(msg) 76 | 77 | 78 | class MultipleTransitionCallbacksFound(InvalidDefinition): 79 | """ 80 | You have defined multiple callbacks ``on_execute`` for the same transition. 81 | """ 82 | def __init__(self, transition): 83 | self.transition = transition 84 | msg = _('Multiple callbacks found, you must choose between a callback in the transition' 85 | 'or a bouded method in the state machine class.') 86 | super(MultipleTransitionCallbacksFound, self).__init__(msg) 87 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/conftest.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | import pytest 4 | from datetime import datetime 5 | 6 | 7 | @pytest.fixture 8 | def current_time(): 9 | return datetime.now() 10 | 11 | 12 | @pytest.fixture 13 | def campaign_machine(): 14 | "Define a new class for each test" 15 | from statemachine import State, StateMachine 16 | 17 | class CampaignMachine(StateMachine): 18 | "A workflow machine" 19 | draft = State('Draft', initial=True) 20 | producing = State('Being produced') 21 | closed = State('Closed') 22 | 23 | add_job = draft.to(draft) | producing.to(producing) 24 | produce = draft.to(producing) 25 | deliver = producing.to(closed) 26 | 27 | return CampaignMachine 28 | 29 | 30 | @pytest.fixture 31 | def campaign_machine_with_values(): 32 | "Define a new class for each test" 33 | from statemachine import State, StateMachine 34 | 35 | class CampaignMachineWithKeys(StateMachine): 36 | "A workflow machine" 37 | draft = State('Draft', initial=True, value=1) 38 | producing = State('Being produced', value=2) 39 | closed = State('Closed', value=3) 40 | 41 | add_job = draft.to(draft) | producing.to(producing) 42 | produce = draft.to(producing) 43 | deliver = producing.to(closed) 44 | 45 | return CampaignMachineWithKeys 46 | 47 | 48 | @pytest.fixture 49 | def traffic_light_machine(): 50 | from statemachine import StateMachine, State 51 | 52 | class TrafficLightMachine(StateMachine): 53 | "A traffic light machine" 54 | green = State('Green', initial=True) 55 | yellow = State('Yellow') 56 | red = State('Red') 57 | 58 | cycle = green.to(yellow) | yellow.to(red) | red.to(green) 59 | 60 | @green.to(yellow) 61 | def slowdown(self, *args, **kwargs): 62 | return args, kwargs 63 | 64 | @yellow.to(red) 65 | def stop(self, *args, **kwargs): 66 | return args, kwargs 67 | 68 | @red.to(green) 69 | def go(self, *args, **kwargs): 70 | return args, kwargs 71 | 72 | def on_cicle(self, *args, **kwargs): 73 | return args, kwargs 74 | 75 | return TrafficLightMachine 76 | 77 | 78 | @pytest.fixture 79 | def approval_machine(current_time): 80 | from statemachine import StateMachine, State 81 | 82 | class ApprovalMachine(StateMachine): 83 | "A workflow machine" 84 | requested = State('Requested', initial=True) 85 | accepted = State('Accepted') 86 | rejected = State('Rejected') 87 | 88 | completed = State('Completed') 89 | 90 | @requested.to(accepted, rejected) 91 | def validate(self, *args, **kwargs): 92 | if self.model.is_ok(): 93 | self.model.accepted_at = current_time 94 | return self.model, self.accepted 95 | else: 96 | self.model.rejected_at = current_time 97 | return self.model, self.rejected 98 | 99 | @accepted.to(completed) 100 | def complete(self): 101 | self.model.completed_at = current_time 102 | 103 | @requested.to(requested) 104 | def update(self, **kwargs): 105 | for k, v in kwargs.items(): 106 | setattr(self.model, k, v) 107 | return self.model 108 | 109 | @rejected.to(requested) 110 | def retry(self): 111 | self.model.rejected_at = None 112 | return self.model 113 | 114 | return ApprovalMachine 115 | -------------------------------------------------------------------------------- /Include/lap-master/README.md: -------------------------------------------------------------------------------- 1 | [![Travis](https://travis-ci.org/gatagat/lap.svg?branch=master)](https://travis-ci.org/gatagat/lap/) 2 | [![Appveyor](https://ci.appveyor.com/api/projects/status/github/gatagat/lap?branch=master&svg=true)](https://ci.appveyor.com/project/gatagat/lap/history) 3 | ![Python 2.7](https://img.shields.io/badge/python-2.7-blue.svg) 4 | ![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg) 5 | ![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg) 6 | 7 | lap: Linear Assignment Problem solver 8 | ===================================== 9 | 10 | **lap** is a [linear assignment 11 | problem](https://en.wikipedia.org/wiki/Assignment_problem) solver using 12 | Jonker-Volgenant algorithm for dense (LAPJV [1]) or sparse (LAPMOD [2]) 13 | matrices. 14 | 15 | Both algorithms are implemented from scratch based solely on the papers [1,2] 16 | and the public domain Pascal implementation provided by A. Volgenant [3]. 17 | 18 | In my tests the LAPMOD implementation seems to be faster than the LAPJV 19 | implementation for matrices with a side of more than ~5000 and with less than 20 | 50% finite coefficients. 21 | 22 | [1] R. Jonker and A. Volgenant, "A Shortest Augmenting Path Algorithm for Dense 23 | and Sparse Linear Assignment Problems", Computing 38, 325-340 (1987)
24 | [2] A. Volgenant, "Linear and Semi-Assignment Problems: A Core Oriented 25 | Approach", Computer Ops Res. 23, 917-932 (1996)
26 | [3] http://www.assignmentproblems.com/LAPJV.htm 27 | 28 | Installation 29 | ------------ 30 | 31 | #### Dependencies 32 | 33 | lap requires: 34 | 35 | * Python (2.7, 3.6, 3.7) 36 | * NumPy (>=1.10.1) 37 | * Cython (>=0.21) - to compile the wrapper 38 | * SciPy, pytest, pytest-timeout - only for testing 39 | 40 | #### Install using pip 41 | 42 | You can install the latest release of lap from PyPI (recommended): 43 | 44 | pip install lap 45 | 46 | Alternatively, you can install lap directly from the repository: 47 | 48 | pip install git+git://github.com/gatagat/lap.git 49 | 50 | #### Install from source 51 | 52 | 1. Clone 53 | 54 | git clone https://github.com/gatagat/lap.git 55 | 56 | 2. Under the root of the repo 57 | 58 | python setup.py build 59 | python setup.py install 60 | 61 | Tested under Linux, OS X, Windows. 62 | 63 | ### Usage 64 | 65 | ``` 66 | cost, x, y = lap.lapjv(C) 67 | ``` 68 | 69 | The function `lapjv(C)` returns the assignment cost (`cost`) and two arrays, `x, y`. If cost matrix `C` has shape N x M, then `x` is a size-N array specifying to which column is row is assigned, and `y` is a size-M array specifying to which row each column is assigned. For example, an output of `x = [1, 0]` indicates that row 0 is assigned to column 1 and row 1 is assigned to column 0. Similarly, an output of `x = [2, 1, 0]` indicates that row 0 is assigned to column 2, row 1 is assigned to column 1, and row 2 is assigned to column 0. 70 | 71 | Note that this function *does not* return the assignment matrix (as done by scipy's [`linear_sum_assignment`](https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.linear_sum_assignment.html) and lapsolver's [`solve dense`](https://github.com/cheind/py-lapsolver)). The assignment matrix can be constructed from `x` as follows: 72 | ``` 73 | A = np.zeros((N, M)) 74 | for i in range(N): 75 | A[i, x[i]] = 1 76 | ``` 77 | Equivalently, we could construct the assignment matrix from `y`: 78 | ``` 79 | A = np.zeros((N, M)) 80 | for j in range(M): 81 | A[y[j], j] = 1 82 | ``` 83 | 84 | Finally, note that the outputs are redundant: we can construct `x` from `y`, and vise versa: 85 | ``` 86 | x = [np.where(y == i)[0][0] for i in range(N)] 87 | y = [np.where(x == j)[0][0] for j in range(M)] 88 | ``` 89 | 90 | License 91 | ------- 92 | 93 | Released under the 2-clause BSD license, see `LICENSE`. 94 | 95 | Copyright (C) 2012-2017, Tomas Kazmar 96 | -------------------------------------------------------------------------------- /Include/python-statemachine/CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every 8 | little bit helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/fgmacedo/python-statemachine/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" 30 | and "help wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | Python State Machine could always use more documentation, whether as part of the 42 | official Python State Machine docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/fgmacedo/python-statemachine/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `python-statemachine` for local development. 61 | 62 | 1. Fork the `python-statemachine` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/python-statemachine.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 68 | 69 | $ mkvirtualenv python-statemachine 70 | $ cd python-statemachine/ 71 | $ python setup.py develop 72 | 73 | 4. Create a branch for local development:: 74 | 75 | $ git checkout -b name-of-your-bugfix-or-feature 76 | 77 | Now you can make your changes locally. 78 | 79 | 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: 80 | 81 | $ flake8 statemachine tests 82 | $ python setup.py test or py.test 83 | $ tox 84 | 85 | To get flake8 and tox, just pip install them into your virtualenv. 86 | 87 | 6. Commit your changes and push your branch to GitHub:: 88 | 89 | $ git add . 90 | $ git commit -m "Your detailed description of your changes." 91 | $ git push origin name-of-your-bugfix-or-feature 92 | 93 | 7. Submit a pull request through the GitHub website. 94 | 95 | Pull Request Guidelines 96 | ----------------------- 97 | 98 | Before you submit a pull request, check that it meets these guidelines: 99 | 100 | 1. The pull request should include tests. 101 | 2. If the pull request adds functionality, the docs should be updated. Put 102 | your new functionality into a function with a docstring, and add the 103 | feature to the list in README.rst. 104 | 3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5. Check 105 | https://travis-ci.org/fgmacedo/python-statemachine/pull_requests 106 | and make sure that the tests pass for all supported Python versions. 107 | 108 | Tips 109 | ---- 110 | 111 | To run a subset of tests:: 112 | 113 | $ py.test tests.test_statemachine 114 | 115 | -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_transitions.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | 5 | import pytest 6 | import mock 7 | 8 | from statemachine import Transition, State, exceptions, StateMachine 9 | 10 | 11 | def test_transition_representation(campaign_machine): 12 | s = repr([t for t in campaign_machine.transitions if t.identifier == 'produce'][0]) 13 | print(s) 14 | assert s == ( 15 | "Transition(" 16 | "State('Draft', identifier='draft', value='draft', initial=True), " 17 | "(State('Being produced', identifier='producing', value='producing', " 18 | "initial=False),), identifier='produce')" 19 | ) 20 | 21 | 22 | def test_transition_should_accept_decorator_syntax(traffic_light_machine): 23 | machine = traffic_light_machine() 24 | assert machine.current_state == machine.green 25 | 26 | 27 | def test_transition_as_decorator_should_call_method_before_activating_state(traffic_light_machine): 28 | machine = traffic_light_machine() 29 | assert machine.current_state == machine.green 30 | assert machine.slowdown(1, 2, number=3, text='x') == ((1, 2), {'number': 3, 'text': 'x'}) 31 | assert machine.current_state == machine.yellow 32 | 33 | 34 | def test_cycle_transitions(traffic_light_machine): 35 | machine = traffic_light_machine() 36 | expected_states = ['green', 'yellow', 'red'] * 2 37 | for expected_state in expected_states: 38 | assert machine.current_state.identifier == expected_state 39 | machine.cycle() 40 | 41 | 42 | def test_transition_call_can_only_be_used_as_decorator(): 43 | source, dest = State('Source'), State('Destination') 44 | transition = Transition(source, dest) 45 | 46 | with pytest.raises(exceptions.StateMachineError): 47 | transition('not a callable') 48 | 49 | 50 | @pytest.fixture(params=['bounded', 'unbounded']) 51 | def transition_callback_machine(request): 52 | if request.param == 'bounded': 53 | class ApprovalMachine(StateMachine): 54 | "A workflow" 55 | requested = State('Requested', initial=True) 56 | accepted = State('Accepted') 57 | 58 | validate = requested.to(accepted) 59 | 60 | def on_validate(self): 61 | self.model('on_validate') 62 | return 'accepted' 63 | elif request.param == 'unbounded': 64 | class ApprovalMachine(StateMachine): 65 | "A workflow" 66 | requested = State('Requested', initial=True) 67 | accepted = State('Accepted') 68 | 69 | @requested.to(accepted) 70 | def validate(self): 71 | self.model('on_validate') 72 | return 'accepted' 73 | else: 74 | raise ValueError('machine not defined') 75 | 76 | return ApprovalMachine 77 | 78 | 79 | def test_statemachine_transition_callback(transition_callback_machine): 80 | model = mock.Mock(state='requested') 81 | machine = transition_callback_machine(model) 82 | assert machine.validate() == 'accepted' 83 | model.assert_called_once_with('on_validate') 84 | 85 | 86 | def test_can_run_combined_transitions(): 87 | class CampaignMachine(StateMachine): 88 | "A workflow machine" 89 | draft = State('Draft', initial=True) 90 | producing = State('Being produced') 91 | closed = State('Closed') 92 | 93 | abort = draft.to(closed) | producing.to(closed) | closed.to(closed) 94 | 95 | machine = CampaignMachine() 96 | 97 | machine.abort() 98 | 99 | assert machine.is_closed 100 | 101 | 102 | def test_transitions_to_the_same_estate_as_itself(): 103 | class CampaignMachine(StateMachine): 104 | "A workflow machine" 105 | draft = State('Draft', initial=True) 106 | producing = State('Being produced') 107 | closed = State('Closed') 108 | 109 | update = draft.to.itself() 110 | abort = draft.to(closed) | producing.to(closed) | closed.to.itself() 111 | 112 | machine = CampaignMachine() 113 | 114 | machine.update() 115 | 116 | assert machine.is_draft 117 | -------------------------------------------------------------------------------- /scripts/_lapjv.pyx: -------------------------------------------------------------------------------- 1 | # Tomas Kazmar, 2012-2017, BSD 2-clause license, see LICENSE. 2 | 3 | import numpy as np 4 | cimport numpy as cnp 5 | cimport cython 6 | from libc.stdlib cimport malloc, free 7 | 8 | 9 | cdef extern from "lapjv.h" nogil: 10 | ctypedef signed int int_t 11 | ctypedef unsigned int uint_t 12 | cdef int LARGE 13 | cdef enum fp_t: 14 | FP_1 15 | FP_2 16 | FP_DYNAMIC 17 | int lapjv_internal( 18 | const uint_t n, 19 | double *cost[], 20 | int_t *x, 21 | int_t *y) 22 | int lapmod_internal( 23 | const uint_t n, 24 | double *cc, 25 | uint_t *ii, 26 | uint_t *kk, 27 | int_t *x, 28 | int_t *y, 29 | fp_t fp_version) 30 | 31 | LARGE_ = LARGE 32 | FP_1_ = FP_1 33 | FP_2_ = FP_2 34 | FP_DYNAMIC_ = FP_DYNAMIC 35 | 36 | 37 | @cython.boundscheck(False) 38 | @cython.wraparound(False) 39 | def lapjv(cnp.ndarray cost not None, char extend_cost=False, 40 | double cost_limit=np.inf, char return_cost=True): 41 | """Solve linear assignment problem using Jonker-Volgenant algorithm. 42 | 43 | Parameters 44 | ---------- 45 | cost: (N,N) ndarray 46 | Cost matrix. Entry `cost[i, j]` is the cost of assigning row `i` to 47 | column `j`. 48 | extend_cost: bool, optional 49 | Whether or not extend a non-square matrix. Default: False. 50 | cost_limit: double, optional 51 | An upper limit for a cost of a single assignment. Default: `np.inf`. 52 | return_cost: bool, optional 53 | Whether or not to return the assignment cost. 54 | 55 | Returns 56 | ------- 57 | opt: double 58 | Assignment cost. Not returned if `return_cost is False`. 59 | x: (N,) ndarray 60 | Assignment. `x[i]` specifies the column to which row `i` is assigned. 61 | y: (N,) ndarray 62 | Assignment. `y[j]` specifies the row to which column `j` is assigned. 63 | 64 | Notes 65 | ----- 66 | For non-square matrices (with `extend_cost is True`) or `cost_limit` set 67 | low enough, there will be unmatched rows, columns in the solution `x`, `y`. 68 | All such entries are set to -1. 69 | """ 70 | if cost.ndim != 2: 71 | raise ValueError('2-dimensional array expected') 72 | cdef cnp.ndarray[cnp.double_t, ndim=2, mode='c'] cost_c = \ 73 | np.ascontiguousarray(cost, dtype=np.double) 74 | cdef cnp.ndarray[cnp.double_t, ndim=2, mode='c'] cost_c_extended 75 | cdef uint_t n_rows = cost_c.shape[0] 76 | cdef uint_t n_cols = cost_c.shape[1] 77 | cdef uint_t n = 0 78 | if n_rows == n_cols: 79 | n = n_rows 80 | else: 81 | if not extend_cost: 82 | raise ValueError( 83 | 'Square cost array expected. If cost is intentionally ' 84 | 'non-square, pass extend_cost=True.') 85 | if extend_cost or cost_limit < np.inf: 86 | n = n_rows + n_cols 87 | cost_c_extended = np.empty((n, n), dtype=np.double) 88 | if cost_limit < np.inf: 89 | cost_c_extended[:] = cost_limit / 2. 90 | else: 91 | cost_c_extended[:] = cost_c.max() + 1 92 | cost_c_extended[n_rows:, n_cols:] = 0 93 | cost_c_extended[:n_rows, :n_cols] = cost_c 94 | cost_c = cost_c_extended 95 | 96 | cdef double **cost_ptr 97 | cost_ptr = malloc(n * sizeof(double *)) 98 | cdef int i 99 | for i in range(n): 100 | cost_ptr[i] = &cost_c[i, 0] 101 | 102 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] x_c = \ 103 | np.empty((n,), dtype=np.int32) 104 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] y_c = \ 105 | np.empty((n,), dtype=np.int32) 106 | 107 | cdef int ret = lapjv_internal(n, cost_ptr, &x_c[0], &y_c[0]) 108 | free(cost_ptr) 109 | if ret != 0: 110 | if ret == -1: 111 | raise MemoryError('Out of memory.') 112 | raise RuntimeError('Unknown error (lapjv_internal returned %d).' % ret) 113 | 114 | 115 | cdef double opt = np.nan 116 | if n != n_rows: 117 | x_c[x_c >= n_cols] = -1 118 | y_c[y_c >= n_rows] = -1 119 | x_c = x_c[:n_rows] 120 | y_c = y_c[:n_cols] 121 | if return_cost: 122 | opt = cost_c[np.nonzero(x_c != -1)[0], x_c[x_c != -1]].sum() 123 | elif return_cost: 124 | opt = cost_c[np.arange(n_rows), x_c].sum() 125 | 126 | if return_cost: 127 | return opt, x_c, y_c 128 | else: 129 | return x_c, y_c 130 | 131 | 132 | @cython.boundscheck(False) 133 | @cython.wraparound(False) 134 | def _lapmod( 135 | const uint_t n, 136 | cnp.ndarray cc not None, 137 | cnp.ndarray ii not None, 138 | cnp.ndarray kk not None, 139 | fp_t fp_version=FP_DYNAMIC): 140 | """Internal function called from lapmod(..., fast=True).""" 141 | cdef cnp.ndarray[cnp.double_t, ndim=1, mode='c'] cc_c = \ 142 | np.ascontiguousarray(cc, dtype=np.double) 143 | cdef cnp.ndarray[uint_t, ndim=1, mode='c'] ii_c = \ 144 | np.ascontiguousarray(ii, dtype=np.uint32) 145 | cdef cnp.ndarray[uint_t, ndim=1, mode='c'] kk_c = \ 146 | np.ascontiguousarray(kk, dtype=np.uint32) 147 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] x_c = \ 148 | np.empty((n,), dtype=np.int32) 149 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] y_c = \ 150 | np.empty((n,), dtype=np.int32) 151 | 152 | cdef int_t ret = lapmod_internal( 153 | n, &cc_c[0], &ii_c[0], &kk_c[0], 154 | &x_c[0], &y_c[0], fp_version) 155 | if ret != 0: 156 | if ret == -1: 157 | raise MemoryError('Out of memory.') 158 | raise RuntimeError('Unknown error (lapmod_internal returned %d).' % ret) 159 | 160 | return x_c, y_c 161 | -------------------------------------------------------------------------------- /Include/lap-master/lap/_lapjv.pyx: -------------------------------------------------------------------------------- 1 | # Tomas Kazmar, 2012-2017, BSD 2-clause license, see LICENSE. 2 | 3 | import numpy as np 4 | cimport numpy as cnp 5 | cimport cython 6 | from libc.stdlib cimport malloc, free 7 | 8 | 9 | cdef extern from "lapjv.h" nogil: 10 | ctypedef signed int int_t 11 | ctypedef unsigned int uint_t 12 | cdef int LARGE 13 | cdef enum fp_t: 14 | FP_1 15 | FP_2 16 | FP_DYNAMIC 17 | int lapjv_internal( 18 | const uint_t n, 19 | double *cost[], 20 | int_t *x, 21 | int_t *y) 22 | int lapmod_internal( 23 | const uint_t n, 24 | double *cc, 25 | uint_t *ii, 26 | uint_t *kk, 27 | int_t *x, 28 | int_t *y, 29 | fp_t fp_version) 30 | 31 | LARGE_ = LARGE 32 | FP_1_ = FP_1 33 | FP_2_ = FP_2 34 | FP_DYNAMIC_ = FP_DYNAMIC 35 | 36 | 37 | @cython.boundscheck(False) 38 | @cython.wraparound(False) 39 | def lapjv(cnp.ndarray cost not None, char extend_cost=False, 40 | double cost_limit=np.inf, char return_cost=True): 41 | """Solve linear assignment problem using Jonker-Volgenant algorithm. 42 | 43 | Parameters 44 | ---------- 45 | cost: (N,N) ndarray 46 | Cost matrix. Entry `cost[i, j]` is the cost of assigning row `i` to 47 | column `j`. 48 | extend_cost: bool, optional 49 | Whether or not extend a non-square matrix. Default: False. 50 | cost_limit: double, optional 51 | An upper limit for a cost of a single assignment. Default: `np.inf`. 52 | return_cost: bool, optional 53 | Whether or not to return the assignment cost. 54 | 55 | Returns 56 | ------- 57 | opt: double 58 | Assignment cost. Not returned if `return_cost is False`. 59 | x: (N,) ndarray 60 | Assignment. `x[i]` specifies the column to which row `i` is assigned. 61 | y: (N,) ndarray 62 | Assignment. `y[j]` specifies the row to which column `j` is assigned. 63 | 64 | Notes 65 | ----- 66 | For non-square matrices (with `extend_cost is True`) or `cost_limit` set 67 | low enough, there will be unmatched rows, columns in the solution `x`, `y`. 68 | All such entries are set to -1. 69 | """ 70 | if cost.ndim != 2: 71 | raise ValueError('2-dimensional array expected') 72 | cdef cnp.ndarray[cnp.double_t, ndim=2, mode='c'] cost_c = \ 73 | np.ascontiguousarray(cost, dtype=np.double) 74 | cdef cnp.ndarray[cnp.double_t, ndim=2, mode='c'] cost_c_extended 75 | cdef uint_t n_rows = cost_c.shape[0] 76 | cdef uint_t n_cols = cost_c.shape[1] 77 | cdef uint_t n = 0 78 | if n_rows == n_cols: 79 | n = n_rows 80 | else: 81 | if not extend_cost: 82 | raise ValueError( 83 | 'Square cost array expected. If cost is intentionally ' 84 | 'non-square, pass extend_cost=True.') 85 | if extend_cost or cost_limit < np.inf: 86 | n = n_rows + n_cols 87 | cost_c_extended = np.empty((n, n), dtype=np.double) 88 | if cost_limit < np.inf: 89 | cost_c_extended[:] = cost_limit / 2. 90 | else: 91 | cost_c_extended[:] = cost_c.max() + 1 92 | cost_c_extended[n_rows:, n_cols:] = 0 93 | cost_c_extended[:n_rows, :n_cols] = cost_c 94 | cost_c = cost_c_extended 95 | 96 | cdef double **cost_ptr 97 | cost_ptr = malloc(n * sizeof(double *)) 98 | cdef int i 99 | for i in range(n): 100 | cost_ptr[i] = &cost_c[i, 0] 101 | 102 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] x_c = \ 103 | np.empty((n,), dtype=np.int32) 104 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] y_c = \ 105 | np.empty((n,), dtype=np.int32) 106 | 107 | cdef int ret = lapjv_internal(n, cost_ptr, &x_c[0], &y_c[0]) 108 | free(cost_ptr) 109 | if ret != 0: 110 | if ret == -1: 111 | raise MemoryError('Out of memory.') 112 | raise RuntimeError('Unknown error (lapjv_internal returned %d).' % ret) 113 | 114 | 115 | cdef double opt = np.nan 116 | if n != n_rows: 117 | x_c[x_c >= n_cols] = -1 118 | y_c[y_c >= n_rows] = -1 119 | x_c = x_c[:n_rows] 120 | y_c = y_c[:n_cols] 121 | if return_cost: 122 | opt = cost_c[np.nonzero(x_c != -1)[0], x_c[x_c != -1]].sum() 123 | elif return_cost: 124 | opt = cost_c[np.arange(n_rows), x_c].sum() 125 | 126 | if return_cost: 127 | return opt, x_c, y_c 128 | else: 129 | return x_c, y_c 130 | 131 | 132 | @cython.boundscheck(False) 133 | @cython.wraparound(False) 134 | def _lapmod( 135 | const uint_t n, 136 | cnp.ndarray cc not None, 137 | cnp.ndarray ii not None, 138 | cnp.ndarray kk not None, 139 | fp_t fp_version=FP_DYNAMIC): 140 | """Internal function called from lapmod(..., fast=True).""" 141 | cdef cnp.ndarray[cnp.double_t, ndim=1, mode='c'] cc_c = \ 142 | np.ascontiguousarray(cc, dtype=np.double) 143 | cdef cnp.ndarray[uint_t, ndim=1, mode='c'] ii_c = \ 144 | np.ascontiguousarray(ii, dtype=np.uint32) 145 | cdef cnp.ndarray[uint_t, ndim=1, mode='c'] kk_c = \ 146 | np.ascontiguousarray(kk, dtype=np.uint32) 147 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] x_c = \ 148 | np.empty((n,), dtype=np.int32) 149 | cdef cnp.ndarray[int_t, ndim=1, mode='c'] y_c = \ 150 | np.empty((n,), dtype=np.int32) 151 | 152 | cdef int_t ret = lapmod_internal( 153 | n, &cc_c[0], &ii_c[0], &kk_c[0], 154 | &x_c[0], &y_c[0], fp_version) 155 | if ret != 0: 156 | if ret == -1: 157 | raise MemoryError('Out of memory.') 158 | raise RuntimeError('Unknown error (lapmod_internal returned %d).' % ret) 159 | 160 | return x_c, y_c 161 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\sample.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\sample.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /Include/lap-master/lap/tests/test_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | from gzip import GzipFile 4 | 5 | 6 | def make_hard(cost, lo, hi): 7 | hard = cost.copy() 8 | for row in range(hard.shape[0]): 9 | hard[row, :] += np.random.randint(lo, hi) 10 | for col in range(hard.shape[1]): 11 | hard[:, col] += np.random.randint(lo, hi) 12 | return hard 13 | 14 | 15 | def get_dense_8x8_int(): 16 | cost = np.array([[1000, 2, 11, 10, 8, 7, 6, 5], 17 | [6, 1000, 1, 8, 8, 4, 6, 7], 18 | [5, 12, 1000, 11, 8, 12, 3, 11], 19 | [11, 9, 10, 1000, 1, 9, 8, 10], 20 | [11, 11, 9, 4, 1000, 2, 10, 9], 21 | [12, 8, 5, 2, 11, 1000, 11, 9], 22 | [10, 11, 12, 10, 9, 12, 1000, 3], 23 | [10, 10, 10, 10, 6, 3, 1, 1000]]) 24 | opt = 17. 25 | return cost, opt 26 | 27 | 28 | def get_dense_int(sz, rng, hard=True, seed=1299821): 29 | np.random.seed(seed) 30 | cost = np.random.randint(1, rng+1, size=(sz, sz)) 31 | if hard is True: 32 | cost = make_hard(cost, 0, rng) 33 | return cost 34 | 35 | 36 | def get_sparse_int(sz, rng, sparsity, hard=True, seed=1299821): 37 | np.random.seed(seed) 38 | cost = np.random.randint(1, rng+1, size=(sz, sz)) 39 | if hard is True: 40 | cost = make_hard(cost, 0, rng) 41 | mask = np.random.rand(sz, sz) 42 | thresh = np.percentile( 43 | mask.flat, max(0, (sparsity - sz/float(sz*sz)) * 100.)) 44 | mask = mask < thresh 45 | # Make sure there exists a solution. 46 | row = np.random.permutation(sz) 47 | col = np.random.permutation(sz) 48 | mask[row, col] = True 49 | return cost, mask 50 | 51 | 52 | def get_nnz_int(sz, nnz, rng=100, seed=1299821): 53 | np.random.seed(seed) 54 | cc = np.random.randint(1, rng+1, size=(sz*nnz,)) 55 | ii = np.empty((sz + 1,), dtype=np.int32) 56 | ii[0] = 0 57 | ii[1:] = nnz 58 | ii = np.cumsum(ii) 59 | kk = np.empty((sz, nnz), dtype=np.int32) 60 | # Make sure there exists a solution. 61 | kk[:, 0] = np.random.permutation(sz) 62 | for row in range(sz): 63 | p = np.random.permutation(sz)[:nnz] 64 | if kk[row, 0] in p: 65 | kk[row, :] = p 66 | else: 67 | kk[row, 1:] = p[:-1] 68 | # Column indices must be sorted within each row. 69 | kk = np.sort(kk, axis=1).flatten() 70 | assert len(cc) == sz * nnz 71 | assert len(kk) 72 | assert np.all(kk >= 0) 73 | assert np.all(kk < sz) 74 | return cc, ii, kk 75 | 76 | 77 | def get_dense_100x100_int(): 78 | cost = get_dense_int(100, 100, hard=False, seed=1299821) 79 | opt = 198. 80 | return cost, opt 81 | 82 | 83 | def get_dense_100x100_int_hard(): 84 | cost = get_dense_int(100, 100, hard=True, seed=1299821) 85 | opt = 11399. 86 | return cost, opt 87 | 88 | 89 | def get_sparse_100x100_int(): 90 | cost, mask = get_sparse_int(100, 100, 0.04, seed=1299821) 91 | opt = 11406 92 | return cost, np.logical_not(mask), opt 93 | 94 | 95 | def get_dense_1kx1k_int(): 96 | cost = get_dense_int(1000, 100, hard=False, seed=1299821) 97 | opt = 1000. 98 | return cost, opt 99 | 100 | 101 | def get_dense_1kx1k_int_hard(): 102 | cost = get_dense_int(1000, 100, hard=True, seed=1299821) 103 | opt = 101078.0 104 | return cost, opt 105 | 106 | 107 | def get_sparse_1kx1k_int(): 108 | cost, mask = get_sparse_int(1000, 100, 0.01, seed=1299821) 109 | opt = 101078 110 | return cost, np.logical_not(mask), opt 111 | 112 | 113 | def get_dense_4kx4k_int(): 114 | cost = get_dense_int(4000, 100, hard=False, seed=1299821) 115 | opt = 1000. 116 | return cost, opt 117 | 118 | 119 | def get_sparse_4kx4k_int(): 120 | cost, mask = get_sparse_int(4000, 100, 0.004, seed=1299821) 121 | opt = 402541 122 | return cost, np.logical_not(mask), opt 123 | 124 | 125 | # Thanks to Michael Lewis for providing this cost matrix. 126 | def get_dense_eps(): 127 | from pytest import approx 128 | datadir = os.path.abspath(os.path.dirname(__file__)) 129 | filename = os.path.join(datadir, 'cost_eps.csv.gz') 130 | cost = np.genfromtxt(GzipFile(filename), delimiter=",") 131 | opt = approx(224.8899507294651, 0.0000000000001) 132 | return cost, opt 133 | 134 | 135 | def sparse_from_dense(cost): 136 | cc = cost.flatten() 137 | n_rows = cost.shape[0] 138 | n_columns = cost.shape[1] 139 | ii = np.empty((n_rows+1,), dtype=int) 140 | ii[0] = 0 141 | ii[1:] = n_columns 142 | ii = np.cumsum(ii) 143 | kk = np.tile(np.arange(n_columns, dtype=int), n_rows) 144 | return n_rows, cc, ii, kk 145 | 146 | 147 | def sparse_from_masked(cost, mask=None): 148 | if mask is None: 149 | mask = np.logical_not(np.isinf(cost)) 150 | cc = cost[mask].flatten() 151 | n_rows = cost.shape[0] 152 | n_columns = cost.shape[1] 153 | ii = np.empty((n_rows+1,), dtype=int) 154 | ii[0] = 0 155 | ii[1:] = mask.sum(axis=1) 156 | ii = np.cumsum(ii) 157 | kk = np.tile(np.arange(n_columns, dtype=int), cost.shape[0]) 158 | kk = kk[mask.flatten()] 159 | return n_rows, cc, ii, kk 160 | 161 | 162 | def sparse_from_dense_CS(cost): 163 | i = np.tile( 164 | np.atleast_2d(np.arange(cost.shape[0])).T, 165 | cost.shape[1]).flatten() 166 | j = np.tile(np.arange(cost.shape[1]), cost.shape[0]) 167 | cc = cost.flatten() 168 | return i, j, cc 169 | 170 | 171 | def sparse_from_masked_CS(cost, mask): 172 | i = np.tile( 173 | np.atleast_2d(np.arange(cost.shape[0])).T, 174 | cost.shape[1])[mask] 175 | j = np.tile(np.arange(cost.shape[1]), cost.shape[0])[mask.flat] 176 | cc = cost[mask].flatten() 177 | return i, j, cc 178 | 179 | 180 | def get_cost_CS(cost, x): 181 | return cost[np.arange(cost.shape[0]), x].sum() 182 | 183 | 184 | def get_platform_maxint(): 185 | import struct 186 | return 2 ** (struct.Struct('i').size * 8 - 1) - 1 187 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mission Planning & Task Allocation - Team A (Cranfield University) 2 | 3 | ### Description 4 | This Software Project was created as part of a UAV Swarm Project in which a Cranfield Student Team participated in the BAE Systems UAV Swarm Challenge. The software contains the Mission Control and Task Allocation system, which was utilized to orchestrate the UAV Swarm. The system is embedded in a ROS Framework, which can communicate with other Subsytems such as the Agent's Autopilot and the Situational Awareness Systems (these software parts are not part of this repository). The Software can process the receiving data from Situational awareness (current Agent and Enemy information) and use a combinatorial optimization approach to choose suitable countermeasures against incoming threads. 5 | 6 | You can find the related publication on: [A Mission Planning and Task Allocation Framework For Multi-UAV Swarm Coordination](https://ieeexplore.ieee.org/document/8999708) 7 | 8 | #### Task Allocation Approach 9 | 10 | The dynamic task allocation approach decomposes complex multi-task missions into single tasks. This simplifies the assignment problem from a complex optimization to a problem that can be solved in an optimal manner with linear programming approaches. To solve this optimization problem following algorithms are implemented: 11 | * Kuhn–Munkres Algorithm 12 | * Jonker-Volgenant Algorithm 13 | * Stable-Marriage Algorithm 14 | 15 | The default Algorithm for the System is the Kuhn–Munkres Algorithm since it is ensured that it delivers the optimal solution in a polynomial time. The Jonker-Volgenant Algorithm is implemented as an alternative since it has the potential to solve the problem with sufficient accuracy by having a lower computational complexity than the Kuhn–Munkres Algorithm. Nevertheless, if that algorithm is currently under testing, it will be implemented in future releases. The stable marriage algorithm is not under use anymore since both the Jonker-Volgenant and the Jonker-Volgenant Algorithm deliver better results in terms of a cost-optimal solution. 16 | 17 | #### Mission Concept 18 | 19 | The full mission was separated into 3 stages: 20 | * Stage 1: Agent Setup 21 | * Stage 2: Asset Protection (Dynamic Task Allocation) 22 | * Stage 3: Landing 23 | 24 | The distinct stages are implemented as a state machine that uses defined trigger parameters to transit from one stage to another. Inside stage 1 and stage 3, sub-state machines are implemented, which ensure the correct agent workflows in those stages. Stage 2 is fully dynamic and only uses a dynamic task allocation approach, as explained prior. 25 | 26 |

27 | Statemachine_main 28 |

29 | 30 | #### Task Manager 31 | To create a fully autonomous mission system, a task manager system has been implemented. The task manager is an independent software system that is able to recognize task assignments and monitor their progress. That is the process of computing a reward for each waypoint or attack task progress of the agents. When it is recognized that the reward is not increasing over a defined time window, the assigned task is getting aborted. The same applies to task execution that exceeds a certain time window. The time window for each assigned task is individually defined based on the task type, distance, and flying speed. 32 | 33 |

34 | System_Overview 35 |

36 | 37 | 38 | #### Graphical User Interface 39 | 40 | The GUI was created to simplify the mission overview for the user during the competition. The GUI-System is fully integrated into the ROS Network System and is listening to the exchanged messages. Received information is displayed for the user in a Mission Window based on the PyQT framework. 41 | 42 |

43 | MISSION_GUI 44 |

45 | 46 | 47 | 48 | ## Dependencies 49 | 50 | The software system us using external libraries which needs to be installed. 51 | 52 | Install Rospy for Pyton 3.6: 53 | 54 | sudo pip3 install -U rospkg 55 | sudo pip3 install roslibpy 56 | sudo apt-get install python3-yaml 57 | sudo pip3 install rospkg catkin_pkg 58 | 59 | Install PyQt, PyUic4 and PyRcc4: 60 | 61 | sudo apt-get install pyqt4-dev-tools qt4-designer 62 | 63 | 64 | **The software was tested under Linux Ubuntu Versions 16.04.6 LTS and 18.04.2 LTS*-** 65 | 66 | ### Usage 67 | 68 | This Software system is using ROS for that reason it needs to be integrated into a Robot Operating System Framework. If not already exist, a working ROS Workspace needs to be created. If that is the case, please go first to your workspace. 69 | 70 | # Go to your ROS Workspace Directory 71 | $ cd ~/your_ros_workspace 72 | 73 | The next step is to clone this github repository and use it as a new package: 74 | 75 | $ git clone https://github.com/JohannesAutenrieb/mission_planning.git ./src/mission_planning 76 | 77 | The system is built with: 78 | 79 | #Building all ROS packages 80 | $ catkin_make 81 | 82 | To have a functional Task Allocation system the system needs initial agent information to start. When the system is not embedded in the complete ROS environment, the publisher.py can be used to fake the swarm: 83 | 84 | # fakes a swarm environment with 5 agents and 2 moving targets 85 | $ rosrun mission_planning publisher.py 86 | 87 | The task allocation software is started with: 88 | 89 | $ rosrun mission_planning Main.py 90 | 91 | The task manager software is started with: 92 | 93 | $ rosrun mission_planning TaskManager.py 94 | 95 | When it is wanted to display the mission via the gui, the gui can started with: 96 | 97 | $ rosrun mission_planning GUI.py 98 | 99 | 100 | License 101 | ------- 102 | 103 | Released under the 2-clause GPL GNU license, see `LICENSE`. 104 | 105 | Copyright (C) 2019, Johannes Autenrieb and Natalia Strawa 106 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sample.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/sample" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /scripts/GUI.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from PyQt4 import QtGui, QtCore # Import the PyQt4 module we'll need 3 | import sys # We need sys so that we can pass argv to QApplication 4 | import rospy 5 | import time 6 | import output # This file holds our MainWindow and all design related things 7 | # it also keeps events etc that we defined in Qt Designer 8 | from mission_planning.msg import TaskMessage, AgentInfo, SwarmInfo 9 | 10 | class ExampleApp(QtGui.QMainWindow, output.Ui_MissionOverview): 11 | def __init__(self, parent=None): 12 | # Explaining super is out of the scope of this article 13 | # So please google it if you're not familar with it 14 | # Simple reason why we use it here is that it allows us to 15 | # access variables, methods etc in the design.py file 16 | super(self.__class__, self).__init__() 17 | self.setupUi(self) # This is defined in design.py file automatically 18 | # It sets up layout and widgets that are defined 19 | 20 | self.taskText= str() 21 | self.taskList = [] 22 | 23 | # Set total mission time in seconds 24 | self.startTime=time.time() 25 | self.missionTime=600 26 | self.endTime=self.startTime+self.missionTime 27 | #Static: Used for progress estimation 28 | self.totalMissionTime=1000 29 | 30 | def callbackFriend(self, msg): 31 | 32 | # Extract friends information from message 33 | dataFriend = msg.friendlies 34 | 35 | # Iter over list of messages 36 | for i in range(0, len(dataFriend)): 37 | # If agent is not on the list, append new agent object 38 | if(dataFriend[i].agentId==1): 39 | self.lineEdit_TID_A1.setText(str(dataFriend[i].agentTaskId)) 40 | self.lineEdit_TS_A1.setText(str(dataFriend[i].agentTaskStatus)) 41 | self.lineEdit_WS_A1.setText(str(dataFriend[i].agentWorkingStatus)) 42 | self.lineEdit_Pos_A1.setText(str(dataFriend[i].agentPosition)) 43 | #self.lineEdit_Vel_A1.setText(str(dataFriend[i].agentTaskStatus)) 44 | self.lineEdit_Pay_A1.setText(str(dataFriend[i].agentPayload)) 45 | self.lineEdit_Bat_A1.setText(str(dataFriend[i].agentBattery)) 46 | # 47 | if(dataFriend[i].agentId==2): 48 | self.lineEdit_TID_A2.setText(str(dataFriend[i].agentTaskId)) 49 | self.lineEdit_TS_A2.setText(str(dataFriend[i].agentTaskStatus)) 50 | self.lineEdit_WS_A2.setText(str(dataFriend[i].agentWorkingStatus)) 51 | self.lineEdit_Pos_A2.setText(str(dataFriend[i].agentPosition)) 52 | #self.lineEdit_Vel_A1.setText(str(dataFriend[i].agentTaskStatus)) 53 | self.lineEdit_Pay_A2.setText(str(dataFriend[i].agentPayload)) 54 | self.lineEdit_Bat_A2.setText(str(dataFriend[i].agentBattery)) 55 | # 56 | if(dataFriend[i].agentId==3): 57 | self.lineEdit_TID_A3.setText(str(dataFriend[i].agentTaskId)) 58 | self.lineEdit_TS_A3.setText(str(dataFriend[i].agentTaskStatus)) 59 | self.lineEdit_WS_A3.setText(str(dataFriend[i].agentWorkingStatus)) 60 | self.lineEdit_Pos_A3.setText(str(dataFriend[i].agentPosition)) 61 | #self.lineEdit_Vel_A1.setText(str(dataFriend[i].agentTaskStatus)) 62 | self.lineEdit_Pay_A3.setText(str(dataFriend[i].agentPayload)) 63 | self.lineEdit_Bat_A3.setText(str(dataFriend[i].agentBattery)) 64 | # 65 | if(dataFriend[i].agentId==4): 66 | self.lineEdit_TID_A4.setText(str(dataFriend[i].agentTaskId)) 67 | self.lineEdit_TS_A4.setText(str(dataFriend[i].agentTaskStatus)) 68 | self.lineEdit_WS_A4.setText(str(dataFriend[i].agentWorkingStatus)) 69 | self.lineEdit_Pos_A4.setText(str(dataFriend[i].agentPosition)) 70 | #self.lineEdit_Vel_A1.setText(str(dataFriend[i].agentTaskStatus)) 71 | self.lineEdit_Pay_A4.setText(str(dataFriend[i].agentPayload)) 72 | self.lineEdit_Bat_A4.setText(str(dataFriend[i].agentBattery)) 73 | # 74 | 75 | # Extract foos information from message 76 | dataFoo = msg.enemies 77 | self.testString=str() 78 | for i in range(0, len(dataFoo)): 79 | self.testEnemies="EnemyID: {} Position: {} Velocity: {} Confidence: {} \n \n".format(msg.enemies[i].agentId,msg.enemies[i].agentPosition,msg.enemies[i].agentVelocity,msg.enemies[i].confidence) 80 | self.testString=self.testString+self.testEnemies 81 | self.label_enemies.setText(self.testString) 82 | del self.testString 83 | 84 | #Timer 85 | self. currentTime= time.time() 86 | self.delta = int(self.endTime - self.currentTime) 87 | mins, secs = divmod(self.delta, 60) 88 | self.timeformat = '{:02d}:{:02d}'.format(mins, secs) 89 | #print(str(self.timeformat)) 90 | self.lineEdit_time.setText(str(self.timeformat)) 91 | 92 | self.string= "{0:.0%}".format((self.endTime - self.currentTime)/self.missionTime) 93 | self.label_progress.setText(self.string) 94 | 95 | # Callback for adding new tasks to current Database 96 | def callbackTaskMessages(self, msg): 97 | 98 | self.taskText=msg 99 | self.task="AgentID: {} TaskID: {} Waypoint: {} \n \n".format(msg.agentId,msg.taskId,msg.taskLocation) 100 | self.label_task_histo.setText(self.task) 101 | 102 | 103 | def updater(self): 104 | 105 | #update countdown timer 106 | mins, secs = divmod(self.missionTime, 60) 107 | self.timeformat = '{:02d}:{:02d}'.format(mins, secs) 108 | #print(str(self.timeformat)) 109 | self.lineEdit_time.setText(str(self.timeformat)) 110 | # Count one second down 111 | self.missionTime -= 1 112 | 113 | 114 | if __name__ == '__main__': 115 | # Setup System 116 | app = QtGui.QApplication(sys.argv) 117 | form = ExampleApp() 118 | 119 | # Init of ROS Listener Node 120 | rospy.init_node('MissionDisplayer', anonymous=True) 121 | 122 | # Init Listener for friend and foos 123 | rospy.Subscriber("SwarmInformation", SwarmInfo, form.callbackFriend) 124 | 125 | # Init Listener to Task Topic 126 | rospy.Subscriber('TaskAction', TaskMessage, form.callbackTaskMessages) 127 | #Execute the GUI 128 | form.show() 129 | app.exec_() 130 | # Timer for Time Measurement 131 | timer = QtCore.QTimer() 132 | timer.timeout.connect(form.updater) 133 | timer.setInterval(500) 134 | timer.start() -------------------------------------------------------------------------------- /Include/python-statemachine/tests/test_multiple_destinations.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | from __future__ import absolute_import, unicode_literals 3 | 4 | import pytest 5 | import mock 6 | 7 | from statemachine import StateMachine, State, exceptions 8 | 9 | 10 | def test_transition_should_choose_final_state_on_multiple_possibilities( 11 | approval_machine, current_time): 12 | # given 13 | model = mock.MagicMock( 14 | state='requested', 15 | accepted_at=None, 16 | rejected_at=None, 17 | completed_at=None, 18 | ) 19 | machine = approval_machine(model) 20 | 21 | model.is_ok.return_value = False 22 | 23 | # when 24 | assert machine.validate() == model 25 | 26 | # then 27 | assert model.rejected_at == current_time 28 | assert machine.is_rejected 29 | 30 | # given 31 | model.is_ok.return_value = True 32 | 33 | # when 34 | assert machine.retry() == model 35 | 36 | # then 37 | assert model.rejected_at is None 38 | assert machine.is_requested 39 | 40 | # when 41 | assert machine.validate() == model 42 | 43 | # then 44 | assert model.accepted_at == current_time 45 | assert machine.is_accepted 46 | 47 | 48 | def test_should_raise_error_if_not_define_callback_in_multiple_destinations(): 49 | class ApprovalMachine(StateMachine): 50 | "A workflow" 51 | requested = State('Requested', initial=True) 52 | accepted = State('Accepted') 53 | rejected = State('Rejected') 54 | 55 | validate = requested.to(accepted, rejected) 56 | 57 | machine = ApprovalMachine() 58 | 59 | with pytest.raises(exceptions.MultipleStatesFound) as e: 60 | machine.validate() 61 | 62 | assert 'desired state' in e.message 63 | 64 | 65 | @pytest.mark.parametrize('return_value, expected_exception', [ 66 | (None, exceptions.MultipleStatesFound), 67 | (1, exceptions.MultipleStatesFound), 68 | ((2, 3), exceptions.MultipleStatesFound), 69 | ((4, 5, 6), exceptions.MultipleStatesFound), 70 | (((7, 8), 9), exceptions.MultipleStatesFound), 71 | ('requested', exceptions.InvalidDestinationState), 72 | ]) 73 | def test_should_raise_error_if_not_inform_state_in_multiple_destinations( 74 | return_value, expected_exception): 75 | class ApprovalMachine(StateMachine): 76 | "A workflow" 77 | requested = State('Requested', initial=True) 78 | accepted = State('Accepted') 79 | rejected = State('Rejected') 80 | 81 | @requested.to(accepted, rejected) 82 | def validate(self): 83 | "tries to get an attr (like a desired state), failsback to the `return_value` itself" 84 | return getattr(self, str(return_value), return_value) 85 | 86 | machine = ApprovalMachine() 87 | 88 | with pytest.raises(expected_exception) as e: 89 | machine.validate() 90 | 91 | assert 'desired state' in e.message 92 | 93 | 94 | @pytest.mark.parametrize('callback', ['single', 'multiple']) 95 | @pytest.mark.parametrize('with_return_value', [True, False], ids=['with_return', 'without_return']) 96 | @pytest.mark.parametrize('return_value', [None, 'spam']) 97 | def test_should_transition_to_the_state_returned_by_callback( 98 | callback, with_return_value, return_value): 99 | class ApprovalMachine(StateMachine): 100 | "A workflow" 101 | requested = State('Requested', initial=True) 102 | accepted = State('Accepted') 103 | rejected = State('Rejected') 104 | 105 | @requested.to(accepted) 106 | def transition_with_single_destination(self): 107 | if with_return_value: 108 | return return_value, self.accepted 109 | else: 110 | return self.accepted 111 | 112 | @requested.to(accepted, rejected) 113 | def transition_with_multiple_destination(self): 114 | if with_return_value: 115 | return return_value, self.accepted 116 | else: 117 | return self.accepted 118 | 119 | machine = ApprovalMachine() 120 | 121 | transition = 'transition_with_{}_destination'.format(callback) 122 | 123 | result = machine.run(transition) 124 | if with_return_value: 125 | assert result == return_value 126 | else: 127 | assert result is None 128 | assert machine.is_accepted 129 | 130 | 131 | def test_should_change_to_returned_state_on_multiple_destination_with_combined_transitions(): 132 | class ApprovalMachine(StateMachine): 133 | "A workflow" 134 | requested = State('Requested', initial=True) 135 | accepted = State('Accepted') 136 | rejected = State('Rejected') 137 | completed = State('Completed') 138 | 139 | validate = requested.to(accepted, rejected) | accepted.to(completed) 140 | retry = rejected.to(requested) 141 | 142 | @validate 143 | def do_validate(self): 144 | if not self.is_accepted: 145 | if self.model.is_ok(): 146 | return self.accepted 147 | else: 148 | return self.rejected 149 | else: 150 | return 'congrats!' 151 | 152 | # given 153 | model = mock.MagicMock(state='requested') 154 | machine = ApprovalMachine(model) 155 | 156 | model.is_ok.return_value = False 157 | 158 | # when 159 | assert machine.validate() is None 160 | # then 161 | assert machine.is_rejected 162 | 163 | # given 164 | assert machine.retry() is None 165 | assert machine.is_requested 166 | model.is_ok.return_value = True 167 | 168 | # when 169 | assert machine.validate() is None 170 | # then 171 | assert machine.is_accepted 172 | 173 | # when 174 | assert machine.validate() == 'congrats!' 175 | # then 176 | assert machine.is_completed 177 | 178 | with pytest.raises(exceptions.TransitionNotAllowed) as e: 179 | assert machine.validate() 180 | assert e.message == "Can't validate when in Completed." 181 | 182 | 183 | def test_transition_on_execute_should_be_called_with_run_syntax(approval_machine, current_time): 184 | # given 185 | model = mock.MagicMock(state='requested', accepted_at=None,) 186 | machine = approval_machine(model) 187 | 188 | model.is_ok.return_value = True 189 | 190 | # when 191 | assert machine.run('validate') == model 192 | # then 193 | assert model.accepted_at == current_time 194 | assert machine.is_accepted 195 | 196 | 197 | def test_multiple_transition_callbacks(): 198 | class ApprovalMachine(StateMachine): 199 | "A workflow" 200 | requested = State('Requested', initial=True) 201 | accepted = State('Accepted') 202 | 203 | @requested.to(accepted) 204 | def validate(self): 205 | return self.accepted 206 | 207 | def on_validate(self): 208 | return self.accepted 209 | 210 | machine = ApprovalMachine() 211 | 212 | with pytest.raises(exceptions.MultipleTransitionCallbacksFound): 213 | machine.validate() 214 | -------------------------------------------------------------------------------- /Include/python-statemachine/README.rst: -------------------------------------------------------------------------------- 1 | ==================== 2 | Python State Machine 3 | ==================== 4 | 5 | 6 | .. image:: https://img.shields.io/pypi/v/python-statemachine.svg 7 | :target: https://pypi.python.org/pypi/python-statemachine 8 | 9 | .. image:: https://travis-ci.org/fgmacedo/python-statemachine.svg?branch=master 10 | :target: https://travis-ci.org/fgmacedo/python-statemachine 11 | :alt: Build status 12 | 13 | .. image:: https://codecov.io/gh/fgmacedo/python-statemachine/branch/master/graph/badge.svg 14 | :target: https://codecov.io/gh/fgmacedo/python-statemachine 15 | :alt: Coverage report 16 | 17 | .. image:: https://readthedocs.org/projects/python-statemachine/badge/?version=latest 18 | :target: https://python-statemachine.readthedocs.io/en/latest/?badge=latest 19 | :alt: Documentation Status 20 | 21 | .. image:: https://pyup.io/repos/github/fgmacedo/python-statemachine/shield.svg 22 | :target: https://pyup.io/repos/github/fgmacedo/python-statemachine/ 23 | :alt: Updates 24 | 25 | .. image:: https://badges.gitter.im/fgmacedo/python-statemachine.svg 26 | :alt: Join the chat at https://gitter.im/fgmacedo/python-statemachine 27 | :target: https://gitter.im/fgmacedo/python-statemachine 28 | 29 | 30 | Python `finite-state machines `_ made easy. 31 | 32 | 33 | * Free software: MIT license 34 | * Documentation: https://python-statemachine.readthedocs.io. 35 | 36 | 37 | Getting started 38 | =============== 39 | 40 | To install Python State Machine, run this command in your terminal: 41 | 42 | .. code-block:: console 43 | 44 | $ pip install python-statemachine 45 | 46 | 47 | Define your state machine: 48 | 49 | .. code-block:: python 50 | 51 | from statemachine import StateMachine, State 52 | 53 | class TrafficLightMachine(StateMachine): 54 | green = State('Green', initial=True) 55 | yellow = State('Yellow') 56 | red = State('Red') 57 | 58 | slowdown = green.to(yellow) 59 | stop = yellow.to(red) 60 | go = red.to(green) 61 | 62 | 63 | You can now create an instance: 64 | 65 | >>> traffic_light = TrafficLightMachine() 66 | 67 | And inspect about the current state: 68 | 69 | >>> traffic_light.current_state 70 | State('Green', identifier='green', value='green', initial=True) 71 | >>> traffic_light.current_state == TrafficLightMachine.green == traffic_light.green 72 | True 73 | 74 | For each state, there's a dinamically created property in the form ``is_``, that 75 | returns ``True`` if the current status matches the query: 76 | 77 | >>> traffic_light.is_green 78 | True 79 | >>> traffic_light.is_yellow 80 | False 81 | >>> traffic_light.is_red 82 | False 83 | 84 | Query about metadata: 85 | 86 | >>> [s.identifier for s in m.states] 87 | ['green', 'red', 'yellow'] 88 | >>> [t.identifier for t in m.transitions] 89 | ['go', 'slowdown', 'stop'] 90 | 91 | Call a transition: 92 | 93 | >>> traffic_light.slowdown() 94 | 95 | And check for the current status: 96 | 97 | >>> traffic_light.current_state 98 | State('Yellow', identifier='yellow', value='yellow', initial=False) 99 | >>> traffic_light.is_yellow 100 | True 101 | 102 | You can't run a transition from an invalid state: 103 | 104 | >>> traffic_light.is_yellow 105 | True 106 | >>> traffic_light.slowdown() 107 | Traceback (most recent call last): 108 | ... 109 | LookupError: Can't slowdown when in Yellow. 110 | 111 | You can also trigger events in an alternative way, calling the ``run()`` method: 112 | 113 | >>> traffic_light.is_yellow 114 | True 115 | >>> traffic_light.run('stop') 116 | >>> traffic_light.is_red 117 | True 118 | 119 | A state machine can be instantiated with an initial value: 120 | 121 | >>> machine = TrafficLightMachine(start_value='red') 122 | >>> traffic_light.is_red 123 | True 124 | 125 | 126 | Models 127 | ------ 128 | 129 | If you need to persist the current state on another object, or you're using the 130 | state machine to control the flow of another object, you can pass this object 131 | to the ``StateMachine`` constructor: 132 | 133 | >>> class MyModel(object): 134 | ... def __init__(self, state): 135 | ... self.state = state 136 | ... 137 | >>> obj = MyModel(state='red') 138 | >>> traffic_light = TrafficLightMachine(obj) 139 | >>> traffic_light.is_red 140 | True 141 | >>> obj.state 142 | 'red' 143 | >>> obj.state = 'green' 144 | >>> traffic_light.is_green 145 | True 146 | >>> traffic_light.slowdown() 147 | >>> obj.state 148 | 'yellow' 149 | >>> traffic_light.is_yellow 150 | True 151 | 152 | 153 | Callbacks 154 | --------- 155 | 156 | Callbacks when running events: 157 | 158 | .. code-block:: python 159 | 160 | from statemachine import StateMachine, State 161 | 162 | class TrafficLightMachine(StateMachine): 163 | "A traffic light machine" 164 | green = State('Green', initial=True) 165 | yellow = State('Yellow') 166 | red = State('Red') 167 | 168 | slowdown = green.to(yellow) 169 | stop = yellow.to(red) 170 | go = red.to(green) 171 | 172 | def on_slowdown(self): 173 | print('Calma, lá!') 174 | 175 | def on_stop(self): 176 | print('Parou.') 177 | 178 | def on_go(self): 179 | print('Valendo!') 180 | 181 | 182 | >>> stm = TrafficLightMachine() 183 | >>> stm.slowdown() 184 | Calma, lá! 185 | >>> stm.stop() 186 | Parou. 187 | >>> stm.go() 188 | Valendo! 189 | 190 | 191 | Or when entering/exiting states: 192 | 193 | .. code-block:: python 194 | 195 | from statemachine import StateMachine, State 196 | 197 | class TrafficLightMachine(StateMachine): 198 | "A traffic light machine" 199 | green = State('Green', initial=True) 200 | yellow = State('Yellow') 201 | red = State('Red') 202 | 203 | cycle = green.to(yellow) | yellow.to(red) | red.to(green) 204 | 205 | def on_enter_green(self): 206 | print('Valendo!') 207 | 208 | def on_enter_yellow(self): 209 | print('Calma, lá!') 210 | 211 | def on_enter_red(self): 212 | print('Parou.') 213 | 214 | >>> stm = TrafficLightMachine() 215 | >>> stm.cycle() 216 | Calma, lá! 217 | >>> stm.cycle() 218 | Parou. 219 | >>> stm.cycle() 220 | Valendo! 221 | 222 | Mixins 223 | ------ 224 | 225 | Your model can inherited from a custom mixin to auto-instantiate a state machine. 226 | 227 | .. code-block:: python 228 | 229 | class CampaignMachineWithKeys(StateMachine): 230 | "A workflow machine" 231 | draft = State('Draft', initial=True, value=1) 232 | producing = State('Being produced', value=2) 233 | closed = State('Closed', value=3) 234 | 235 | add_job = draft.to.itself() | producing.to.itself() 236 | produce = draft.to(producing) 237 | deliver = producing.to(closed) 238 | 239 | 240 | class MyModel(MachineMixin): 241 | state_machine_name = 'CampaignMachine' 242 | 243 | def __init__(self, **kwargs): 244 | for k, v in kwargs.items(): 245 | setattr(self, k, v) 246 | super(MyModel, self).__init__() 247 | 248 | def __repr__(self): 249 | return "{}({!r})".format(type(self).__name__, self.__dict__) 250 | 251 | 252 | model = MyModel(state='draft') 253 | assert isinstance(model.statemachine, campaign_machine) 254 | assert model.state == 'draft' 255 | assert model.statemachine.current_state == model.statemachine.draft 256 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/statemachine.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/statemachine.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/statemachine" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/statemachine" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /Include/python-statemachine/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\statemachine.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\statemachine.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(mission_planning) 3 | 4 | ## Compile as C++11, supported in ROS Kinetic and newer 5 | # add_compile_options(-std=c++11) 6 | 7 | ## Find catkin macros and libraries 8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) 9 | ## is used, also find other catkin packages 10 | find_package(catkin REQUIRED COMPONENTS 11 | rospy 12 | std_msgs 13 | message_generation 14 | ) 15 | 16 | ## System dependencies are found with CMake's conventions 17 | # find_package(Boost REQUIRED COMPONENTS system) 18 | 19 | ## Uncomment this if the package has a setup.py. This macro ensures 20 | ## modules and global scripts declared therein get installed 21 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html 22 | # catkin_python_setup() 23 | 24 | ################################################ 25 | ## Declare ROS messages, services and actions ## 26 | ################################################ 27 | 28 | ## To declare and build messages, services or actions from within this 29 | ## package, follow these steps: 30 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in 31 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). 32 | ## * In the file package.xml: 33 | ## * add a build_depend tag for "message_generation" 34 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET 35 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in 36 | ## but can be declared for certainty nonetheless: 37 | ## * add a exec_depend tag for "message_runtime" 38 | ## * In this file (CMakeLists.txt): 39 | ## * add "message_generation" and every package in MSG_DEP_SET to 40 | ## find_package(catkin REQUIRED COMPONENTS ...) 41 | ## * add "message_runtime" and every package in MSG_DEP_SET to 42 | ## catkin_package(CATKIN_DEPENDS ...) 43 | ## * uncomment the add_*_files sections below as needed 44 | ## and list every .msg/.srv/.action file to be processed 45 | ## * uncomment the generate_messages entry below 46 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) 47 | 48 | # Generate messages in the 'msg' folder 49 | add_message_files( 50 | FILES 51 | TaskMessage.msg 52 | AgentInfo.msg 53 | SwarmInformation.msg 54 | TargetInformation.msg 55 | TaskStatusMessage.msg 56 | RewardMessage.msg 57 | TaskStatusInformation.msg 58 | SystemStatusMessage.msg 59 | InitMessage.msg 60 | SwarmInfo.msg 61 | EnemyInfo.msg 62 | ) 63 | 64 | ## Generate services in the 'srv' folder 65 | # add_service_files( 66 | # FILES 67 | # Service1.srv 68 | # Service2.srv 69 | # ) 70 | 71 | ## Generate actions in the 'action' folder 72 | # add_action_files( 73 | # FILES 74 | # Action1.action 75 | # Action2.action 76 | # ) 77 | 78 | # Generate added messages and services with any dependencies listed here 79 | generate_messages( 80 | DEPENDENCIES 81 | std_msgs 82 | ) 83 | 84 | ################################################ 85 | ## Declare ROS dynamic reconfigure parameters ## 86 | ################################################ 87 | 88 | ## To declare and build dynamic reconfigure parameters within this 89 | ## package, follow these steps: 90 | ## * In the file package.xml: 91 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" 92 | ## * In this file (CMakeLists.txt): 93 | ## * add "dynamic_reconfigure" to 94 | ## find_package(catkin REQUIRED COMPONENTS ...) 95 | ## * uncomment the "generate_dynamic_reconfigure_options" section below 96 | ## and list every .cfg file to be processed 97 | 98 | ## Generate dynamic reconfigure parameters in the 'cfg' folder 99 | # generate_dynamic_reconfigure_options( 100 | # cfg/DynReconf1.cfg 101 | # cfg/DynReconf2.cfg 102 | # ) 103 | 104 | ################################### 105 | ## catkin specific configuration ## 106 | ################################### 107 | ## The catkin_package macro generates cmake config files for your package 108 | ## Declare things to be passed to dependent projects 109 | ## INCLUDE_DIRS: uncomment this if your package contains header files 110 | ## LIBRARIES: libraries you create in this project that dependent projects also need 111 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need 112 | ## DEPENDS: system dependencies of this project that dependent projects also need 113 | catkin_package( 114 | # INCLUDE_DIRS include 115 | # LIBRARIES mission_planning 116 | CATKIN_DEPENDS rospy std_msgs 117 | # DEPENDS system_lib 118 | ) 119 | 120 | ########### 121 | ## Build ## 122 | ########### 123 | 124 | ## Specify additional locations of header files 125 | ## Your package locations should be listed before other locations 126 | include_directories( 127 | # include 128 | ${catkin_INCLUDE_DIRS} 129 | ) 130 | 131 | ## Declare a C++ library 132 | # add_library(${PROJECT_NAME} 133 | # src/${PROJECT_NAME}/mission_planning.cpp 134 | # ) 135 | 136 | ## Add cmake target dependencies of the library 137 | ## as an example, code may need to be generated before libraries 138 | ## either from message generation or dynamic reconfigure 139 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 140 | 141 | ## Declare a C++ executable 142 | ## With catkin_make all packages are built within a single CMake context 143 | ## The recommended prefix ensures that target names across packages don't collide 144 | # add_executable(${PROJECT_NAME}_node src/mission_planning_node.cpp) 145 | 146 | ## Rename C++ executable without prefix 147 | ## The above recommended prefix causes long target names, the following renames the 148 | ## target back to the shorter version for ease of user use 149 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" 150 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") 151 | 152 | ## Add cmake target dependencies of the executable 153 | ## same as for the library above 154 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) 155 | 156 | ## Specify libraries to link a library or executable target against 157 | # target_link_libraries(${PROJECT_NAME}_node 158 | # ${catkin_LIBRARIES} 159 | # ) 160 | 161 | 162 | ############# 163 | ## Install ## 164 | ############# 165 | 166 | # all install targets should use catkin DESTINATION variables 167 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html 168 | 169 | ## Mark executable scripts (Python etc.) for installation 170 | ## in contrast to setup.py, you can choose the destination 171 | # install(PROGRAMS 172 | # scripts/my_python_script 173 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 174 | # ) 175 | 176 | ## Mark executables and/or libraries for installation 177 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node 178 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 179 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 180 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} 181 | # ) 182 | 183 | ## Mark cpp header files for installation 184 | # install(DIRECTORY include/${PROJECT_NAME}/ 185 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 186 | # FILES_MATCHING PATTERN "*.h" 187 | # PATTERN ".svn" EXCLUDE 188 | # ) 189 | 190 | ## Mark other files for installation (e.g. launch and bag files, etc.) 191 | # install(FILES 192 | # # myfile1 193 | # # myfile2 194 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 195 | # ) 196 | 197 | ############# 198 | ## Testing ## 199 | ############# 200 | 201 | ## Add gtest based cpp test target and link libraries 202 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_mission_planning.cpp) 203 | # if(TARGET ${PROJECT_NAME}-test) 204 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) 205 | # endif() 206 | 207 | ## Add folders to be run by python nosetests 208 | # catkin_add_nosetests(test) 209 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # sample documentation build configuration file, created by 4 | # sphinx-quickstart on Mon Apr 16 21:22:43 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = [] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'sample' 44 | copyright = u'2012, Kenneth Reitz' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = 'v0.0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = 'v0.0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'sampledoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | latex_elements = { 173 | # The paper size ('letterpaper' or 'a4paper'). 174 | #'papersize': 'letterpaper', 175 | 176 | # The font size ('10pt', '11pt' or '12pt'). 177 | #'pointsize': '10pt', 178 | 179 | # Additional stuff for the LaTeX preamble. 180 | #'preamble': '', 181 | } 182 | 183 | # Grouping the document tree into LaTeX files. List of tuples 184 | # (source start file, target name, title, author, documentclass [howto/manual]). 185 | latex_documents = [ 186 | ('index', 'sample.tex', u'sample Documentation', 187 | u'Kenneth Reitz', 'manual'), 188 | ] 189 | 190 | # The name of an image file (relative to this directory) to place at the top of 191 | # the title page. 192 | #latex_logo = None 193 | 194 | # For "manual" documents, if this is true, then toplevel headings are parts, 195 | # not chapters. 196 | #latex_use_parts = False 197 | 198 | # If true, show page references after internal links. 199 | #latex_show_pagerefs = False 200 | 201 | # If true, show URL addresses after external links. 202 | #latex_show_urls = False 203 | 204 | # Documents to append as an appendix to all manuals. 205 | #latex_appendices = [] 206 | 207 | # If false, no module index is generated. 208 | #latex_domain_indices = True 209 | 210 | 211 | # -- Options for manual page output -------------------------------------------- 212 | 213 | # One entry per manual page. List of tuples 214 | # (source start file, name, description, authors, manual section). 215 | man_pages = [ 216 | ('index', 'sample', u'sample Documentation', 217 | [u'Kenneth Reitz'], 1) 218 | ] 219 | 220 | # If true, show URL addresses after external links. 221 | #man_show_urls = False 222 | 223 | 224 | # -- Options for Texinfo output ------------------------------------------------ 225 | 226 | # Grouping the document tree into Texinfo files. List of tuples 227 | # (source start file, target name, title, author, 228 | # dir menu entry, description, category) 229 | texinfo_documents = [ 230 | ('index', 'sample', u'sample Documentation', 231 | u'Kenneth Reitz', 'sample', 'One line description of project.', 232 | 'Miscellaneous'), 233 | ] 234 | 235 | # Documents to append as an appendix to all manuals. 236 | #texinfo_appendices = [] 237 | 238 | # If false, no module index is generated. 239 | #texinfo_domain_indices = True 240 | 241 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 242 | #texinfo_show_urls = 'footnote' 243 | -------------------------------------------------------------------------------- /scripts/StageThree.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | import os 4 | 5 | from StageThreeStateMachine import StageThreeStateMachine, StageThreeState 6 | from Task import Task,TaskType 7 | import time 8 | 9 | 10 | class MissionStageThree(): 11 | 12 | def __init__(self): 13 | """ 14 | =========================================================== 15 | Constructor to create initial relevant Objects and global 16 | Variables 17 | =========================================================== 18 | :Parameters: None 19 | :return: None 20 | =========================================================== 21 | """ 22 | 23 | #State object to handle the states with initial state one 24 | self.obj = StageThreeState(state='hoverAtCurrentPosition') 25 | #state machine instance to handle the main state machine 26 | self.mission = StageThreeStateMachine(self.obj) 27 | 28 | # Entry Trigger 29 | self.EntryStartMotor = False 30 | self.EntryHover = False 31 | self.EntryGoToWaypoint = False 32 | self.EntryLandInAOI = False 33 | self.EntryWaitOnGround = False 34 | self.Entry = False 35 | self.Entry = False 36 | self.Entry = False 37 | 38 | self.StageDone = False 39 | 40 | 41 | 42 | def StageThree(self, agentsList, fooList, TaskList): 43 | """ 44 | =========================================================== 45 | Stage Three Statemachine function which is executing the 46 | initial static mission steps 47 | =========================================================== 48 | :Parameters: 49 | - AgentsList: 50 | A list which contains a lits of Agents obejct.The Agents object 51 | represents a real entity and contains information about: 52 | AgentID 53 | AgentPosition 54 | AgentVelocity 55 | TaskStatus 56 | TaskID 57 | SystemWorkingStatus 58 | 59 | 60 | 61 | - FoosList: 62 | A list which contains a lits of target obejct.The foo object 63 | represents a real targets and contains information about: 64 | TargetID 65 | TargetPosition 66 | AgentVelocity 67 | AttackkStatus 68 | Confidence 69 | 70 | - TaskList: 71 | A list which contains a lits of task obejct.The task object 72 | object contains information of assigend tasks: 73 | AgentID 74 | TagetID 75 | TaskID 76 | TaskLocation/Waypoint 77 | TaskDeadLine 78 | 79 | :return: None 80 | =========================================================== 81 | """ 82 | 83 | if self.obj.state == 'hoverAtCurrentPosition': 84 | 85 | # ======== Entry ======== 86 | if not (self.EntryHover): 87 | # Hover State 88 | time.sleep(5) 89 | self.EntryHover = True 90 | return 91 | 92 | # ====Main Part ======== 93 | print("S3: Agents hovering...") 94 | hoverTimeReached = True 95 | time.sleep(2) 96 | 97 | # ===== Exit ======== 98 | if (hoverTimeReached): 99 | #execute statemachine transition with trigger 100 | self.mission.hoverTimeReached() 101 | #Set time new to restart the countdown 102 | 103 | elif self.obj.state == 'goToWaypoint': 104 | 105 | # ======== Entry ======== 106 | if not (self.EntryGoToWaypoint): 107 | 108 | # Execute Payload Drop 109 | # Create Task Objects handle the tasks for each agent 110 | deadline = 120 111 | f = open(self.getRelativeFilePath("MissionPlan/Stage_3_Attack.txt")) 112 | line = f.readlines(0) 113 | print("S3: Setting waypoints") 114 | for i in range(0, len(agentsList)): 115 | waypoint = line[i].split(";") 116 | del waypoint[-1] # delete last element with new line command 117 | waypoint = [int(x) for x in waypoint] 118 | TaskList.append(Task(agentsList[i].agentId, 0, TaskType.WAYPOINT.value,waypoint,deadline)) 119 | print "S3: Waypoint: {0} set for agent: {1}".format(waypoint, agentsList[i].agentId) 120 | self.EntryGoToWaypoint = True 121 | f.close() 122 | return 123 | 124 | # ====Main Part ======== 125 | print("S3: Agents going to waypoint...") 126 | reachedAOI = self.allAgentsFinishedTask(agentsList) 127 | time.sleep(2) 128 | 129 | # ===== Exit ======== 130 | if (reachedAOI): 131 | #execute statemachine transition with trigger 132 | self.mission.reachedAOI() 133 | 134 | 135 | elif self.obj.state == 'landInAOI': 136 | 137 | # ======== Entry ======== 138 | if not (self.EntryLandInAOI): 139 | # Execute Payload Drop 140 | # Create Task Objects handle the tasks for each agent 141 | deadline = 180 142 | for i in range(0, len(agentsList)): 143 | TaskList.append(Task(agentsList[i].agentId, 0, TaskType.LAND.value,[1, 1, 1],deadline)) 144 | print "S3: Land order send to agent: %d" % agentsList[i].agentId 145 | self.EntryLandInAOI = True 146 | return 147 | 148 | # ====Main Part ======== 149 | touchedGround = self.allAgentsFinishedTask(agentsList) 150 | time.sleep(2) 151 | 152 | # ===== Exit ======== 153 | if (touchedGround): 154 | #execute statemachine transition with trigger 155 | self.mission.touchedGround() 156 | 157 | elif self.obj.state == 'waitOnGround': 158 | 159 | # ======== Entry ======== 160 | if not (self.EntryWaitOnGround): 161 | # Wait on Ground 162 | time.sleep(5) 163 | self.EntryWaitOnGround = True 164 | return 165 | 166 | # ====Main Part ======== 167 | # System Turnsoff automaticly when landed therefore the flag just 168 | # set True 169 | timeToTurnOff = True 170 | time.sleep(2) 171 | 172 | # ===== Exit ======== 173 | if (timeToTurnOff): 174 | print("End of the mission") 175 | self.StageDone = True 176 | return self.StageDone 177 | 178 | 179 | def getRelativeFilePath(self, relativePath): 180 | """ 181 | ============================================================== 182 | Function to setup correct abolute path for rading the .txt file 183 | for predefined agent positions 184 | =========================================================== 185 | :Parameters: 186 | - relativePath: String which contains the relative path of 187 | file 188 | 189 | :return: absFilePath - absolute file path for further use 190 | =========================================================== 191 | """ 192 | 193 | scriptDir = os.path.dirname(__file__) 194 | absFilePath = os.path.join(scriptDir, relativePath) 195 | return absFilePath 196 | 197 | def allAgentsFinishedTask(self,agentsList): 198 | """ 199 | ============================================================== 200 | Function to recognize if all agents are free for new task in 201 | order to go further to next state of the statemachine 202 | =========================================================== 203 | :Parameters: 204 | - AgentsList: 205 | A list which contains a lits of Agents obejct.The Agents object 206 | represents a real entity and contains information about: 207 | AgentID 208 | AgentPosition 209 | AgentVelocity 210 | TaskStatus 211 | TaskID 212 | SystemWorkingStatus 213 | 214 | :return: True if all finished - False if still agents in work 215 | =========================================================== 216 | """ 217 | for i in range(0, len(agentsList)): 218 | if(agentsList[i].taskStatus is True) and (agentsList[i].agentWorkingStatus is True): 219 | return False 220 | return True 221 | -------------------------------------------------------------------------------- /Include/lap-master/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | from pkg_resources import parse_version 5 | import shutil 6 | import subprocess 7 | import sys 8 | import traceback 9 | 10 | if sys.version_info[0] < 3: 11 | import __builtin__ as builtins 12 | else: 13 | import builtins 14 | builtins.__LAP_SETUP__ = True 15 | 16 | DISTNAME = 'lap' 17 | DESCRIPTION = 'Linear Assignment Problem solver (LAPJV/LAPMOD).' 18 | LONG_DESCRIPTION = """ 19 | **lap** is a linear assignment problem solver using Jonker-Volgenant 20 | algorithm for dense (LAPJV) or sparse (LAPMOD) matrices. 21 | """ 22 | MAINTAINER = 'Tomas Kazmar' 23 | MAINTAINER_EMAIL = 'tomash.kazmar@seznam.cz' 24 | URL = 'https://github.com/gatagat/lap' 25 | LICENSE = 'BSD (2-clause)' 26 | DOWNLOAD_URL = URL 27 | 28 | import lap 29 | 30 | VERSION = lap.__version__ 31 | 32 | NUMPY_MIN_VERSION = '1.10.1' 33 | 34 | SETUPTOOLS_COMMANDS = set([ 35 | 'develop', 'release', 'bdist_egg', 'bdist_rpm', 36 | 'bdist_wininst', 'install_egg_info', 'build_sphinx', 37 | 'egg_info', 'easy_install', 'upload', 'bdist_wheel', 38 | '--single-version-externally-managed', 39 | ]) 40 | if SETUPTOOLS_COMMANDS.intersection(sys.argv): 41 | import setuptools 42 | 43 | extra_setuptools_args = dict( 44 | zip_safe=False, # the package can run out of an .egg file 45 | include_package_data=True, 46 | extras_require={ 47 | 'alldeps': ( 48 | 'numpy >= {0}'.format(NUMPY_MIN_VERSION), 49 | ), 50 | }, 51 | ) 52 | else: 53 | extra_setuptools_args = dict() 54 | 55 | from distutils.command.clean import clean as Clean 56 | 57 | class CleanCommand(Clean): 58 | description = "Remove build artifacts from the source tree" 59 | 60 | def run(self): 61 | Clean.run(self) 62 | if os.path.exists('build'): 63 | shutil.rmtree('build') 64 | # Remove c files if we are not within a sdist package 65 | cwd = os.path.abspath(os.path.dirname(__file__)) 66 | remove_c_files = not os.path.exists(os.path.join(cwd, 'PKG-INFO')) 67 | if remove_c_files: 68 | if os.path.exists('lap/_lapjv.cpp'): 69 | os.unlink('lap/_lapjv.cpp') 70 | for dirpath, dirnames, filenames in os.walk('lap'): 71 | for filename in filenames: 72 | if any(filename.endswith(suffix) for suffix in 73 | (".so", ".pyd", ".dll", ".pyc")): 74 | os.unlink(os.path.join(dirpath, filename)) 75 | for dirname in dirnames: 76 | if dirname == '__pycache__': 77 | shutil.rmtree(os.path.join(dirpath, dirname)) 78 | 79 | cmdclass = {'clean': CleanCommand} 80 | 81 | 82 | from distutils.version import LooseVersion 83 | 84 | def cythonize(cython_file, gen_file): 85 | try: 86 | from Cython.Compiler.Version import version as cython_version 87 | if LooseVersion(cython_version) < LooseVersion('0.21'): 88 | raise ImportError('Installed cython is too old (0.21 required), ' 89 | 'please "pip install -U cython".') 90 | except ImportError: 91 | raise ImportError('Building lapjv requires cython, ' 92 | 'please "pip install cython".') 93 | pass 94 | 95 | flags = ['--fast-fail'] 96 | if gen_file.endswith('.cpp'): 97 | flags += ['--cplus'] 98 | 99 | try: 100 | try: 101 | rc = subprocess.call(['cython'] + 102 | flags + ["-o", gen_file, cython_file]) 103 | if rc != 0: 104 | raise Exception('Cythonizing %s failed' % cython_file) 105 | except OSError: 106 | # There are ways of installing Cython that don't result in a cython 107 | # executable on the path, see scipy issue gh-2397. 108 | rc = subprocess.call([sys.executable, '-c', 109 | 'import sys; from Cython.Compiler.Main ' 110 | 'import setuptools_main as main;' 111 | ' sys.exit(main())'] + flags + 112 | ["-o", gen_file, cython_file]) 113 | if rc != 0: 114 | raise Exception('Cythonizing %s failed' % cython_file) 115 | except OSError: 116 | raise OSError('Cython needs to be installed') 117 | 118 | 119 | def get_numpy_status(): 120 | """ 121 | Returns a dictionary containing a boolean specifying whether NumPy 122 | is up-to-date, along with the version string (empty string if 123 | not installed). 124 | """ 125 | numpy_status = {} 126 | try: 127 | import numpy 128 | numpy_version = numpy.__version__ 129 | numpy_status['up_to_date'] = parse_version( 130 | numpy_version) >= parse_version(NUMPY_MIN_VERSION) 131 | numpy_status['version'] = numpy_version 132 | except ImportError: 133 | traceback.print_exc() 134 | numpy_status['up_to_date'] = False 135 | numpy_status['version'] = "" 136 | return numpy_status 137 | 138 | 139 | def get_wrapper_pyx(): 140 | return os.path.join('lap', '_lapjv.pyx') 141 | 142 | 143 | def generate_cython(): 144 | wrapper_pyx_file = get_wrapper_pyx() 145 | wrapper_c_file = os.path.splitext(wrapper_pyx_file)[0] + '.cpp' 146 | cythonize(wrapper_pyx_file, wrapper_c_file) 147 | 148 | 149 | def configuration(parent_package='', top_path=None): 150 | from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs 151 | 152 | config = Configuration(None, parent_package, top_path) 153 | 154 | config.set_options( 155 | ignore_setup_xxx_py=True, 156 | assume_default_configuration=True, 157 | delegate_options_to_subpackages=True, 158 | quiet=True) 159 | 160 | config.add_data_dir('lap/tests') 161 | 162 | wrapper_pyx_file = get_wrapper_pyx() 163 | wrapper_c_file = os.path.splitext(wrapper_pyx_file)[0] + '.cpp' 164 | c_files = [ 165 | os.path.join(os.path.dirname(wrapper_pyx_file), 'lapjv.cpp'), 166 | os.path.join(os.path.dirname(wrapper_pyx_file), 'lapmod.cpp')] 167 | config.add_extension('lap._lapjv', sources=[wrapper_c_file, c_files], 168 | include_dirs=[get_numpy_include_dirs(), 'lap']) 169 | 170 | return config 171 | 172 | 173 | def setup_package(): 174 | metadata = dict(name=DISTNAME, 175 | maintainer=MAINTAINER, 176 | maintainer_email=MAINTAINER_EMAIL, 177 | description=DESCRIPTION, 178 | license=LICENSE, 179 | packages=['lap'], 180 | url=URL, 181 | version=VERSION, 182 | download_url=DOWNLOAD_URL, 183 | long_description=LONG_DESCRIPTION, 184 | classifiers=['Development Status :: 4 - Beta', 185 | 'Environment :: Console', 186 | 'Intended Audience :: Science/Research', 187 | 'Intended Audience :: Developers', 188 | 'Programming Language :: C', 189 | 'Programming Language :: Python', 190 | 'Programming Language :: Python :: 2', 191 | 'Programming Language :: Python :: 3', 192 | 'Programming Language :: Python :: 2.7', 193 | 'Programming Language :: Python :: 3.6', 194 | 'Programming Language :: Python :: 3.7', 195 | 'Operating System :: Microsoft :: Windows', 196 | 'Operating System :: POSIX', 197 | 'Operating System :: Unix', 198 | 'Operating System :: MacOS', 199 | ], 200 | cmdclass=cmdclass, 201 | **extra_setuptools_args) 202 | 203 | if len(sys.argv) == 1 or ( 204 | len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or 205 | sys.argv[1] in ('--help-commands', 206 | 'egg_info', 207 | '--version', 208 | 'clean'))): 209 | try: 210 | from setuptools import setup 211 | except ImportError: 212 | from distutils.core import setup 213 | else: 214 | numpy_status = get_numpy_status() 215 | if numpy_status['up_to_date'] is False: 216 | if numpy_status['version']: 217 | raise ImportError('Installed numpy is too old, ' 218 | 'please "pip install -U numpy".') 219 | else: 220 | raise ImportError('lap requires numpy, ' 221 | 'please "pip install numpy".') 222 | 223 | from numpy.distutils.core import setup 224 | metadata['configuration'] = configuration 225 | 226 | if len(sys.argv) >= 2 and sys.argv[1] not in 'config': 227 | print('Generating cython files') 228 | cwd = os.path.abspath(os.path.dirname(__file__)) 229 | if not os.path.exists(os.path.join(cwd, 'PKG-INFO')): 230 | generate_cython() 231 | 232 | setup(**metadata) 233 | 234 | 235 | if __name__ == "__main__": 236 | setup_package() 237 | --------------------------------------------------------------------------------