A simple GUI-based visualization tool for movement data of Swarms.
Interactively visualize tracking or simulated data of collective movement while monitoring an array of useful metrics. Includes a hierarchical clustering based on distance and orientation as and supports both automatic playback and scrubbing through the time steps. All calculated data can be exported into modern file formats for further analysis.
Download the binary for your operating system from the TU-Berlin DepositOnce. Unpack the archive to a location of your choice, then navigate to SwarmViz/bin
and double-click on the executable named SwarmViz
.
Depending on what libraries are installed on your system, it might be necessary to download additional dependencies on startup. On some operating systems you are not notified of this in any way. Make sure you have an active internet connection and wait for several minutes for the download to finish.
Install the Julia programming language from julialang.org or a package manager of your choice and add it to your path. Clone this repository.
Open your terminal and navigate to the directory containing the Project.toml file. Then do
julia
using Pkg
Pkg.activate(".")
Pkg.instantiate()
using SwarmViz
swarmviz();
Install the Julia programming language from julialang.org or a package manager of your choice and add it to your path. Clone this repository.
Open your terminal and navigate to the directory containing the Project.toml file. Then do
julia
using Pkg
Pkg.add("PackageCompiler")
using PackageCompiler
Pkg.activate(".")
Pkg.instantiate()
create_app(".", "path_to_directory_to_compile_to"; incremental=true, executables=["NameOfYourChoice" => "swarmviz"])
Use the import buttons to load movement data as well as collisions and enclosures matching the specification described in a section below (calculating all metrics might take a moment depending on your system specifications).
Select metrics to monitor from the dropdown menus above the three (empty) graphs on the right.
Either use the “Time Step” slider to move through the data or press the “PLAY” button start playing back the experiment or simulation. The time step slider stays reactive during this and FPS as well as a number of time steps to skip between each frame can be adjusted.
Toggle additional visualization such as the convex hull, collisions or clustering any time. Choose a threshold for the clustering using the slider or enter a specific value in the box above.
See the Makie documentation for additional ways to interact with any of the plots.
After you’re done, hit the export to button to choose a location for all the data that was created.
In the following,
-
Polarization
$$\frac{1}{N} \left| \left| \sum_{i=1}^N \vec{n}_i(t) \right| \right|$$ -
Rotational Order
$$\frac{1}{N} \left| \left| \sum_{i=1}^N \frac{ \vec{x}_{i} (t) - \frac{1}{N} \sum_{j=1}^N \vec{x}_j (t)}{ \left| \left| \vec{x}_{i} (t) - \frac{1}{N} \sum_{j=1}^N \vec{x}_j (t) \right| \right|} \times \vec{n}_i(t) \right| \right|$$
For these first two also see Zheng et. al. (2022).
- Mean Interindividual Distance (IID)
-
Mean Minimum IID
$$\frac{1}{N} \sum_{i=1}^N \min_{j \neq i} \left| \left| \vec{x}_i(t) - \vec{x}_j(t)\right| \right|$$ -
MaxMin IID
$$\max_i \min_{j \neq i} \left| \left| \vec{x}_i(t) - \vec{x}_j(t)\right| \right|$$ -
Diameter
$$\max_{i, j} \left| \left| \vec{x}_i(t) - \vec{x}_j(t)\right| \right|$$ -
Area
$$A(t) = \frac{1}{2} \sum_{i} \left( h_{i,1}(t) h_{j,2}(t) - h_{j, 1}(t) h_{i,2}(t) \right), \quad j = (i \mod N) + 1$$ -
Roundness
$$\frac{4 \pi A(t)}{\left( \sum_{i} \left| \left| \vec{h}_i (t) - \vec{h}_j (t) \right| \right| \right)^2 }, \quad j = (i \mod N) + 1$$
The clustering is a hierarchical clustering based on a dissimilarity matrix with entries constructed as follows:
where
A single file ending in summaryd.npy with four dimensions, respectively:
runs x agents x properties x time steps
Currently, only a single run is supported, so only the first run will be read.
The first five properties need to be exactly the following, in the specified order:
- Time [s]
- X-Coordinate
- Y-Coordinate
- Z-Coordinate
- Heading Angle [radians] (zero to the right)
The Y-Coordinate as well as additional properties will be disregarded.
Two .json files with the same filename and location as the movement file, except replacing “summaryd.npy” with
- aarefl.json for the agent-agent collisions
- warefl.json for the agent-wall collisions
respectively. They need to have the following internal structure:
- an outer dictionary with the run number (zero indexed) as strings as keys and values in the form of
- a dictionary with the agent ID (zero indexed) as a string as keys and values in the form of
- a list of all time steps (integers, not time points!) where a collision of the respective type occurred
- a dictionary with the agent ID (zero indexed) as a string as keys and values in the form of
Currently, only a single run is supported, so only the first run will be read.
A single .npy with four dimensions, respectively:
runs x agents x properties x time steps
Currently, only a single run is supported, so only the first run will be read.
- Time [s]
- X-Coordinate
- Y-Coordinate
- Z-Coordinate
Time, the Y-coordinate as well as additional properties will be disregarded. The tool also assumes that there are no missing time steps, so the index in the tensor corresponds exactly.
- agents.parquet containing a table with all data concerning specific agents. The columns are:
- Time [s]
- X-Coordinate
- Y-Coordinate
- Z-Coordinate
- Heading Angle [radians]
- X-Component of the X-Z Unit Heading Vector
- Z-Component of the X-Z Unit Heading Vector
- Agent ID (one indexed!)
- Cluster Assignment (one indexed!)
- metrics.parquet containing a table with global metrics for the entire swarm. Rows correspond to time steps in the original data and the columns are:
- Polarization
- Rotational Order
- Diameter
- Area
- Roundness
- Mean Interindividual Distance
- MaxMin Interindividual Distance
- Mean Minimum Interindividual Distance
- Log Last Merge Threshold (of the Clustering)
- derived.jld2 containing tensors with derived metrics. It can be accessed by treating it like a regular HDF5 file but has additional functionality when used with Julia. It contains:
- X-Z Distance Matrices as “distance_matrices” in the shape agent x agent x time steps
- The IDs (one indexed!) of the two most distant agents as “furthest” in the shape agents x time steps
- The center of mass of the agents (assuming equal mass) in the X-Z plane as “center_of_mass” in the shape coordinates x time steps
- A group called “clustering” containing:
- The heights = thresholds of dissimilarity at which merges occur in the clusterings as “clustering_heights” in the shape merges x time steps
- The pairwise merges of the clusterings (negative integers denote agent IDs (one indexed!), positive integers cluster IDs by order of creation), ascending by threshold, as “clustering_merges” in the shape merges x IDs x time step
- The ordering of the leaves of the hierarchical clustering (“fast optimal ordering” by Bar-Joseph et. al. (2001)) as “clustering_order” in the shape IDs x time steps
- convex_hull.json containing the locations of the vertices of the convex hull of all agents with the internal structure:
- a list for each timestep where each entry is
- a list of vertices where each entry is
- a list with one X and one Z coordinate
- a list of vertices where each entry is
- a list for each timestep where each entry is
Install the current version of the Julia programming language from your preferred source. Then navigate to the project folder in your terminal and run
julia
using Pkg
Pkg.activate(".")
Pkg.instantiate()
The colors used to denote cluster assignments are suitable for individual with color vision deficiency for up to 6 clusters. The colors for metric plots and collisions always are.
Created by Neal McKee while studying at the BCCN Berlin with the Romanczuk Lab at HU Berlin.
Distributed under the MIT-license. See LICENSE
for more information.
- Fork it (https://github.com/nealmckee/swarmviz/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
McKee, N. SwarmViz. Files at https://doi.org/10.14279/DEPOSITONCE-20001 (2024).
Zheng Y, Huepe C, Han Z. Experimental capabilities and limitations of a position-based control algorithm for swarm robotics. Adaptive Behavior. 2022;30(1):19-35. doi:10.1177/1059712320930418
Ziv Bar-Joseph, David K. Gifford, Tommi S. Jaakkola, Fast optimal leaf ordering for hierarchical clustering , Bioinformatics, Volume 17, Issue suppl_1, June 2001, Pages S22–S29, https://doi.org/10.1093/bioinformatics/17.suppl_1.S22