Example listing

Example listing#

Example:

Train the inverted double link cartpole model

Tags:

dynamics cart pole machine learning

Folder:

example_2_link_cartpole

Description:

We will now demonstrate training the model using StableBaselines 3

Example:

Flexible Slider-Crank

Tags:

dynamics time domain flexible slider crank

Folder:

example_flexible_slider_crank

Description:

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

Example:

Cart Pole Reinforcement Learning

Tags:

dynamics cart pole machine learning

Folder:

example_cartpole

Description:

This notebook demonstrates implementing a custom learning environment using kdFlex. By implementing the simple cart pole scenario in a Gymnasium class, any machine learning library that is compatible with Gymnasium can be trained on the scenario. This tutorial consists of 2 parts: building the environment and training a model on the environment.

Example:

Data Logging

Tags:

data logging

Folder:

example_data_logging

Description:

This notebook explores kdflex’s built in data logging capabilities using a 2-link pendulum example multibody. We start with generic non-simulation data logging to H5 files using Karana.KUtils.H5Writer. Then we will demonstrate automatically logging sim data using the Karana.Models.DataLogger. This requires going through the typical process of setting up a multibody and running the simulation.

Example:

Flexible Double-Wishbone

Tags:

dynamics double wishbone constraints cutjoint flexible TA model

Folder:

example_flexible_double_wishbone

Description:

This example builds a flexible body double-wishbone example. This example and makes one of its links flexible, adds a spring-damper, and runs a full simulation of the double-wishbone system. This is an example of a multibody that has flexible bodies and constraints. _

Example:

Visualization

Tags:

visualization 3D graphics

Folder:

example_visualization

Description:

In this tutorial we will:

  • Create a two-link pendulum multibody

  • Attach a primitive geometry to a body

  • Attach a 3D mesh geometry to a body

  • Setup web-based 3d visualization

  • Render to a file

Prerequisites:

Example:

Importing a robot arm multibody model from a URDF file

Tags:

dynamics urdf import robot WAM

Folder:

example_urdf

Narration:

Video

Description:

The purpose of this notebook is to

  • demonstrate the creation of a Karana.Dynamics.Multibody instance for a robot arm from a URDF model file

  • show the structure of the loaded model

  • show a 3D visualization of the robot arm

  • serve as a hello world script for verifying a proper kdFlex installation

Resources

Acknowledgements The Barrett WAM urdf is sourced from the public repository barrett-ros2-pkg. Thank you to the authors and contributors.

Example:

Parallel vehicle propagation

Tags:

time domain parallelization

Folder:

example_parallel_vehicles

Description:

This notebook runs two independent vehicle SubTrees in parallel via Karana.Models.ParallelVehicles. ParallelVehicles registers on a global state propagator and advances a list of vehicle state propagator instances during the global propagator’s hop.

This example uses small serial-chain vehicles so the setup is easy to see. Each vehicle has its own SubTree, its own state propagator, its own integrator, and a recurring pre-hop event that sleeps for 0.1 seconds. The sleep events make the wall-clock difference between parallel and serial execution visible.

Example:

Basic frames usage

Tags:

frames

Folder:

example_frames

Description:

Illustrates frames layer usage

Example:

Procedural n-link pendulum collision example

Tags:

pendulum contact time domain

Folder:

example_procedural_collision

Description:

This notebook is a more advanced version of the n-link pendulum and 2-link pendulum collision tutorials.In this notebook a pendulum is created using the procedural approach to allow for an n number of linked bodies to be built at once. Collision detection is added in this notebook and visualized using material colors.

Requirements:

In this example we will:

  • Create the n-link pendulum multibody

  • Create the kdFlex Scene

  • Setup geometries

  • Set up the state propagator and models

  • Set initial state

  • Register a timed event

  • Run the simulation

  • Clean up the simulation

For a more in-depth descriptions of kdflex concepts see usage.

Example:

Basic math usage

Tags:

math beginner

Folder:

example_math

Description:

This notebook demonstrates how to work with basic math objects using kdFlex

Example:

ATRVjr Reinforcement Learning

Tags:

dynamics ground vehicle skid steered machine learning ATRV Jr

Folder:

example_atrvjr_learning

Description:

This tutorial trains a model to drive an ATRVjr vehicle to a target. This tutorial consists of 2 parts: building the environment and training a model on the environment.

Example:

Serial chain

Tags:

dynamics pendulum gui beginner

Folder:

example_serial_chain

Description:

This is an introductory example of creating a serial chain system along with starting up the GUI for introspection.

Example:

Double-Wishbone

Tags:

dynamics double wishbone constraints cutjoint TA model

Folder:

example_double_wishbone

Description:

This notebook walks through loading a DARTS Model file of a Double Wishbone multibody. Additionally, it demonstrates how to enforce loop constraints in the graph multibody.

Example:

4-bar system simulation

Tags:

dynamics cutjoint constraints TA model beginner time domain planar 4-bar

Folder:

example_4_bar

Description:

This notebook builds upon the system-level simulation showcased in the system-level notebook. If you are not already familiar with the concepts described in that notebook, please go through it before this one.

Example:

Import/Export Multibodies

Tags:

import pendulum time domain

Folder:

example_import_export

Description:

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

Example:

Load Mars 2020 rover model from a URDF file

Tags:

import urdf ground vehicle

Folder:

example_m2020

Description:

Illustrates importing a Mars 2020 rover model from a URDF file

Example:

Cut-joint loop constraint

Tags:

dynamics constraints cutjoint TA model time domain

Folder:

example_cut_joint_constraint

Description:

This notebook illustrates the use of a cu-joint loop constraint.

Example:

Basic 2-link Pendulum

Tags:

dynamics time domain pendulum

Folder:

example_2_link_pendulum

Description:

This notebook walks you through every step to manually create a simple two-link pendulum multibody simulation. While the majority of the kdFlex software is in C++, Python bindings for the C++ classes are available as Python extensions. This example illustrates the use of the kdFlex Python extensions.

Example:

\(n\)-link Pendulum Benchmark Comparison

Tags:

pendulum time domain

Folder:

example_rigid_timing

Description:

In this notebook we benchmark the n-link pendulum example. This notebook is similar to the \(n\)-link pendulum but is designed for benchmarking kdFlex’s simulation performance and demonstrating how kdFlex’s multibody simulation performance scales.

Requirements:

In this tutorial we will:

  • Define a method to create the multibody

  • Run the simulation with increasing number of links

  • Benchmark simulation runtimes

For a more in-depth descriptions of kdflex concepts see usage.

Example:

Beginner example of creating a system-level simulation

Tags:

dynamics pendulum beginner KModels time domain

Folder:

example_system_level

Description:

An introductory example of setting up a time-domain simulation of a serial chain system along with a gravity KModel and starting up the GUI for introspection.

This notebook builds upon the time domain simulation showcased in the time domain notebook. If you are not already familiar with the concepts described in that notebook, please go through it before this one.

Example:

Robotics Algorithms

Tags:

import math robot

Folder:

example_robotics_algorithms

Description:

The purpose of this notebook is to demonstrate how kdflex’s various algorithms can be used. This notebook uses the Barret WAM arm to showcase these algorithms.

Resources

Acknowledgements The Barret WAM urdf is sourced from the public repository barrett-ros2-pkg. Thank you to the authors and contributors.

Example:

n-link Pendulum

Tags:

pendulum dynamics time domain

Folder:

example_n_link_pendulum

Description:

This notebook walks through the process required to create an n-link pendulum multibody simulation in kdflex. This problem is an extension to the 2-link pendulum by creating the pendulum using a procedural approach to allow for an n number of linked bodies to be built at once. This method uses the Karana.Dynamics.PhysicalBody.addSerialChain() method which can be useful for automating the creation of large multibody systems.

Requirements:

In this tutorial we will:

  • Create the multibody

  • Setup the kdFlex scene

  • Add a root visual geometry

  • Set up the state propagator and models

  • Set initial state

  • Register a timed event

  • Run the simulation

  • Clean up the simulation

For a more in-depth descriptions of kdflex concepts see usage.

Example:

Fully Augmented \(n\)-link Pendulum Benchmark Comparison

Tags:

dynamics time domain pendulum TA model

Folder:

example_fully_augmented_benchmark

Description:

In this notebook, we use the \(n\)-link pendulum example to compare the performance of kdFlex’s default SOA-base \(O(N)\) dynamics algorithm with the conventional \(O(N^{3}\)) methods for a fully augmented (FA) model.

Example:

Spice Frames

Tags:

frames spice ephemerides

Folder:

example_spice_frames

Description:

This notebook walks the user through the process of creating Spice Frames. The Karana.Frame.SpiceFrame is a special type of Karana.Frame.Frame that is associated with planetary bodies for ephemerides.

Requirements:

In this tutorial we will:

  • Create SpiceFrames for planetary bodies

  • Create SpiceFrameToFrames to tie together ephemerides

  • Setup the kdFlex scene

  • Attach ProxySceneNodes to each planet

  • Query ephemeris data for bodies

  • Run and Clean up the Simulation

Example:

Slider crank example

Tags:

dynamics slider crank constraints cutjoint

Folder:

example_slider_crank

Description:

This notebook is an example of creating a simple slider crank with loop constraints and graph topology. This demonstrates how to do the following:

In this tutorial we will:

  • Create a Multibody using DataStruct.DataStruct

  • Use ConstraintKinematicsSolver solve a system

  • Setup the simulation

  • Run the simulation with constraints

Prerequisites:

Example:

ATRVjr Driving

Tags:

dynamics ground vehicle skid steered ATRV Jr

Folder:

example_atrvjr_drive

Description:

In this notebook we import the ATRVjr rover model into kdflex and drive it around using a simple manual applied torque approach.

Example:

2-link Pendulum Collision Example

Tags:

pendulum contact time domain

Folder:

example_pendulum_collision

Description:

This notebook is a more advanced version of the 2-link pendulum example by adding a collision dynamics. This tutorial notebook walks you through the steps to create a 2-link pendulum manually and then adds collision dynamics in addition to extra visualization geometries.

Requirements:

In this example we will:

  • Create the multibody

  • Setup the kdFlex Scene

  • Setup geometries

  • Set up the state propagator and models

  • Set initial state

  • Register a timed event

  • Run the simulation

  • Clean up the simulation

For a more in-depth descriptions of kdflex concepts see usage.

Example:

ATRVjr ROS Integration

Tags:

dynamics ground vehicle skid steered ATRV Jr ROS

Folder:

example_atrvjr_ros

Description:

In this notebook we import the ATRVjr rover model into kdflex and interface with ROS. We will publish messages to ROS as the sim advances as well as listen for a ROS message to command the vehicle’s driving mode.

Example:

Closed-loop assignment

Tags:

dynamics time domain pendulum constraints cutjoint

Folder:

example_loop_assignment

Description:

This notebook servers as a simple assignment (with answers) to help you understand how to build a closed-loop kdFlex simulation.