Examples

Examples#

While the majority of the kdFlex software is written in C++, Python bindings for the C++ classes are available as Python extensions. Example Python scripts, named notebook.py, are availabe within each of the subfolders within /usr/share/Karana/Tutorials in your local installation. These scripts illustrate the use of the kdFlex Python extenson and can be run from within each of these folders by running python3 notebook.py.

There are also Jupyter notebook versions of each of the tutorials, named notebook.ipynb within the same folder. The introduction video shows how to run these notebooks from a remote machine, from a local machine, and as a normal Python script.

This section contains tutorial examples on using kdFlex. The Python examples are included here, while the C++ examples are included inline in the C++ documentation area. (TODO - add link).

Python Tutorial Notebooks#

The following Jupyter notebooks (located under /usr/share/Karana/Tutorials) contain tutorial examples of using kdFlex.

Jupyter notebook

Folder

Description/License tier

Video walkthrough

Importing a rover arm from a URDF file

example_urdf

Illustrates importing a Barrett WAM robot arm multibody model from a URDF file

Video Walkthrough

Importing M2020 rover model from a URDF file

example_m2020

Illustrates importing a Mars 2020 rover model from a URDF file

2 link pendulum (basic)

example_2_link_pendulum

Illustrates the step by step creation of the bodies for a 2-link pendulum, and setting up a time domain simulation for it.

Video Walkthrough

n link pendulum (procedural)

example_n_link_pendulum

Illustrates the procedural creation of an n-link pendulum and a time domain simulation for it.

Video Walkthrough

Spice frames (basic)

example_spice_frames

Illustrates use of the frames layer with planetary body frames

Import/export multibodies

example_import_export

Illustrates importing and exporting multibody models files in various formats; also, the use of units and quantitiies.

Visualization

example_visualization

Illustrates the capabilities of the 3D graphics layer.

Data logging

example_data_logging

Illustrates basic data logging capabilities.

Jacobians and Inverse kinematics (coming soon)

-

Illustrates creation of inertial and relative Jacobians for single and multiple nodes; general constraint and inverse kinematics

Slider-crank with loop constraints

example_slider_crank

Illustrates creating a slide-crank system with loop constraints and graph topology.

Double wishbone

example_double_wishbone

Illustrates creating a double-wishbone system with loop constraints and graph topology.

2 link pendulum (collisions)

example_pendulum_collision

Illustrates collistion dynamics with a 2-link pendulum example.

Multi-link procedural pendulum (collisions)

example_procedural_collision

Illustrates collistion dynamics with a multi-link pendulum example.

Zero-crossing detection: (coming soon)

-

Illustrates zero-crossing detection with a pendulum collision problem

Flexible body dynamics: (coming soon)

-

Illustrates creation of a 2-link flexible body pendulum

Algorithms showcase: (coming soon)

-

Illustrates various system level algorithmic methods for the mass matrix, system inertias etc

Flexible slider-crank

example_flexible_slider_crank

Illustrates a slider-crank with a flexible body. This is a system that has both flexible bodies and closed loops.

Flexible double-wishbone

example_flexible_double_wishbone

Illustrates a double-wishbone with a flexible body. This is a system that has both flexible bodies and closed loops.

Rigid body SOA dynamics performance

example_rigid_timing

Verify O(N) performance of SOA dynamics by measuring computational time with varying number of bodies.

Rigid body SOA dynamics vs fully augmented performance

example_fully_augmented_benchmark

Compare O(N) performance of SOA dynamics with O(N^3) perforamnce of conventional full-augmented (FA) dynamics.

Each notebook has a cooresponding notebook.py, which is a regular Python script.