/kinematic_snake

Simulations for snake kinematics with anisotropic friction.

Primary LanguagePythonMIT LicenseMIT

Snake Locomotion Kinematics · CI license pyversion

A kinematic model of snake-locomotion, with and without lifting, following our publication. Can run single specified cases or many independent cases in parallel to generate a phase-space.

🚀 Before installing the package, check out an interactive, online version at this link.

Installation

For a system wide install, use

python3 -m pip install kinematic-snake

For a local install, please clone this repository and execute the following in the repository directory.

python3 -m pip install --user .

You can then use one of the examples for running a single simulation or a parameter sweep of simulations. For more information see Usage and examples

Extras

If you want to take full advantage of the package (such as running a phase-space of cases in parallel), please execute

python3 -m pip install kinematic-snake[extras]

Usage and examples

The simplest example runs a single simulation and produces output plots. For convenience, the same code is also listed below.

from kinematic_snake import run_and_visualize, Snake

snake, sol_history, time_period = run_and_visualize(
    froude=1, # The froude number
    time_interval=[0.0, 10.0], # Time interval of simulation
    snake_type=Snake, # Type of snake, can be Snake
    mu_f=1.0, # Forward friction coefficient ratio, determined from `froude`
    mu_b=1.5, # Backward friction coefficient
    mu_lat=2.0, # Lateral friction coefficient
)

More examples including the one above are given in that example file. The code is designed to encourage the user to play around with the model of the snake using any activation function (for both the snake gait, specified by curvature, and the lifting). The documented examples provided in the examples folder should get you started.

Numerical algorithms

Details on the algorithms employed can be found in our following paper. If you are using this package, please cite the work below :)

Friction modulation in limbless, three-dimensional gaits and heterogeneous terrains, doi : 10.1038/s41467-021-26276-x

@Article{Zhang2021,
author={Zhang, Xiaotian
and Naughton, Noel
and Parthasarathy, Tejaswin
and Gazzola, Mattia},
title={Friction modulation in limbless, three-dimensional gaits and heterogeneous terrains},
journal={Nature Communications},
year={2021},
month={Oct},
day={19},
volume={12},
number={1},
pages={6076},
issn={2041-1723},
doi={10.1038/s41467-021-26276-x},
url={https://doi.org/10.1038/s41467-021-26276-x}
}

Running tests

Check Installation to see how to install the package. Once that is done, install the test requirements using

python3 -m pip install -r tests/requirements.txt

This package uses py.test for running unit and integration tests. To run the tests, execute

python3 -m pytest

from the repository directory.