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 (/opt/homebrew/share/Karana/Tutorials if using macOS). 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.
Python Tutorial Notebooks#
This section contains tutorial examples on using kdFlex. The Python
examples are included here, since the associated Juptyer notebooks can be converted to HTML. One can find these
notebooks tutorials under /usr/share/Karana/Tutorials (/opt/homebrew/share/Karana/Tutorials if using macOS).
The C++ examples cannot be easily converted to a web format, but are included with the kdflex package
as well under /usr/share/Karana/Tutorials/example_cc (or /opt/homebrew/share/Karana/Tutorials/example_cc) if
using macOS.
Jupyter notebook |
Folder |
Description/License tier |
Video walkthrough |
|---|---|---|---|
example_urdf |
Illustrates importing a Barrett WAM robot arm multibody model from a URDF file |
||
example_m2020 |
Illustrates importing a Mars 2020 rover model from a URDF file |
||
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. |
||
example_n_link_pendulum |
Illustrates the procedural creation of an n-link pendulum and a time domain simulation for it. |
||
example_spice_frames |
Illustrates use of the frames layer with planetary body frames |
||
example_import_export |
Illustrates importing and exporting multibody models files in various formats; also, the use of units and quantitiies. |
||
example_visualization |
Illustrates the capabilities of the 3D graphics layer. |
||
example_data_logging |
Illustrates basic data logging capabilities. |
||
example_slider_crank |
Illustrates creating a slide-crank system with loop constraints and graph topology. |
||
example_double_wishbone |
Illustrates creating a double-wishbone system with loop constraints and graph topology. |
||
example_pendulum_collision |
Illustrates collistion dynamics with a 2-link pendulum example. |
||
example_procedural_collision |
Illustrates collistion dynamics with a multi-link pendulum example. |
||
example_flexible_slider_crank |
Illustrates a slider-crank with a flexible body. This is a system that has both flexible bodies and closed loops. |
||
example_flexible_double_wishbone |
Illustrates a double-wishbone with a flexible body. This is a system that has both flexible bodies and closed loops. |
||
example_rigid_timing |
Verify O(N) performance of SOA dynamics by measuring computational time with varying number of bodies. |
||
example_fully_augmented_benchmark |
Compare O(N) performance of SOA dynamics with O(N^3) perforamnce of conventional full-augmented (FA) dynamics. |
||
example_atrvjr_drive |
Illustrates setting up and driving the ATRV-Jr, a simple skid-steered four wheel vehicle |
||
example_cartpole |
Integrates kdFlex with gymnasium to train on the classical cart-pole problem |
||
example_atrvjr_learning |
Integrates kdFlex with gymnasium to drive the ATRV-Jr (a skid-steered four wheel vehicle) to random goals |
||
example_atrvjr_ros |
Integrates kdFlex with ROS2 to monitor and command a vehicle |
Each notebook has a cooresponding notebook.py, which is a regular Python script.