Skip to content

Commit a5d4d16

Browse files
author
Stepan dergachev
committed
Update README with XML format description and remove old xml files.
1 parent adf256a commit a5d4d16

13 files changed

Lines changed: 193 additions & 123 deletions

README.md

Lines changed: 145 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Before start using this project you need to install the required dependencies:
88

99
1. `Python 3.11`
1010
2. `pip`
11-
3. `numpy`
12-
4. `lxml`
13-
3. `IPython` and `Jupyter Notebook` (for running Jupyter notebooks)
11+
3. `setuptools`
12+
4. `numpy`
13+
5. `lxml`
14+
6. `IPython` and `Jupyter Notebook` (for running Jupyter notebooks)
1415

1516
Next, you need to run this script from the root folder of this project to install it across all system:
1617

@@ -29,7 +30,147 @@ experiments.
2930
* `manavlib.io.tswap_io`: functions to support the setup, conversion, and processing of multi-agent pathfinding experiments to evaluate the TSWAP algorithm.
3031
* `manavlib.utils`: various auxiliary tools. Сurrently include functions for finding paths on grids.
3132

32-
Examples of XML files are located in the `xml-examples` folder. You can find usage examples for the `manavlib.common.params` and `manavlib.io.xml_io` modules in the Jupyter Notebook `test/xml_io_test.ipynb`.
33+
You can find usage examples for the `manavlib.common.params` and `manavlib.io.xml_io` modules in the Jupyter Notebook `test/xml_io_test.ipynb`.
34+
35+
## XML File Structure
36+
37+
One of the key components of this repository is a module `manavlib.io.xml_io` that allows to read experiment configurations from XML files of a special structure. It is assumed that each experiment is described by three types of files: an environment file `map.xml`, an agents/task description file `task.xml`, and an experiment/algorithm configuration file `config.xml`.
38+
39+
Examples of XML files are located in the `xml-examples` folder. An usage examples for `manavlib.io.xml_io` module (with custom agent, algorithm and experiment parameters) is located in the Jupyter Notebook `test/xml_io_test.ipynb`.
40+
41+
### Environment Description `map.xml`
42+
43+
The file includes a description of the environment, namely an obstacle map. Currently only static map description in grid format is supported.
44+
45+
#### Structure
46+
47+
* **Root Element `<root>`**: The entire content of the XML file is wrapped inside the `<root>` element.
48+
* **Occupancy Grid Element `<occupancy_grid>`**: Defines the grid map structure and its properties. It contains metadata about the grid, such as its dimensions and cell size, as well as the grid layout itself.
49+
* **Width Element `<width>`**: Specifies the width of the grid map in the number of cells (columns).
50+
* **Height Element `<height>`**: Specifies the height of the grid map in the number of cells (rows).
51+
* **Cell Size Element `<cell_size>`**: Defines the size of each cell in the grid. This value is used for scaling and pathfinding calculations.
52+
* **Grid Element `<grid>`**: Contains the layout of the map, represented as a matrix of cells.
53+
* **Row Elements `<row>`**: Each `<row>` element represents a single row of the grid. The values within each row indicate the state of the corresponding cell: `0` represents a free cell (traversable), `1` represents an obstacle (non-traversable).
54+
55+
#### Example
56+
57+
```xml
58+
<?xml version="1.0" ?>
59+
<root>
60+
<occupancy_grid>
61+
<width>10</width>
62+
<height>10</height>
63+
<cell_size>1.0</cell_size>
64+
<grid>
65+
<row>0 0 0 0 0 0 0 0 0 0</row>
66+
<row>0 0 0 0 0 0 0 0 0 0</row>
67+
<row>0 0 1 1 1 1 0 0 0 0</row>
68+
<row>0 0 0 0 0 0 0 0 0 0</row>
69+
<row>0 0 0 0 0 0 0 0 0 0</row>
70+
<row>0 0 0 0 0 0 0 0 0 0</row>
71+
<row>0 0 0 0 0 0 0 0 0 0</row>
72+
<row>0 0 0 0 0 0 0 0 0 0</row>
73+
<row>0 0 0 0 0 0 0 0 0 0</row>
74+
<row>0 0 0 0 0 0 0 0 0 0</row>
75+
</grid>
76+
</occupancy_grid>
77+
</root>
78+
```
79+
80+
### Task description `task.xml`
81+
82+
The file includes a task description, namely default agent configurations, initial and goal agent positions (there are two possible options to set positions: discrete and continuous) and (optionally) the configuration of each particular agent. This file defines parameters of agents such as the agent’s type, size, visibility radius, and motion parameters.
83+
84+
The possible agent types are defined in module `manavlib.common.params`. You can define your own agent type by creating a class in your workspace that inherits from `BaseAgentParams`.
85+
86+
An example of creating and reading of task file with custom agents is located in the Jupyter Notebook `test/xml_io_test.ipynb`.
87+
88+
#### Structure
89+
90+
* **Root Element `<root>`**: The entire content of the XML file is wrapped inside the `<root>` element.
91+
* **Default Agent Element `<default_agent>`**: Specifies the default parameters that apply to all agents unless explicitly overridden for a particular agent. In general, the particular set of attributes is specified by the agent type, but each agent type basycally includes the following attributes:
92+
* **`model_type` (mandatory)**: The type of agent model, e.g., `diff_drive`, `holonomic`, or `base_discrete`.
93+
* **`size`**: The size (radius) of the agent.
94+
* **`r_vis`**: Visibility radius of the agent, used for determining the communication range.
95+
* The agent configuration can include custom parameters. The following data types are supported: `str`, `int`, `float`, `bool`.
96+
* **Agents Element: `<agents>`**: Contains the list of individual agents, where `N` is the total number of agents specified by the `number` attribute.
97+
* **Agent Elements: `<agent>`**: Defines an individual agent. The attributes of the element can include:
98+
* **`id` (mandatory)**: An unique identifier for the agent.
99+
* **Initial State (`s.` prefix, mandatory)**:
100+
* **`s.x, s.y, s.th`**: The initial `x` and `y` coordinates and orientation in radians `theta` (for continuous models).
101+
* **`s.i, s.j`**: The initial row (`i`) and column (`j`) indices (for discrete models).
102+
* **Goal State (`g.` prefix, mandatory)**:
103+
* **`g.x, g.y, g.th`**: The initial `x` and `y` coordinates and orientation in radians `theta` (for continuous models).
104+
* **`g.i, g.j`**: The initial row (`i`) and column (`j`) indices (for discrete models).
105+
* **Model-Specific Parameters**: These can override the default agent parameters defined in <default_agent>, such as `model_type`, `size`, `r_vis`, etc. The following data types are supported: `str`, `int`, `float`, `bool`.
106+
107+
#### Example (Continuous)
108+
109+
```xml
110+
<?xml version="1.0" ?>
111+
<root>
112+
<default_agent model_type="diff_drive" size="68.0" r_vis="57.0" v_max="68.0" v_min="64.0" w_max="36.0" w_min="54.0"/>
113+
<agents number="2">
114+
<agent id="0" s.x="75.5" s.y="96.5" s.th="3.378" g.x="10.5" g.y="11.5" g.th="2.995" model_type="diff_drive" size="68.0" r_vis="57.0" v_max="68.0" v_min="64.0" w_max="36.0" w_min="54.0"/>
115+
<agent id="1" s.x="24.5" s.y="41.5" s.th="3.009" g.x="2.5" g.y="43.5" g.th="3.293" model_type="holonomic" size="7.0" r_vis="9.0" vel_max="47.0"/>
116+
</agents>
117+
</root>
118+
```
119+
120+
#### Example (Discrete)
121+
122+
```xml
123+
<?xml version="1.0" ?>
124+
<root>
125+
<default_agent model_type="base_discrete" size="57.0" r_vis="64"/>
126+
<agents number="3">
127+
<agent id="0" s.i="0" s.j="5" g.i="3" g.j="9"/>
128+
<agent id="1" s.i="5" s.j="4" g.i="0" g.j="2"/>
129+
<agent id="2" s.i="2" s.j="4" g.i="4" g.j="7"/>
130+
</agents>
131+
</root>
132+
```
133+
134+
### Experiment configuration `config.xml`
135+
136+
This file defines the configuration for the experiment and the algorithm used in multi-agent pathfinding tasks. It specifies both general experiment settings and the parameters of the algorithm to be applied to all agents in the experiment. Currently, only the configuration of single algorithm is supported.
137+
138+
The base algorithm's parameters class is defined in module `manavlib.common.params`. You need to define your own algorithm's parameters class that inherits from `BaseAlgParams`.
139+
140+
The class with the experiment parameters `ExperimentParams` is also defined in module `manavlib.common.params`. If it is necessary to add custom parameters of the experiment, you need to define your own class, which will globally overwrite the name `ExperimentParams`.
141+
142+
An example of creating and reading of config file with custom agents is located in the Jupyter Notebook `test/xml_io_test.ipynb`.
143+
144+
#### Structure
145+
146+
* **Root Element `<root>`**: The entire content of the XML file is wrapped inside the `<root>` element.
147+
* **Experiment Element `<experiment>`**: Contains general settings for the experiment. It includes parameters that control the overall behavior of the simulation
148+
* **`timestep`**: Defines the duration of each discrete time step in the experiment.
149+
* **`xy_goal_tolerance`**: Defines the tolerance for reaching the goal position. Agents are considered to have reached their goal if they are within this distance
150+
* **`max_steps`**: The maximum number of time steps allowed for the experiment. If this limit is reached, the simulation terminates even if not all agents have reached their goals.
151+
* The experiment configuration can include custom parameters. The following data types are supported: `str`, `int`, `float`, `bool`.
152+
* **Algorithm Element `<algorithm>`**: Specifies the configuration for the algorithm to be applied to all agents in the experiment. The `name` attribute defines the algorithm’s name (e.g., "example_alg"), which should match the implemented algorithm class in the code. Only one `<algorithm>` element is currently supported per configuration file, and its settings are applied uniformly to all agents.
153+
* The parameters listed under the `<algorithm>` element are specific to the selected algorithm and are used to control its behavior during the simulation. The following data types are supported: `str`, `int`, `float`, `bool`.
154+
155+
#### Example
156+
157+
```xml
158+
<?xml version="1.0" ?>
159+
<root>
160+
<experiment>
161+
<timestep>0.1</timestep>
162+
<xy_goal_tolerance>0.3</xy_goal_tolerance>
163+
<max_steps>100</max_steps>
164+
<custom_param>42</some_param1>
165+
</experiment>
166+
<algorithm name="example_alg">
167+
<a_param>85</a_param>
168+
<b_param>89.0</b_param>
169+
<c_param>False</c_param>
170+
<d_param>direct</d_param>
171+
</algorithm>
172+
</root>
173+
```
33174

34175
## Scripts
35176

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# For a discussion on single-sourcing the version across setup.py and the
3232
# project code, see
3333
# https://packaging.python.org/guides/single-sourcing-package-version/
34-
version="0.1", # Required
34+
version="1.0", # Required
3535
# This is a one-line description or tagline of what your project does. This
3636
# corresponds to the "Summary" metadata field:
3737
# https://packaging.python.org/specifications/core-metadata/#summary

test/xml_io_test.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": null,
87+
"execution_count": 5,
8888
"metadata": {},
8989
"outputs": [
9090
{
@@ -173,7 +173,7 @@
173173
},
174174
{
175175
"cell_type": "code",
176-
"execution_count": null,
176+
"execution_count": 7,
177177
"metadata": {},
178178
"outputs": [],
179179
"source": [
@@ -208,14 +208,14 @@
208208
},
209209
{
210210
"cell_type": "code",
211-
"execution_count": null,
211+
"execution_count": 8,
212212
"metadata": {},
213213
"outputs": [
214214
{
215215
"name": "stdout",
216216
"output_type": "stream",
217217
"text": [
218-
"{'timestep': 0.0, 'xy_goal_tolerance': 0.0, 'max_steps': 0, 'some_param1': 0, 'some_param2': 0.0}\n"
218+
"{'timestep': 0.0, 'xy_goal_tolerance': 0.0, 'max_steps': 0, 'some_param1': 0, 'some_param2': 0.0, 'c_param': True, 'd_param': 'abcd'}\n"
219219
]
220220
}
221221
],

xml-examples/all_custom_params.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" ?>
22
<root>
3-
<default_agent model_type="diff_drive" size="68.0" r_vis="57.0" v_max="68.0" v_min="64.0" w_max="36.0" w_min="54.0"/>
3+
<default_agent model_type="holonomic" size="44.0" r_vis="95.0" vel_max="70.0"/>
44
<agents number="2">
5-
<agent id="0" s.x="75.5" s.y="96.5" s.th="3.377398001601135" g.x="10.5" g.y="11.5" g.th="2.995031125848783" model_type="diff_drive" size="68.0" r_vis="57.0" v_max="68.0" v_min="64.0" w_max="36.0" w_min="54.0"/>
6-
<agent id="1" s.x="24.5" s.y="41.5" s.th="3.008969172546417" g.x="2.5" g.y="43.5" g.th="3.2933796995838116" model_type="holonomic" size="7.0" r_vis="9.0" vel_max="47.0"/>
5+
<agent id="0" s.x="41.5" s.y="10.5" s.th="2.958935152129407" g.x="50.5" g.y="58.5" g.th="5.58201555927494" model_type="holonomic" size="44.0" r_vis="95.0" vel_max="70.0"/>
6+
<agent id="1" s.x="78.5" s.y="50.5" s.th="0.10168232769908343" g.x="0.5" g.y="16.5" g.th="1.495203504956078" model_type="diff_drive" size="39.0" r_vis="75.0" v_max="25.0" v_min="35.0" w_max="74.0" w_min="27.0"/>
77
</agents>
88
</root>

xml-examples/config.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" ?>
22
<root>
33
<experiment>
4-
<timestep>18.0</timestep>
5-
<xy_goal_tolerance>41.0</xy_goal_tolerance>
6-
<max_steps>13</max_steps>
7-
<some_param1>42</some_param1>
8-
<some_param2>7.0</some_param2>
4+
<timestep>1.0</timestep>
5+
<xy_goal_tolerance>43.0</xy_goal_tolerance>
6+
<max_steps>14</max_steps>
7+
<some_param1>14</some_param1>
8+
<some_param2>29.0</some_param2>
99
<c_param>True</c_param>
1010
<d_param>abcd</d_param>
1111
</experiment>
1212
<algorithm name="test_alg">
13-
<a_param>85</a_param>
14-
<b_param>89.0</b_param>
13+
<a_param>76</a_param>
14+
<b_param>22.0</b_param>
1515
<c_param>False</c_param>
1616
<d_param>abc</d_param>
1717
</algorithm>

xml-examples/default_params.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

xml-examples/default_params_base_discrete.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" ?>
22
<root>
3-
<default_agent model_type="base_discrete" size="57.0" r_vis="64"/>
3+
<default_agent model_type="base_discrete" size="48.0" r_vis="93"/>
44
<agents number="10">
5-
<agent id="0" s.i="0" s.j="5" g.i="3" g.j="9"/>
6-
<agent id="1" s.i="5" s.j="4" g.i="0" g.j="2"/>
7-
<agent id="2" s.i="2" s.j="4" g.i="4" g.j="7"/>
8-
<agent id="3" s.i="9" s.j="0" g.i="0" g.j="0"/>
9-
<agent id="4" s.i="3" s.j="0" g.i="2" g.j="9"/>
10-
<agent id="5" s.i="1" s.j="9" g.i="8" g.j="9"/>
11-
<agent id="6" s.i="7" s.j="7" g.i="6" g.j="6"/>
12-
<agent id="7" s.i="9" s.j="8" g.i="2" g.j="3"/>
13-
<agent id="8" s.i="5" s.j="5" g.i="9" g.j="8"/>
14-
<agent id="9" s.i="6" s.j="6" g.i="2" g.j="2"/>
5+
<agent id="0" s.i="0" s.j="6" g.i="6" g.j="6"/>
6+
<agent id="1" s.i="0" s.j="9" g.i="6" g.j="3"/>
7+
<agent id="2" s.i="5" s.j="9" g.i="1" g.j="4"/>
8+
<agent id="3" s.i="8" s.j="4" g.i="7" g.j="2"/>
9+
<agent id="4" s.i="4" s.j="4" g.i="0" g.j="6"/>
10+
<agent id="5" s.i="2" s.j="3" g.i="6" g.j="5"/>
11+
<agent id="6" s.i="7" s.j="6" g.i="9" g.j="2"/>
12+
<agent id="7" s.i="9" s.j="7" g.i="7" g.j="8"/>
13+
<agent id="8" s.i="8" s.j="6" g.i="6" g.j="8"/>
14+
<agent id="9" s.i="3" s.j="1" g.i="7" g.j="3"/>
1515
</agents>
1616
</root>

xml-examples/default_params_diff_drive.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)