isar 1.19.1__py3-none-any.whl → 1.20.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of isar might be problematic. Click here for more details.

@@ -1,433 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: isar
3
- Version: 1.19.1
4
- Summary: Integration and Supervisory control of Autonomous Robots
5
- Home-page: https://github.com/equinor/isar
6
- Author: Equinor ASA
7
- Author-email: fg_robots_dev@equinor.com
8
- Classifier: Environment :: Other Environment
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: Programming Language :: Python
12
- Classifier: Topic :: Scientific/Engineering
13
- Classifier: Topic :: Scientific/Engineering :: Physics
14
- Classifier: Topic :: Software Development :: Libraries
15
- Requires-Python: >=3.11
16
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
- Requires-Dist: alitra >=1.1.3
19
- Requires-Dist: azure-identity
20
- Requires-Dist: azure-keyvault-secrets
21
- Requires-Dist: azure-storage-blob
22
- Requires-Dist: backoff
23
- Requires-Dist: click
24
- Requires-Dist: dacite
25
- Requires-Dist: fastapi-azure-auth
26
- Requires-Dist: fastapi
27
- Requires-Dist: injector
28
- Requires-Dist: opencensus-ext-logging
29
- Requires-Dist: opencensus-ext-requests
30
- Requires-Dist: opencensus-ext-azure
31
- Requires-Dist: numpy
32
- Requires-Dist: paho-mqtt
33
- Requires-Dist: pydantic
34
- Requires-Dist: pydantic-settings
35
- Requires-Dist: PyJWT
36
- Requires-Dist: python-dotenv
37
- Requires-Dist: PyYAML
38
- Requires-Dist: requests-toolbelt
39
- Requires-Dist: requests
40
- Requires-Dist: transitions
41
- Requires-Dist: uvicorn
42
- Provides-Extra: dev
43
- Requires-Dist: black ; extra == 'dev'
44
- Requires-Dist: flake8 ; extra == 'dev'
45
- Requires-Dist: mypy ; extra == 'dev'
46
- Requires-Dist: myst-parser ; extra == 'dev'
47
- Requires-Dist: pre-commit ; extra == 'dev'
48
- Requires-Dist: pytest-dotenv ; extra == 'dev'
49
- Requires-Dist: pytest-mock ; extra == 'dev'
50
- Requires-Dist: pytest-xdist ; extra == 'dev'
51
- Requires-Dist: pytest ; extra == 'dev'
52
- Requires-Dist: requests-mock ; extra == 'dev'
53
- Requires-Dist: sphinx ; extra == 'dev'
54
-
55
- # ISAR
56
-
57
- [![Python package](https://github.com/equinor/isar/actions/workflows/pythonpackage.yml/badge.svg)](https://github.com/equinor/isar/actions/workflows/pythonpackage.yml)
58
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
59
- [![License](https://img.shields.io/badge/License-EPL_2.0-blue.svg)](https://opensource.org/licenses/EPL-2.0)
60
-
61
- ISAR - Integration and Supervisory control of Autonomous Robots - is a tool for integrating robot applications into
62
- operator systems. Through the ISAR API you can send commands to a robot to do missions and collect results from the
63
- missions.
64
-
65
- ## Getting started
66
-
67
- Steps:
68
-
69
- - Install
70
- - Integrate a robot
71
- - Run the ISAR server
72
- - Run a robot mission
73
-
74
- ### Install
75
-
76
- For local development, please fork the repository. Then, clone and install in the repository root folder:
77
-
78
- ```
79
- git clone https://github.com/<path_to_parent>/isar
80
- cd isar
81
- pip install -e .[dev]
82
- ```
83
-
84
- For `zsh` you might have to type `".[dev]"`
85
-
86
- Verify that you can run the tests:
87
-
88
- ```bash
89
- pytest .
90
- ```
91
-
92
- The repository contains a configuration file for installing pre-commit hooks. Currently, [black](https://github.com/psf/black) and a mirror of [mypy](https://github.com/pre-commit/mirrors-mypy) are configured hooks. Install with:
93
-
94
- ```
95
- pre-commit install
96
- ```
97
-
98
- Verify that pre-commit runs:
99
-
100
- ```
101
- pre-commit
102
- ```
103
-
104
- pre-commit will now run the installed hooks before code is commited to git. To turn pre-commit off, run:
105
-
106
- ```
107
- pre-commit uninstall
108
- ```
109
-
110
- ### Robot integration
111
-
112
- To connect the state machine to a robot in a separate repository, it is required that the separate repository implements
113
- the [robot interface](https://github.com/equinor/isar/blob/main/src/robot_interface/robot_interface.py).
114
- The separate repository should also have a settings.env file in a config folder where `CAPABILITIES` and `ROBOT_MODEL` are set.
115
- A mocked robot can be found in [this repository](https://github.com/equinor/isar-robot). Install the repo, i.e:
116
-
117
- ```bash
118
- pip install isar-robot
119
- ```
120
-
121
- NB: isar-robot has not been published to PyPi for some time, and needs to be downloaded directly
122
- from git to work.
123
-
124
- Then, ensure the `ISAR_ROBOT_PACKAGE` variable in [settings.env](./src/isar/config/settings.env)
125
- is set to the name of the package you installed. `isar_robot` is set by default. See the section
126
- for [configuration](#configuration) for overwriting configuration.
127
-
128
- If you have the robot repository locally, you can simply install through
129
-
130
- ```bash
131
- pip install -e /path/to/robot/repo/
132
- ```
133
-
134
- #### Running ISAR with a robot simulator
135
-
136
- A simulator based on the open source robot Turtlebot3 has been implemented for use with ISAR and may be
137
- found [here](https://github.com/equinor/isar-turtlebot). Follow the installation instructions for the simulator and
138
- install `isar-turtlebot` in the same manner as given in the [robot integration](#robot-integration) section. Overwrite
139
- the following configuration variables:
140
-
141
- ```bash
142
- ISAR_ROBOT_PACKAGE = isar_turtlebot
143
- ISAR_DEFAULT_MAP = turtleworld
144
- ```
145
-
146
- ### Run ISAR server
147
-
148
- To run ISAR:
149
-
150
- ```bash
151
- python main.py
152
- ```
153
-
154
- Note, running the full system requires that an implementation of a robot has been installed. See
155
- this [section](#robot-integration) for installing a mocked robot or a Turtlebot3 simulator.
156
-
157
- ### Running a robot mission
158
-
159
- Once the application has been started the swagger site may be accessed at
160
-
161
- ```
162
- http://localhost:3000/docs
163
- ```
164
-
165
- Execute the `/schedule/start-mission` endpoint with `mission_id=1` to run a mission.
166
-
167
- In [this](./src/isar/config/predefined_missions) folder there are predefined default missions, for example the mission
168
- corresponding to `mission_id=1`. A new mission may be added by adding a new json-file with a mission description. Note,
169
- the mission IDs must be unique.
170
-
171
- ### Running with docker-compose
172
-
173
- ISAR may be started with an instance of the [isar-robot](https://github.com/equinor/isar-robot) package by
174
-
175
- ```shell
176
- docker-compose up --build
177
- ```
178
-
179
- Provided that the simulator from [isar-turtlebot](https://github.com/equinor/isar-turtlebot) is running ISAR may be
180
- started with the turtlebot by
181
-
182
- ```shell
183
- docker-compose -f docker-compose-turtlebot.yml up --build
184
- ```
185
-
186
- ### Configuration
187
-
188
- The system consists of many configuration variables which may alter the functionality. As an example, it is possible to
189
- change mission planners or add multiple storage handlers as described in the [mission planner](#mission-planner)
190
- and [storage](#storage) sections.
191
-
192
- There are two methods of specifying configuration.
193
-
194
- 1. Override the default value by setting an environment variable.
195
-
196
- Every configuration variable is defined in [settings.py](./src/isar/config/settings.py), and they may all be
197
- overwritten by specifying the variables in the environment instead. Note that the configuration variable must be
198
- prefixed with `ISAR_` when specified in the environment. So for the `ROBOT_PACKAGE`configuration variable:
199
-
200
- ```shell
201
- export ISAR_ROBOT_PACKAGE=isar_turtlebot
202
- ```
203
-
204
- This means ISAR will connect to `isar_turtlebot` robot package.
205
-
206
- 2. Adding environment variables through [settings.env](./src/isar/config/settings.env).
207
-
208
- By adding environment variables with the prefix `ISAR_` to the [settings.env](./src/isar/config/settings.env) file
209
- the configuration variables will be overwritten by the values in this file.
210
-
211
- ### Running tests
212
-
213
- After following the steps in [Development](#install), you can run the tests:
214
-
215
- ```bash
216
- pytest .
217
- ```
218
-
219
- To create an interface test in your robot repository, use the function `interface_test` from `robot_interface`. The
220
- argument should be an interface object from your robot specific implementation.
221
- See [isar-robot](https://github.com/equinor/isar-robot/blob/main/tests/interfaces/test_robotinterface.py) for example.
222
-
223
- #### Integration tests
224
-
225
- Integration tests can be found [here](https://github.com/equinor/isar/tree/main/tests/integration) and have been created
226
- with a simulator in mind. The integration tests will not run as part of `pytest .` or as part of the CI/CD pipeline. To
227
- run the integration tests please follow the instructions in [this section](#running-isar-with-a-robot-simulator) for
228
- setting up the `isar-turtlebot` implementation with simulator and run the following command once the simulation has been
229
- launched.
230
-
231
- ```bash
232
- pytest tests/integration
233
- ```
234
-
235
- Note that these tests will run towards the actual simulation (you may monitor it through Gazebo and RVIZ) and it will
236
- take a long time.
237
-
238
- ### Documentation
239
-
240
- To build the project documentation, run the following commands:
241
-
242
- ```bash
243
- cd docs
244
- make docs
245
- ```
246
-
247
- The documentation can now be viewed at `docs/build/html/index.html`.
248
-
249
- ## Components
250
-
251
- The system consists of two main components.
252
-
253
- 1. State machine
254
- 1. FastAPI
255
-
256
- ### State machine
257
-
258
- The state machine handles interaction with the robots API and monitors the execution of missions. It also enables
259
- interacting with the robot before, during and after missions.
260
-
261
- The state machine is based on the [transitions](https://github.com/pytransitions/transitions) package for Python. An visualization of the state machine can be seen below:
262
- ![State Machine](./docs/state_machine_diagram.png)
263
-
264
- In general the states
265
-
266
- ```
267
- States.Off,
268
- States.Initialize,
269
- States.Initiate,
270
- States.Stop,
271
- States.Monitor,
272
- States.Paused,
273
- ```
274
-
275
- indicates that the state machine is already running. For running a mission the state machine need to be in the state
276
-
277
- ```
278
- States.Idle
279
- ```
280
-
281
- ### FastAPI
282
-
283
- The FastAPI establishes an interface to the state machine for the user. As the API and state machine are separate
284
- threads, they communicate through python queues. FastAPI runs on an ASGI-server, specifically uvicorn. The
285
- FastAPI-framework is split into routers where the endpoint operations are defined.
286
-
287
- ## Mission planner
288
-
289
- The mission planner that is currently in use is a local mission planner, where missions are specified in a json file. You can create your own mission planner by implementing
290
- the [mission planner interface](./src/isar/mission_planner/mission_planner_interface.py) and adding your planner to the
291
- selection [here](./src/isar/modules.py). Note that you must add your module as an option in the dictionary.
292
-
293
- ## Storage
294
-
295
- The storage modules that are used is defined by the `ISAR_STORAGE` configuration variable. This can be changed by
296
- overriding the configuration through an environment variable. It accepts a json encoded list and will use each element
297
- in the list to retrieve the corresponding handler. The current options are
298
-
299
- ```
300
- ISAR_STORAGE = '["local", "blob", "slimm"]'
301
- ```
302
-
303
- Note that the `blob` and `slimm` options require special configuration to authenticate to these endpoints.
304
-
305
- ### Implement your own storage module
306
-
307
- You can create your own storage module by implementing the [storage interface](./src/isar/storage/storage_interface.py)
308
- and adding your storage module to the selection [here](./src/isar/modules.py). Note that you must add your module as an
309
- option in the dictionary.
310
-
311
- ## Task selection
312
-
313
- The tasks of a mission are selected based on a task selector module, defined by the `TASK_SELECTOR` configuration variable. The default task selector is `sequential`. When using the default module, tasks are executed in sequential order defined by the current input mission.
314
-
315
- ### Implement you own task selector module
316
-
317
- Custom task selector modules may be added by implementing additional versions of the [task selector interface](./src/isar/mission_planner/task_selector_interface.py).
318
-
319
- For every custom module, the interface function `next_task()` must be implemented. All interface implementations by default have access to the list of tasks in the current mission through the member `self.tasks`, however additional variables may be supplied by adding arguments to `next_task()`. To comply with the interface definition, the function should return the next task upon every call, and raise the `TaskSelectorStop` exception when all tasks in the current mission have been completed:
320
-
321
- ```python
322
- class CustomTaskSelector(TaskSelectorInterface):
323
- ...
324
- def next_task(...) -> Task:
325
-
326
- # Add code here
327
- ...
328
-
329
- # Raise `TaskSelectorStop` when all tasks have been completed
330
- ...
331
- ```
332
-
333
- Optionally, the `initialize()` function may be extended by supplementing the parameter list or function body:
334
-
335
- ```python
336
- class CustomTaskSelector(TaskSelectorInterface):
337
- ...
338
- def initialize(self, tasks: List[Task], ...) -> None:
339
- super.initialize(tasks=tasks)
340
-
341
- # Add supplementary code here
342
- ...
343
- ```
344
-
345
- A custom task selector may be made available during [module selection](./src/isar/modules.py) by adding it to the series of options in the dictionary of injector modules. It can then be activated by overriding the task selector configuration variable:
346
-
347
- ```python
348
- # Add custom task selector module to `modules.py`
349
-
350
- class CustomTaskSelectorModule(Module):
351
- @provider
352
- @singleton
353
- def provide_task_selector(self) -> TaskSelectorInterface:
354
- return CustomTaskSelector()
355
-
356
- ...
357
-
358
- # Make it available to select during injector instantiation
359
-
360
- modules: dict[str, tuple[Module, Union[str, bool]]] = {
361
- ...
362
- "task_selector": (
363
- {
364
- "sequential": SequentialTaskSelectorModule,
365
- "custom": CustomTaskSelectorModule
366
- }
367
- ...
368
- )
369
- ...
370
- }
371
- ```
372
-
373
- ## API authentication
374
-
375
- The API has an option to include user authentication. This can be enabled by setting the environment variable
376
-
377
- ```
378
- ISAR_AUTHENTICATION_ENABLED = true
379
- ```
380
-
381
- By default, the `local` storage module is used and API authentication is disabled. If using Azure Blob Storage a set of
382
- environment variables must be available which gives access to an app registration that may use the storage account.
383
- Enabling API authentication also requires the same environment variables. The required variables are
384
-
385
- ```
386
- AZURE_CLIENT_ID
387
- AZURE_TENANT_ID
388
- AZURE_CLIENT_SECRET
389
- ```
390
-
391
- ## MQTT communication
392
-
393
- ISAR is able to publish parts of its internal state to topics on an MQTT broker whenever they change. This is by default
394
- turned off but may be activated by setting the environment variable
395
-
396
- ```
397
- ISAR_MQTT_ENABLED = true
398
- ```
399
-
400
- The connection to the broker will be determined by the following configuration values in `settings.py`
401
-
402
- ```
403
- ISAR_MQTT_USERNAME
404
- ISAR_MQTT_HOST
405
- ISAR_MQTT_PORT
406
- ```
407
-
408
- The default values of these are overwritten by the environment in `settings.env`.
409
-
410
- To specify broker password, add the following environment variable to a .env file in the root of the repository:
411
-
412
- ```
413
- ISAR_MQTT_PASSWORD
414
- ```
415
-
416
- If not specified the password will default to an empty string.
417
-
418
- ## Running several ISAR instances locally
419
-
420
- To run several ISAR instances in parallel locally:
421
- 1. Generate a guid: https://www.guidgenerator.com/
422
- 2. Open a new terminal in the isar folder
423
- 3. Run the following command before running main.py:
424
-
425
- ```
426
- export ISAR_API_PORT=port_name_higher_than_1024 ISAR_ISAR_ID=guid ISAR_ROBOT_NAME=random_robot_name
427
- ```
428
-
429
- # Contributions
430
-
431
- Equinor welcomes all kinds of contributions, including code, bug reports, issues, feature requests, and documentation
432
- Please initiate your contribution by creating an [issue](https://github.com/equinor/isar/issues) or by forking the
433
- project and making a pull requests. Commit messages shall be written according to [this guide](https://cbea.msgit-commit/).
File without changes
File without changes