GaitSim Assist is a comprehensive Python library for biomechanics researchers and wearable device engineers. It provides a high-level API for running gait simulations, testing assistive device parameters, and optimizing cost function settings without deep diving into low-level OpenSim code.
- Unified Gait Simulation API: High-level Python APIs to load gait datasets, run simulations (tracking or predictive), and retrieve joint kinematics & kinetics results.
- Cost Function Modules: Built-in library of cost functions (metabolic cost, fatigue, effort, etc.) that can be swapped or combined to see how assistive outcomes change.
- Assistive Device Modeling: Tools to model simple assistive device effects (like exoskeleton torques or prosthetic joint limits) and incorporate them into simulations.
- Visualization & Analysis: Automatic generation of gait plots β joint angle curves, ground reaction forces, muscle activations β for both experimental and synthetic gait data.
pip install gaitsim-assist
git clone https://github.com/yourusername/gaitsim-assist.git
cd gaitsim-assist
pip install -e .
GaitSim Assist requires:
- Python 3.9+
- OpenSim 4.3+
- NumPy, Matplotlib, Pandas, SciPy
- CasADi (for optimization)
import gaitsim_assist as gsa
# Create a simulator with default 2D walking model
simulator = gsa.GaitSimulator()
# Run a predictive simulation with cost of transport cost function
results = simulator.run_predictive_simulation(
cost_function='cot',
time_range=(0.0, 1.0)
)
# Visualize the results
from gaitsim_assist.visualization import GaitPlotter
plotter = GaitPlotter()
plotter.plot_joint_angles(results)
plotter.plot_ground_forces(results)
We provide several example scripts in the examples/
directory:
- basic_simulation_moco.py: Run a simple walking simulation using OpenSim Moco
- compare_cost_functions.py: Compare different cost functions (muscle effort, joint torque, hybrid)
- analyze_opensim_results.py: Analyze and visualize existing OpenSim simulation results
- batch_processing.py: Run multiple simulations with different parameters
- assistive_device_optimization.py: Optimize assistive device parameters
- custom_cost_function.py: Create and use custom cost functions
To run an example:
cd examples
python basic_simulation_moco.py
# Create an ankle exoskeleton
exo = gsa.devices.Exoskeleton(
name="ankle_exo",
model=simulator.model,
joint_name="ankle",
mass=1.0,
max_torque=50.0
)
# Run simulation with the exoskeleton
exo_results = simulator.run_predictive_simulation(
cost_function='cot',
time_range=(0.0, 1.0),
assistive_device=exo
)
# Create a hybrid cost function
hybrid_cost = gsa.cost_functions.Hybrid(
simulator.model,
cost_functions={
'cot': 0.5,
'muscle_effort': 0.5
}
)
# Run simulation with the hybrid cost function
hybrid_results = simulator.run_predictive_simulation(
cost_function=hybrid_cost,
time_range=(0.0, 1.0)
)
# Compare results
plotter.compare_simulations(
results_list=[results, exo_results, hybrid_results],
labels=["Baseline", "Exoskeleton", "Hybrid Cost"],
plot_type="joint_angles"
)
Detailed view of joint angles for hip, knee, and ankle joints throughout the gait cycle.
Ground reaction forces showing both vertical and anterior-posterior components during walking.
Muscle activation patterns during the gait cycle, showing the timing and magnitude of major muscle group activations during walking.
For full documentation, visit docs.gaitsim-assist.org.
- Getting Started
- Creating Custom Cost Functions
- Modeling Assistive Devices
- Analyzing Simulation Results
gaitsim_assist/
βββ __init__.py
βββ simulation/ # Core simulation capabilities
β βββ __init__.py
β βββ gait_simulator.py
β βββ tracking.py
β βββ predictive.py
βββ cost_functions/ # Cost function implementations
β βββ __init__.py
β βββ base.py
β βββ cot.py
β βββ muscle_effort.py
β βββ ...
βββ devices/ # Assistive device models
β βββ __init__.py
β βββ base.py
β βββ exoskeleton.py
β βββ ...
βββ visualization/ # Visualization tools
β βββ __init__.py
β βββ gait_plotter.py
β βββ ...
βββ analysis/ # Analysis tools
βββ __init__.py
βββ ...
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenSim community for their excellent tools and documentation
- Contributors to the biomechanics research community