├── config
├── ___init__.py
├── farmworld_config.py
├── portworld_config.py
└── mineworld_config.py
├── requirements.txt
├── .flake8
├── images
├── icon.png
├── farmworld.png
├── mineworld.png
├── portworld.png
├── farmworld_screenshot.png
├── mineworld_screenshot.png
└── portworld_screenshot.png
├── .github
├── workflows
│ ├── pull_request.yml
│ ├── ci.yml
│ └── push.yml
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── caladan_api.py
├── README.md
├── portworld.py
├── farmworld.py
├── mineworld.py
└── LICENSE
/config/___init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests>=2.22.0
2 | pysimplegui>=4.50.0
3 |
--------------------------------------------------------------------------------
/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length = 88
3 | extend-ignore = E203,E501
4 |
--------------------------------------------------------------------------------
/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/icon.png
--------------------------------------------------------------------------------
/images/farmworld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/farmworld.png
--------------------------------------------------------------------------------
/images/mineworld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/mineworld.png
--------------------------------------------------------------------------------
/images/portworld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/portworld.png
--------------------------------------------------------------------------------
/images/farmworld_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/farmworld_screenshot.png
--------------------------------------------------------------------------------
/images/mineworld_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/mineworld_screenshot.png
--------------------------------------------------------------------------------
/images/portworld_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/polymathrobotics/caladan_examples/HEAD/images/portworld_screenshot.png
--------------------------------------------------------------------------------
/.github/workflows/pull_request.yml:
--------------------------------------------------------------------------------
1 | name: 'PR'
2 | on:
3 | - pull_request
4 | jobs:
5 | preview:
6 | name: Preview
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 |
11 | - name: Set up Python 3.8
12 | uses: actions/setup-python@v4
13 | with:
14 | python-version: 3.8
15 |
16 | - name: Install Black
17 | run: pip install black
18 |
19 | - name: Run Black
20 | uses: psf/black@stable
21 | with:
22 | src: "."
23 |
24 | - name: Install flake8
25 | run: pip install flake8
26 |
27 | - uses: TrueBrain/actions-flake8@v2
28 | with:
29 | path: .
30 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: ci
2 | on:
3 | push:
4 | branches: [ main ]
5 | # Allows you to run this workflow manually from the Actions tab
6 | workflow_dispatch:
7 | jobs:
8 | update:
9 | name: Update
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 |
14 | - name: Set up Python 3.8
15 | uses: actions/setup-python@v4
16 | with:
17 | python-version: 3.8
18 |
19 | - name: Install Black
20 | run: pip install black
21 |
22 | - name: Run Black
23 | uses: psf/black@stable
24 | with:
25 | src: "."
26 |
27 | - name: Install flake8
28 | run: pip install flake8
29 |
30 | - name: Run flake8
31 | uses: suo/flake8-github-action@releases/v1
32 | with:
33 | checkName: 'update' # NOTE: this needs to be the same as the job name
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 |
--------------------------------------------------------------------------------
/.github/workflows/push.yml:
--------------------------------------------------------------------------------
1 | name: push
2 | on:
3 | push:
4 | branches: [ main ]
5 | # Allows you to run this workflow manually from the Actions tab
6 | workflow_dispatch:
7 | jobs:
8 | update:
9 | name: Update
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 |
14 | - name: Set up Python 3.8
15 | uses: actions/setup-python@v4
16 | with:
17 | python-version: 3.8
18 |
19 | - name: Install Black
20 | run: pip install black
21 |
22 | - name: Run Black
23 | uses: psf/black@stable
24 | with:
25 | src: "."
26 |
27 | - name: Install flake8
28 | run: pip install flake8
29 |
30 | - name: Run flake8
31 | uses: suo/flake8-github-action@releases/v1
32 | with:
33 | checkName: 'update' # NOTE: this needs to be the same as the job name
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 |
3 | Please answer the following questions for yourself before submitting an issue. **YOU MAY DELETE THE PREREQUISITES SECTION.**
4 |
5 | - [ ] I am running the latest version
6 | - [ ] I checked the documentation and found no answer
7 | - [ ] I checked to make sure that this issue has not already been filed
8 | - [ ] I'm reporting the issue to the correct repository (for multi-repository projects)
9 |
10 | # Expected Behavior
11 |
12 | Please describe the behavior you are expecting
13 |
14 | # Current Behavior
15 |
16 | What is the current behavior?
17 |
18 | # Failure Information (for bugs)
19 |
20 | Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
21 |
22 | ## Steps to Reproduce
23 |
24 | Please provide detailed steps for reproducing the issue.
25 |
26 | 1. step 1
27 | 2. step 2
28 | 3. you get it...
29 |
30 | ## Context
31 |
32 | Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
33 |
34 | * Firmware Version:
35 | * Operating System:
36 | * SDK version:
37 | * Toolchain version:
38 |
39 | ## Failure Logs
40 |
41 | Please include any relevant log snippets or files here.
42 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4 |
5 | Fixes # (issue)
6 |
7 | ## Type of change
8 |
9 | Please delete options that are not relevant.
10 |
11 | - [ ] Bug fix (non-breaking change which fixes an issue)
12 | - [ ] New feature (non-breaking change which adds functionality)
13 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14 | - [ ] This change requires a documentation update
15 |
16 | # How Has This Been Tested?
17 |
18 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19 |
20 | - [ ] Test A
21 | - [ ] Test B
22 |
23 | **Test Configuration**:
24 | * Firmware version:
25 | * Hardware:
26 | * Toolchain:
27 | * SDK:
28 |
29 | # Checklist:
30 |
31 | - [ ] My code follows the style guidelines of this project
32 | - [ ] I have performed a self-review of my own code
33 | - [ ] I have commented my code, particularly in hard-to-understand areas
34 | - [ ] I have made corresponding changes to the documentation
35 | - [ ] My changes generate no new warnings
36 | - [ ] I have added tests that prove my fix is effective or that my feature works
37 |
--------------------------------------------------------------------------------
/config/farmworld_config.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
2 | # Example farmworld UI for using the Caladan API in Python
3 | # Designed as a simple teaching example, not feature complete or fully robust.
4 |
5 | # Example set of goals for vehicle to follow
6 | tilling_goals = [
7 | (37.724908, -120.998889, 1.57), # start of row 1
8 | (37.725445, -120.998889, 1.57), # end of row 1
9 | (37.725495, -120.998857, 0), # turn around midpoint
10 | (37.725445, -120.998811, -1.57), # start of row 2
11 | (37.724908, -120.998811, -1.57), # end of row 2
12 | ]
13 |
14 | # Example single goal to return to the shed
15 | shed_goal = (37.72448, -120.998921, 0)
16 |
17 | # Overall size of the map, south-west corner, then north-east corner
18 | # south-west: 37.724367, -120.999586
19 | # north-east: 37.725545, -120.998047
20 | # Hence, window will be 0.001178 by 0.001539 in lat/lon coordinates
21 | # Latitude is North to South (equator 0), Longitude is West to East (Greenwich 0)
22 | # Graphing is +x to the right, +y upwards
23 | # Multiplying by 400000 to get pixel space (so ~ 616 by 471 )
24 | # In a real application, please convert correctly, this only works well for small toy examples
25 | latlon_map = (
26 | (37.724367, -120.999586),
27 | (37.725545, -120.998047),
28 | )
29 |
30 | odom = dict()
31 | stat = dict()
32 |
33 | api_url = "https://beta-caladan.polymathrobotics.dev/api/"
34 |
35 | # Enter your Polymath Robotics provided Bearer Token and Device Key here!
36 | token = "bearer_token"
37 | key = "device_key"
38 |
--------------------------------------------------------------------------------
/config/portworld_config.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
2 | # Example farmworld UI for using the Caladan API in Python
3 | # Designed as a simple teaching example, not feature complete or fully robust.
4 |
5 | # Example single goal to return to the shed
6 | shed_goal = (37.724570, -120.998354, 0)
7 |
8 | # Example Buttons, experiment by changing the name and location/orientations sent
9 | button_a = ("Crane A", 37.725380, -120.998295, -3.14)
10 | button_b = ("Crane B", 37.725189, -120.998295, -3.14)
11 | button_c = ("Crane C", 37.724960, -120.998295, -3.14)
12 | button_d = ("Train Load", 37.72465, -120.99914, 0)
13 | button_e = ("Train Unload", 37.72481, -120.99947, -1.57)
14 |
15 | # Overall size of the map, south-west corner, then north-east corner
16 | # south-west: 37.724367, -120.999586
17 | # north-east: 37.725545, -120.998047
18 | # Hence, window will be 0.001178 by 0.001539 in lat/lon coordinates
19 | # Latitude is North to South (equator 0), Longitude is West to East (Greenwich 0)
20 | # Graphing is +x to the right, +y upwards
21 | # Multiplying by 400000 to get pixel space (so ~ 616 by 471 )
22 | # In a real application, please convert correctly, this only works well for small toy examples
23 | latlon_map = (
24 | (37.724367, -120.999586),
25 | (37.725545, -120.998047),
26 | )
27 |
28 |
29 | odom = dict()
30 | stat = dict()
31 |
32 | api_url = "https://beta-caladan.polymathrobotics.dev/api/"
33 |
34 | # Enter your Polymath Robotics provided Bearer Token and Device Key here!
35 | token = "bearer_token"
36 | key = "device_key"
37 |
--------------------------------------------------------------------------------
/config/mineworld_config.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
2 | # Example farmworld UI for using the Caladan API in Python
3 | # Designed as a simple teaching example, not feature complete or fully robust.
4 |
5 |
6 | # Example single goal to return to the shed
7 | shed_goal = (37.724570, -120.998354, 0)
8 |
9 | # Example Buttons, experiment by changing the name and location/orientations sent
10 | button_a = ("Mine Site A", 37.725103, -120.998961, 0)
11 | button_b = ("Mine Site B", 37.724731, -120.999148, -3.14)
12 | button_c = ("Processing Plant", 37.725324, -120.998303, 0)
13 | button_d = ("Bulldozer Mode", 0)
14 | button_e = ("Dump Truck Mode", 0)
15 | button_f = ("Rotate North", 0)
16 | button_g = ("Rotate South", 3.14)
17 |
18 | # Moves between two mine sites
19 | bulldoze = (
20 | (37.724682, -120.999465, -3.14),
21 | (37.725299, -120.999431, 0),
22 | )
23 |
24 | # Moves from center of the mine to processing plant
25 | dump = (
26 | (37.724977, -120.999469, 1.57),
27 | (37.724834, -120.998283, -1.57),
28 | )
29 |
30 | # Overall size of the map, south-west corner, then north-east corner
31 | # south-west: 37.724367, -120.999586
32 | # north-east: 37.725545, -120.998047
33 | # Hence, window will be 0.001178 by 0.001539 in lat/lon coordinates
34 | # Latitude is North to South (equator 0), Longitude is West to East (Greenwich 0)
35 | # Graphing is +x to the right, +y upwards
36 | # Multiplying by 400000 to get pixel space (so ~ 616 by 471 )
37 | # In a real application, please convert correctly, this only works well for small toy examples
38 | latlon_map = (
39 | (37.724367, -120.999586),
40 | (37.725545, -120.998047),
41 | )
42 |
43 |
44 | odom = dict()
45 | stat = dict()
46 |
47 | api_url = "https://beta-caladan.polymathrobotics.dev/api/"
48 |
49 | # Enter your Polymath Robotics provided Bearer Token and Device Key here!
50 | token = "bearer_token"
51 | key = "device_key"
52 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | .env
3 | activate_venv
4 | dist-packages
5 | # Byte-compiled / optimized / DLL files
6 | __pycache__/
7 | *.py[cod]
8 | *$py.class
9 | # C extensions
10 | *.so
11 | # Distribution / packaging
12 | .Python
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | wheels/
25 | share/python-wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .nox/
45 | .coverage
46 | .coverage.*
47 | .cache
48 | nosetests.xml
49 | coverage.xml
50 | *.cover
51 | *.py,cover
52 | .hypothesis/
53 | .pytest_cache/
54 | cover/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 | db.sqlite3
64 | db.sqlite3-journal
65 |
66 | # Flask stuff:
67 | instance/
68 | .webassets-cache
69 |
70 | # Scrapy stuff:
71 | .scrapy
72 |
73 | # Sphinx documentation
74 | docs/_build/
75 |
76 | # PyBuilder
77 | .pybuilder/
78 | target/
79 |
80 | # Jupyter Notebook
81 | .ipynb_checkpoints
82 |
83 | # IPython
84 | profile_default/
85 | ipython_config.py
86 |
87 | # pyenv
88 | # For a library or package, you might want to ignore these files since the code is
89 | # intended to run in multiple environments; otherwise, check them in:
90 | # .python-version
91 |
92 | # pipenv
93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
96 | # install all needed dependencies.
97 | #Pipfile.lock
98 |
99 | # poetry
100 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101 | # This is especially recommended for binary packages to ensure reproducibility, and is more
102 | # commonly ignored for libraries.
103 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104 | #poetry.lock
105 |
106 | # pdm
107 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108 | #pdm.lock
109 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110 | # in version control.
111 | # https://pdm.fming.dev/#use-with-ide
112 | .pdm.toml
113 |
114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115 | __pypackages__/
116 |
117 | # Celery stuff
118 | celerybeat-schedule
119 | celerybeat.pid
120 |
121 | # SageMath parsed files
122 | *.sage.py
123 |
124 | # Environments
125 | .env
126 | .venv
127 | env/
128 | venv/
129 | ENV/
130 | env.bak/
131 | venv.bak/
132 |
133 | # Spyder project settings
134 | .spyderproject
135 | .spyproject
136 |
137 | # Rope project settings
138 | .ropeproject
139 |
140 | # mkdocs documentation
141 | /site
142 |
143 | # mypy
144 | .mypy_cache/
145 | .dmypy.json
146 | dmypy.json
147 |
148 | # Pyre type checker
149 | .pyre/
150 |
151 | # pytype static type analyzer
152 | .pytype/
153 |
154 | # Cython debug symbols
155 | cython_debug/
156 |
157 | # PyCharm
158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160 | # and can be added to the global gitignore or merged into this file. For a more nuclear
161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162 | .idea/
163 |
--------------------------------------------------------------------------------
/caladan_api.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python3
2 |
3 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
4 | # Example small API library for using the API in Python
5 | # Designed as a simple teaching example, not feature complete or fully robust.
6 |
7 | import requests
8 | import json
9 |
10 |
11 | class SimpleAPI:
12 | def __init__(self, url, key, token):
13 | self.token = token
14 | self.key = key
15 | self.url = url
16 | self.headers = {
17 | "Accept": "application/json",
18 | "Authorization": "Bearer " + token,
19 | "Content-Type": "application/x-www-form-urlencoded",
20 | }
21 |
22 | def status_check(self, data):
23 | if "status" in data:
24 | if data["status"] == "success":
25 | return (data)["data"]
26 | else:
27 | return data["message"]
28 | else:
29 | return data
30 |
31 | def get_uuid(self):
32 | api_url = self.url + "uuid?device_key=" + self.key
33 | response = requests.get(api_url, headers=self.headers, timeout=30)
34 | return self.status_check(response.json())
35 |
36 | def get_position(self):
37 | api_url = self.url + "position?device_key=" + self.key
38 | response = requests.get(api_url, headers=self.headers, timeout=30)
39 | return self.status_check(response.json())
40 |
41 | def pose_with_odometry(self):
42 | api_url = self.url + "pose-with-odometry?device_key=" + self.key
43 | response = requests.get(api_url, headers=self.headers, timeout=30)
44 | return self.status_check(response.json())
45 |
46 | def goal_status(self):
47 | api_url = self.url + "goal-status?device_key=" + self.key
48 | response = requests.get(api_url, headers=self.headers, timeout=30)
49 | return self.status_check(response.json())
50 |
51 | def send_gps_goal(self, lat, lon, yaw):
52 | api_url = self.url + "send-gps-goal?device_key=" + self.key
53 | response = requests.post(
54 | api_url,
55 | headers=self.headers,
56 | data={"lat": lat, "lon": lon, "yaw": yaw},
57 | timeout=10,
58 | )
59 | return self.status_check(response.json())
60 |
61 | def send_waypoints(self, goals): # Expect an array of 3 entry sets
62 | api_url = self.url + "send-waypoints?device_key=" + self.key
63 | r = {"goals": []}
64 | for waypoint in goals:
65 | print(json.dumps(waypoint[2]))
66 | r["goals"].append(
67 | {
68 | "lat": json.dumps(waypoint[0]),
69 | "lon": json.dumps(waypoint[1]),
70 | "yaw": json.dumps(waypoint[2]),
71 | }
72 | )
73 | print(r)
74 | self.headers["Content-Type"] = "application/json"
75 | response = requests.post(
76 | api_url,
77 | headers=self.headers,
78 | json=r,
79 | timeout=10,
80 | )
81 | self.headers["Content-Type"] = "application/x-www-form-urlencoded"
82 | return self.status_check(response.json())
83 |
84 | def cancel_prev_goal(self):
85 | api_url = self.url + "cancel-prev-goal?device_key=" + self.key
86 | response = requests.post(api_url, headers=self.headers, timeout=30)
87 | return self.status_check(response.json())
88 |
89 |
90 | # Example Usage in
91 | # import caladan_api
92 | # url = "https://beta-caladan.polymathrobotics.dev/api/"
93 | # device_key = "*******"
94 | # token= "*******"
95 | # api = SimpleAPI(url,device_key,token)
96 | # print (api.get_uuid())
97 | # print (api.get_position())
98 | # print (api.send_gps_goal(37.72521,-120.99957,3.14))
99 | # print (api.pose_with_odometry())
100 | # print (api.cancel_prev_goal())
101 | # print (api.send_waypoints([[37.725017,-120.998852,None],[37.72519,-120.998815,3.14]]))
102 | # print (api.goal_status()) # Note: that goal status will take a few seconds to change when a new goal is sent
103 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # caladan_examples [](https://github.com/polymathrobotics/caladan_examples/actions/workflows/ci.yml)
2 |
3 | See your robot moving autonomously in simulation - today!
4 |
5 | ## Requirements
6 |
7 | 1. Python3
8 | 2. Pip3
9 |
10 | Once you have both of the above installed, you can go to the installation section below to pull down requirements.
11 | These are python libraries [Requests](https://pypi.org/project/requests/) and [PySimpleGUI](https://pypi.org/project/PySimpleGUI/)
12 |
13 | #### On Mac:
14 |
15 | Python3 installation: [Guide here](https://docs.python-guide.org/starting/install3/osx/)
16 |
17 | ```bash
18 | curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
19 | python3 get-pip.py
20 | ```
21 |
22 | #### On Ubuntu:
23 |
24 | ```bash
25 | sudo apt update
26 | sudo apt install python3-pip
27 | ```
28 |
29 | #### On Windows:
30 |
31 | ```bash
32 | Download Windows Installer (likely 64bit) from: https://www.python.org/downloads/release/python-3105/
33 | Or search python3 in the Microsoft Store
34 | ```
35 |
36 | ## Quick Start
37 |
38 | Open the [API webpage](https://beta-caladan.polymathrobotics.dev/docs#/Launch/start_sim_world_api_launch_sim_world_post), Authorize with your Bearer Token, click "try it out" and enter your device key.
39 | For launching simulation_world, you can choose between farm, port or mine.
40 |
41 | Clone this repo and then open a terminal in the folder.
42 |
43 | ### Installation
44 |
45 | Install dependencies using the requirements file
46 |
47 | ```bash
48 | python3 -m pip install -r requirements.txt
49 | ```
50 |
51 | ##### Launch the farm world gui example
52 |
53 | `python3 farmworld.py`
54 |
55 |
56 |
57 | 1. Enter your Bearer Token and Device Key.
58 |
59 | 2. Click Connect, and after a second or so, you will get current position and data about your simulated vehicle.
60 |
61 | 3. Click on some open space in the map, and the vehicle will navigate itself there.
62 |
63 | 4. Explore! Have fun (note: you will have to click STOP to send a new goal)
64 |
65 |
66 |
67 | ##### To launch the port world gui example
68 |
69 | `python3 portworld.py`
70 |
71 |
72 |
73 | 1. Enter your Bearer Token and Device Key.
74 |
75 | 2. Click Connect, and after a second or so, you will get current position and data about your simulated vehicle.
76 |
77 | 3. Click on some open space in the map, and the vehicle will navigate itself there.
78 |
79 | 4. Explore! Have fun (note: you will have to click STOP to send a new goal)
80 |
81 |
82 |
83 | ##### To launch the mine world gui example
84 |
85 | `python3 mineworld.py`
86 |
87 |
88 |
89 | 1. Enter your Bearer Token and Device Key.
90 |
91 | 2. Click Connect, and after a second or so, you will get current position and data about your simulated vehicle.
92 |
93 | 3. Click on some open space in the map, and the vehicle will navigate itself there.
94 |
95 | 4. Explore! Have fun (note: you will have to click STOP to send a new goal)
96 |
97 |
98 | ## Caladan API
99 |
100 | Check the bottom of the caladan_api.py file for example usage of the API in Python directly, for use in your own code. Example:
101 |
102 | ```bash
103 | user@computer:~/caladan_examples$ python3
104 | Python 3.8.10
105 |
106 | >>> import caladan_api
107 | >>> url = "https://beta-caladan.polymathrobotics.dev/api/"
108 | >>> device_key = "******"
109 | >>> token = "*******"
110 | >>> api = caladan_api.SimpleAPI(url,device_key,token)
111 | >>> print (api.get_uuid())
112 | {'uuid': 'ba791890-06e9-11ed-abcd-123456'}
113 | >>> print (api.get_position())
114 | {'position': {'latitude': 37.12345678, 'longitude': -120.12345678}, 'orientation': {'x': 0.0, 'y': 0.0, 'z': -0.9996048936785271, 'w': 0.028107944320787368}}
115 |
116 | ```
117 |
118 | ##
119 |
120 | ## FAQs
121 |
122 | - Q: I don't have a token and key?
123 | - A: Sign up for our beta!
124 |
125 | - NB: Add your token and key to farmworld_config.py and portworld_config.py files directly, so you don't have to copy/paste them in every time you start the examples.
126 |
127 | - NB: Clicking to send a goal in the examples always sets the orientation to 0 (north or up). Try changing this to a click-and-drag behavior to set orientation, as a first improvement to make!
128 |
129 | - Q: Why does the vehicle take the long way around sometimes?
130 | - A: The vehicle starts without any pre-baked map of the world. As it explores, it will build this map, and make better path planning decisions over time.
131 |
132 | - Q: Why does the vehicle back up sometimes?
133 | - A: The example vehicles have no preference for forwards/backwards, only to arrive at a goal with a set orientation.
134 |
135 | - Q: Why does the vehicle not reach the exact lat/lon/yaw I requested?
136 | - A: The example vehicles have position and orientation tolerances of 2m and 0.2rad respectively. On real vehicles, these are generaly much smaller.
137 |
138 | ##
139 |
140 | ## Questions?
141 |
142 | Check out our discussion page: [https://github.com/polymathrobotics/caladan_examples/discussions](https://github.com/polymathrobotics/caladan_examples/discussions)
143 | Email `support@polymathrobotics.com`
144 |
--------------------------------------------------------------------------------
/portworld.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python3
2 |
3 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
4 | # Example portworld UI for using the Caladan API in Python
5 | # Designed as a simple teaching example, not feature complete or fully robust.
6 |
7 | import time # used for sleep
8 | import math # used for some basic trigonometry
9 | import PySimpleGUI as sg # used for the Gui
10 | import caladan_api # example API library
11 | import config.portworld_config as portworld_config # simple convenience, used to store config values
12 |
13 | url = portworld_config.api_url
14 | token = portworld_config.token
15 | key = portworld_config.key
16 | scale = 400000.0 # Used to change drawing scale of the map
17 | font = ("Courier New", 7)
18 | latdiff = abs(portworld_config.latlon_map[0][0] - portworld_config.latlon_map[1][0])
19 | londiff = abs(portworld_config.latlon_map[0][1] - portworld_config.latlon_map[1][1])
20 | api = caladan_api.SimpleAPI("", "", "") # Init to avoid flake8 issues
21 |
22 | sg.theme("DarkGrey10")
23 | layout = [
24 | [sg.Text("Please provide Token and Key below", key="-PROMPT-")],
25 | [sg.Input(token)],
26 | [sg.Input(key)],
27 | [sg.Button("Connect"), sg.Text("", key="-VEL-"), sg.Text("", key="-POSE-")],
28 | [
29 | sg.Graph(
30 | canvas_size=(londiff * scale, latdiff * scale),
31 | graph_bottom_left=(0, 0),
32 | graph_top_right=(londiff * scale, latdiff * scale),
33 | background_color="#1C1E23",
34 | enable_events=True,
35 | key="graph",
36 | )
37 | ],
38 | [
39 | sg.Button("STOP", button_color=("white", "red")),
40 | sg.Text("", key="-STATUS-", size=(45, None)),
41 | ],
42 | [
43 | sg.Button("Return to Equipment Shed"),
44 | sg.Button(portworld_config.button_a[0]),
45 | sg.Button(portworld_config.button_b[0]),
46 | sg.Button(portworld_config.button_c[0]),
47 | ],
48 | [sg.Button(portworld_config.button_d[0]), sg.Button(portworld_config.button_e[0])],
49 | ]
50 |
51 |
52 | window = sg.Window(
53 | "Polymath Robotics Caladan Portworld Example",
54 | layout,
55 | icon="./images/icon.png",
56 | finalize=True,
57 | )
58 | graph = window["graph"]
59 |
60 |
61 | def latlon_to_pixelXY(lat, lon):
62 | return (
63 | -scale * (portworld_config.latlon_map[0][1] - lon),
64 | -scale * (portworld_config.latlon_map[0][0] - lat),
65 | )
66 |
67 |
68 | def pixelXY_to_latlon(x, y):
69 | return (
70 | portworld_config.latlon_map[0][0] + y / scale,
71 | portworld_config.latlon_map[0][1] + x / scale,
72 | )
73 |
74 |
75 | def send_goal(lat, lon, yaw):
76 | x, y = latlon_to_pixelXY(lat, lon)
77 | graph.draw_circle((x, y), 10, fill_color="red", line_color="red")
78 | graph.DrawText(
79 | text=(round(lat, 5), round(lon, 5)),
80 | location=(x, y - 7),
81 | font=font,
82 | color="white",
83 | )
84 | api.send_gps_goal(lat, lon, yaw)
85 |
86 |
87 | def update_loop():
88 | while True:
89 | portworld_config.stat = api.goal_status()
90 | portworld_config.odom = api.pose_with_odometry()
91 | if "orientation" in portworld_config.odom:
92 | quat = portworld_config.odom["orientation"]
93 | portworld_config.odom["orientation"] = math.atan2(
94 | 2.0 * (quat["w"] * quat["z"]), 1.0 - 2.0 * (quat["z"] * quat["z"])
95 | )
96 | window.write_event_value("-UPDATE-", "updated")
97 | else:
98 | print(portworld_config.odom)
99 | time.sleep(1.2)
100 |
101 |
102 | def tolerance_check(goal, tol):
103 | if (
104 | abs(portworld_config.odom["position"]["latitude"] - goal[0]) < tol
105 | and abs(portworld_config.odom["position"]["longitude"] - goal[1]) < tol
106 | ):
107 | return True
108 | else:
109 | return False
110 |
111 |
112 | def graph_clean():
113 | graph.Erase()
114 | graph.DrawImage(filename="./images/portworld.png", location=(0, latdiff * scale))
115 |
116 |
117 | graph_clean()
118 |
119 | while True: # Main UI Loop
120 | event, values = window.read()
121 |
122 | if event == sg.WIN_CLOSED: # Handle closing window
123 | break
124 |
125 | # Only update and accept other commands if already connected
126 | if window["Connect"].get_text() == "Connected":
127 | window["-VEL-"].update(
128 | str(round(portworld_config.odom["odometry"]["linear.x"], 2)) + " m/s "
129 | )
130 | current_pose = (
131 | "lat: "
132 | + str(round(portworld_config.odom["position"]["latitude"], 6))
133 | + " lon: "
134 | + str(round(portworld_config.odom["position"]["longitude"], 6))
135 | + " angle: "
136 | + str(round(portworld_config.odom["orientation"], 3))
137 | )
138 | window["-POSE-"].update(current_pose)
139 | window["-STATUS-"].update(portworld_config.stat)
140 | draw_pose = latlon_to_pixelXY(
141 | portworld_config.odom["position"]["latitude"],
142 | portworld_config.odom["position"]["longitude"],
143 | )
144 | position = graph.draw_circle(
145 | draw_pose, 10, fill_color="white", line_color="black"
146 | )
147 |
148 | if event == "Return to Equipment Shed":
149 | graph_clean()
150 | send_goal(*portworld_config.shed_goal)
151 |
152 | if event == "STOP":
153 | graph_clean()
154 | api.cancel_prev_goal()
155 |
156 | if event == portworld_config.button_a[0]:
157 | graph_clean()
158 | send_goal(*portworld_config.button_a[1:])
159 |
160 | if event == portworld_config.button_b[0]:
161 | graph_clean()
162 | send_goal(*portworld_config.button_b[1:])
163 |
164 | if event == portworld_config.button_c[0]:
165 | graph_clean()
166 | send_goal(*portworld_config.button_c[1:])
167 |
168 | if event == portworld_config.button_d[0]:
169 | graph_clean()
170 | send_goal(*portworld_config.button_d[1:])
171 |
172 | if event == portworld_config.button_e[0]:
173 | graph_clean()
174 | send_goal(*portworld_config.button_e[1:])
175 |
176 | if event == "graph":
177 | graph_clean()
178 | x, y = values["graph"]
179 | lat, lon = pixelXY_to_latlon(x, y)
180 | send_goal(
181 | lat, lon, yaw=1.57
182 | ) # NOTE: Clicking on the map always sends orientation NORTH!
183 |
184 | if event == "Connect": # First time clicking the connect button, check we get UUID
185 | api = caladan_api.SimpleAPI(url, values[1], values[0])
186 | uuid_response = api.get_uuid()
187 | if "uuid" in uuid_response:
188 | window["-PROMPT-"].update(
189 | "Successfully connected to vehicle " + uuid_response["uuid"]
190 | )
191 | window["Connect"].update(button_color=("black", "green"))
192 | window.perform_long_operation(update_loop, "-OPERATION DONE-")
193 | window["Connect"].update("Connected")
194 | graph_clean()
195 | else:
196 | window["-PROMPT-"].update(
197 | uuid_response
198 | ) # otherwise, print returned error message
199 |
200 | window.close()
201 |
--------------------------------------------------------------------------------
/farmworld.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python3
2 |
3 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
4 | # Example farmworld UI for using the Caladan API in Python
5 | # Designed as a simple teaching example, not feature complete or fully robust.
6 |
7 | import time # used for sleep
8 | import math # used for some basic trigonometry
9 | import PySimpleGUI as sg # used for the Gui
10 | import caladan_api # example API library
11 | import config.farmworld_config as farmworld_config # simple convenience, used to store config values
12 |
13 | url = farmworld_config.api_url
14 | token = farmworld_config.token
15 | key = farmworld_config.key
16 | scale = 400000.0 # Used to change drawing scale of the map
17 | font = ("Courier New", 7)
18 | latdiff = abs(farmworld_config.latlon_map[0][0] - farmworld_config.latlon_map[1][0])
19 | londiff = abs(farmworld_config.latlon_map[0][1] - farmworld_config.latlon_map[1][1])
20 | api = caladan_api.SimpleAPI("", "", "") # Init to avoid flake8 issues
21 |
22 | sg.theme("DarkGrey10")
23 | layout = [
24 | [sg.Text("Please provide Token and Key below", key="-PROMPT-")],
25 | [sg.Input(token)],
26 | [sg.Input(key)],
27 | [sg.Button("Connect"), sg.Text("", key="-VEL-"), sg.Text("", key="-POSE-")],
28 | [
29 | sg.Graph(
30 | canvas_size=(londiff * scale, latdiff * scale),
31 | graph_bottom_left=(0, 0),
32 | graph_top_right=(londiff * scale, latdiff * scale),
33 | background_color="#1C1E23",
34 | enable_events=True,
35 | key="graph",
36 | )
37 | ],
38 | [
39 | sg.Button("Start Tilling"),
40 | sg.Button("STOP", button_color=("white", "red")),
41 | sg.Text("", key="-STATUS-", size=(45, None)),
42 | ],
43 | [
44 | sg.Button("Return to Equipment Shed"),
45 | sg.Input("lat", size=10, key="lat"),
46 | sg.Input("lon", size=10, key="lon"),
47 | sg.Input("ori", size=10, key="ori"),
48 | sg.Button("Send Goal"),
49 | ],
50 | ]
51 |
52 |
53 | window = sg.Window(
54 | "Polymath Robotics Caladan Farmworld Example",
55 | layout,
56 | icon="./images/icon.png",
57 | finalize=True,
58 | )
59 | graph = window["graph"]
60 |
61 |
62 | def latlon_to_pixelXY(lat, lon):
63 | return (
64 | -scale * (farmworld_config.latlon_map[0][1] - lon),
65 | -scale * (farmworld_config.latlon_map[0][0] - lat),
66 | )
67 |
68 |
69 | def pixelXY_to_latlon(x, y):
70 | return (
71 | farmworld_config.latlon_map[0][0] + y / scale,
72 | farmworld_config.latlon_map[0][1] + x / scale,
73 | )
74 |
75 |
76 | def send_goal(lat, lon, yaw):
77 | x, y = latlon_to_pixelXY(lat, lon)
78 | graph.draw_circle((x, y), 3, fill_color="#1C1E23", line_color="red")
79 | graph.DrawText(
80 | text=(round(lat, 5), round(lon, 5)),
81 | location=(x, y - 7),
82 | font=font,
83 | color="white",
84 | )
85 | api.send_gps_goal(lat, lon, yaw)
86 |
87 |
88 | def update_loop():
89 | while True:
90 | farmworld_config.stat = api.goal_status()
91 | farmworld_config.odom = api.pose_with_odometry()
92 | if "orientation" in farmworld_config.odom:
93 | quat = farmworld_config.odom["orientation"]
94 | farmworld_config.odom["orientation"] = math.atan2(
95 | 2.0 * (quat["w"] * quat["z"]), 1.0 - 2.0 * (quat["z"] * quat["z"])
96 | )
97 | window.write_event_value("-UPDATE-", "updated")
98 | else:
99 | print(farmworld_config.odom)
100 | time.sleep(1.2)
101 |
102 |
103 | def tolerance_check(goal, tol):
104 | if (
105 | abs(farmworld_config.odom["position"]["latitude"] - goal[0]) < tol
106 | and abs(farmworld_config.odom["position"]["longitude"] - goal[1]) < tol
107 | ):
108 | return True
109 | else:
110 | return False
111 |
112 |
113 | def tilling():
114 | for goal in farmworld_config.tilling_goals:
115 | send_goal(*goal)
116 | while not tolerance_check(goal, 0.00003):
117 | time.sleep(0.5)
118 |
119 |
120 | def graph_clean():
121 | graph.Erase()
122 | graph.DrawImage(filename="./images/farmworld.png", location=(0, latdiff * scale))
123 |
124 |
125 | graph_clean()
126 |
127 | while True: # Main UI Loop
128 | event, values = window.read()
129 |
130 | if event == sg.WIN_CLOSED: # Handle closing window
131 | break
132 |
133 | # Only update and accept other commands if already connected
134 | if window["Connect"].get_text() == "Connected":
135 | window["-VEL-"].update(
136 | str(round(farmworld_config.odom["odometry"]["linear.x"], 2)) + " m/s "
137 | )
138 | current_pose = (
139 | "lat: "
140 | + str(round(farmworld_config.odom["position"]["latitude"], 6))
141 | + " lon: "
142 | + str(round(farmworld_config.odom["position"]["longitude"], 6))
143 | + " angle: "
144 | + str(round(farmworld_config.odom["orientation"], 3))
145 | )
146 | window["-POSE-"].update(current_pose)
147 | window["-STATUS-"].update(farmworld_config.stat)
148 | draw_pose = latlon_to_pixelXY(
149 | farmworld_config.odom["position"]["latitude"],
150 | farmworld_config.odom["position"]["longitude"],
151 | )
152 | position = graph.draw_circle(
153 | draw_pose, 3, fill_color="#1C1E23", line_color="white"
154 | )
155 |
156 | if event == "Return to Equipment Shed":
157 | graph_clean()
158 | send_goal(*farmworld_config.shed_goal)
159 |
160 | if event == "Start Tilling":
161 | graph_clean()
162 | window.perform_long_operation(tilling, "-tilling DONE-")
163 |
164 | if event == "STOP":
165 | graph_clean()
166 | api.cancel_prev_goal()
167 |
168 | if event == "Send Goal":
169 | graph_clean()
170 | try:
171 | lat, lon, ori = (
172 | float(values["lat"]),
173 | float(values["lon"]),
174 | float(values["ori"]),
175 | )
176 | send_goal(lat, lon, ori)
177 | except ValueError:
178 | print(
179 | "You need to provide latitude, longitude, and orientation values in the text boxes!"
180 | )
181 |
182 | if event == "graph":
183 | graph_clean()
184 | x, y = values["graph"]
185 | lat, lon = pixelXY_to_latlon(x, y)
186 | send_goal(
187 | lat, lon, yaw=1.57
188 | ) # NOTE: Clicking on the map always sends orientation NORTH!
189 |
190 | if event == "Connect": # First time clicking the connect button, check we get UUID
191 | api = caladan_api.SimpleAPI(url, values[1], values[0])
192 | uuid_response = api.get_uuid()
193 | if "uuid" in uuid_response:
194 | window["-PROMPT-"].update(
195 | "Successfully connected to vehicle " + uuid_response["uuid"]
196 | )
197 | window["Connect"].update(button_color=("black", "green"))
198 | window.perform_long_operation(update_loop, "-OPERATION DONE-")
199 | window["Connect"].update("Connected")
200 | graph_clean()
201 | else:
202 | window["-PROMPT-"].update(
203 | uuid_response
204 | ) # otherwise, print returned error message
205 |
206 | window.close()
207 |
--------------------------------------------------------------------------------
/mineworld.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env python3
2 |
3 | # Copyright (c) 2022-present, Polymath Robotics, Inc.
4 | # Example mineworld UI for using the Caladan API in Python
5 | # Designed as a simple teaching example, not feature complete or fully robust.
6 |
7 | import time # used for sleep
8 | import math # used for some basic trigonometry
9 | import PySimpleGUI as sg # used for the Gui
10 | import caladan_api # example API library
11 | import config.mineworld_config as mineworld_config # simple convenience, used to store config values
12 |
13 | url = mineworld_config.api_url
14 | token = mineworld_config.token
15 | key = mineworld_config.key
16 | scale = 400000.0 # Used to change drawing scale of the map
17 | font = ("Courier New", 7)
18 | latdiff = abs(mineworld_config.latlon_map[0][0] - mineworld_config.latlon_map[1][0])
19 | londiff = abs(mineworld_config.latlon_map[0][1] - mineworld_config.latlon_map[1][1])
20 | api = caladan_api.SimpleAPI("", "", "") # Init to avoid flake8 issues
21 |
22 | sg.theme("DarkGrey10")
23 | layout = [
24 | [sg.Text("Please provide Token and Key below", key="-PROMPT-")],
25 | [sg.Input(token)],
26 | [sg.Input(key)],
27 | [sg.Button("Connect"), sg.Text("", key="-VEL-"), sg.Text("", key="-POSE-")],
28 | [
29 | sg.Graph(
30 | canvas_size=(londiff * scale, latdiff * scale),
31 | graph_bottom_left=(0, 0),
32 | graph_top_right=(londiff * scale, latdiff * scale),
33 | background_color="#1C1E23",
34 | enable_events=True,
35 | key="graph",
36 | )
37 | ],
38 | [
39 | sg.Button("Return to Equipment Shed"),
40 | sg.Button("STOP", button_color=("white", "red")),
41 | sg.Text("", key="-STATUS-", size=(45, None)),
42 | ],
43 | [
44 | sg.Button(mineworld_config.button_a[0]),
45 | sg.Button(mineworld_config.button_b[0]),
46 | sg.Button(mineworld_config.button_c[0]),
47 | ],
48 | [
49 | sg.Button(mineworld_config.button_d[0]),
50 | sg.Button(mineworld_config.button_e[0]),
51 | sg.Button(mineworld_config.button_f[0]),
52 | sg.Button(mineworld_config.button_g[0]),
53 | ],
54 | ]
55 |
56 |
57 | window = sg.Window(
58 | "Polymath Robotics Caladan mineworld Example",
59 | layout,
60 | icon="./images/icon.png",
61 | finalize=True,
62 | )
63 | graph = window["graph"]
64 |
65 |
66 | def latlon_to_pixelXY(lat, lon):
67 | return (
68 | -scale * (mineworld_config.latlon_map[0][1] - lon),
69 | -scale * (mineworld_config.latlon_map[0][0] - lat),
70 | )
71 |
72 |
73 | def pixelXY_to_latlon(x, y):
74 | return (
75 | mineworld_config.latlon_map[0][0] + y / scale,
76 | mineworld_config.latlon_map[0][1] + x / scale,
77 | )
78 |
79 |
80 | def send_goal(lat, lon, yaw):
81 | x, y = latlon_to_pixelXY(lat, lon)
82 | graph.draw_circle((x, y), 3, fill_color="#1C1E23", line_color="red")
83 | graph.DrawText(
84 | text=(round(lat, 5), round(lon, 5)),
85 | location=(x, y - 7),
86 | font=font,
87 | color="white",
88 | )
89 | api.send_gps_goal(lat, lon, yaw)
90 |
91 |
92 | def update_loop():
93 | while True:
94 | mineworld_config.stat = api.goal_status()
95 | mineworld_config.odom = api.pose_with_odometry()
96 | if "orientation" in mineworld_config.odom:
97 | quat = mineworld_config.odom["orientation"]
98 | mineworld_config.odom["orientation"] = math.atan2(
99 | 2.0 * (quat["w"] * quat["z"]), 1.0 - 2.0 * (quat["z"] * quat["z"])
100 | )
101 | window.write_event_value("-UPDATE-", "updated")
102 | else:
103 | print(mineworld_config.odom)
104 | time.sleep(1.2)
105 |
106 |
107 | def tolerance_check(goal, tol):
108 | if (
109 | abs(mineworld_config.odom["position"]["latitude"] - goal[0]) < tol
110 | and abs(mineworld_config.odom["position"]["longitude"] - goal[1]) < tol
111 | ):
112 | return True
113 | else:
114 | return False
115 |
116 |
117 | def bulldoze():
118 | while True: # Cancelled by the STOP button, as this cancels any goal
119 | graph_clean()
120 | for goal in mineworld_config.bulldoze:
121 | send_goal(*goal)
122 | while not tolerance_check(goal, 0.00003):
123 | time.sleep(0.5)
124 |
125 |
126 | def dump():
127 | while True: # Cancelled by the STOP button, as this cancels any goal
128 | graph_clean()
129 | for goal in mineworld_config.dump:
130 | send_goal(*goal)
131 | while not tolerance_check(goal, 0.00003):
132 | time.sleep(0.5)
133 |
134 |
135 | def graph_clean():
136 | graph.Erase()
137 | graph.DrawImage(filename="./images/mineworld.png", location=(0, latdiff * scale))
138 |
139 |
140 | graph_clean()
141 |
142 | while True: # Main UI Loop
143 | event, values = window.read()
144 |
145 | if event == sg.WIN_CLOSED: # Handle closing window
146 | break
147 |
148 | # Only update and accept other commands if already connected
149 | if window["Connect"].get_text() == "Connected":
150 | window["-VEL-"].update(
151 | str(round(mineworld_config.odom["odometry"]["linear.x"], 2)) + " m/s "
152 | )
153 | current_pose = (
154 | "lat: "
155 | + str(round(mineworld_config.odom["position"]["latitude"], 6))
156 | + " lon: "
157 | + str(round(mineworld_config.odom["position"]["longitude"], 6))
158 | + " angle: "
159 | + str(round(mineworld_config.odom["orientation"], 3))
160 | )
161 | window["-POSE-"].update(current_pose)
162 | window["-STATUS-"].update(mineworld_config.stat)
163 | draw_pose = latlon_to_pixelXY(
164 | mineworld_config.odom["position"]["latitude"],
165 | mineworld_config.odom["position"]["longitude"],
166 | )
167 | position = graph.draw_circle(
168 | draw_pose, 3, fill_color="#1C1E23", line_color="white"
169 | )
170 |
171 | if event == "Return to Equipment Shed":
172 | graph_clean()
173 | send_goal(*mineworld_config.shed_goal)
174 |
175 | if event == "STOP":
176 | graph_clean()
177 | api.cancel_prev_goal()
178 |
179 | if event == mineworld_config.button_a[0]:
180 | graph_clean()
181 | send_goal(*mineworld_config.button_a[1:])
182 |
183 | if event == mineworld_config.button_b[0]:
184 | graph_clean()
185 | send_goal(*mineworld_config.button_b[1:])
186 |
187 | if event == mineworld_config.button_c[0]:
188 | graph_clean()
189 | send_goal(*mineworld_config.button_c[1:])
190 |
191 | if event == mineworld_config.button_d[0]:
192 | graph_clean()
193 | window.perform_long_operation(bulldoze, "-bulldoze DONE-")
194 |
195 | if event == mineworld_config.button_e[0]:
196 | graph_clean()
197 | window.perform_long_operation(dump, "-dump DONE-")
198 |
199 | if event == mineworld_config.button_f[0]:
200 | graph_clean()
201 | send_goal(
202 | mineworld_config.odom["position"]["latitude"],
203 | mineworld_config.odom["position"]["longitude"],
204 | mineworld_config.button_f[1],
205 | )
206 |
207 | if event == mineworld_config.button_g[0]:
208 | graph_clean()
209 | send_goal(
210 | mineworld_config.odom["position"]["latitude"],
211 | mineworld_config.odom["position"]["longitude"],
212 | mineworld_config.button_g[1],
213 | )
214 |
215 | if event == "graph":
216 | graph_clean()
217 | x, y = values["graph"]
218 | lat, lon = pixelXY_to_latlon(x, y)
219 | send_goal(
220 | lat, lon, yaw=0
221 | ) # NOTE: Clicking on the map always sends orientation 0!
222 |
223 | if event == "Connect": # First time clicking the connect button, check we get UUID
224 | api = caladan_api.SimpleAPI(url, values[1], values[0])
225 | uuid_response = api.get_uuid()
226 | if "uuid" in uuid_response:
227 | window["-PROMPT-"].update(
228 | "Successfully connected to vehicle " + uuid_response["uuid"]
229 | )
230 | window["Connect"].update(button_color=("black", "green"))
231 | window.perform_long_operation(update_loop, "-OPERATION DONE-")
232 | window["Connect"].update("Connected")
233 | graph_clean()
234 | else:
235 | window["-PROMPT-"].update(
236 | uuid_response
237 | ) # otherwise, print returned error message
238 |
239 | window.close()
240 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------