Tutorials written in the scripting language Lua

The Lua scripting API has been deprecated. We refer to the Python scripting API.

All Lua based tutorials can be found in <agxDir>/data/luaDemos/tutorials. Most of the scripts can be started both with luaagx and agxViewer.
To run these tutorials, AGX needs to be installed on the computer. The .agxLua file suffix is associated to the application agxViewer which will be executed for the links below.

If you want to start one of the scripts manually in a command window, just write:

agxviewer tutorials\tutorial1_graphics.agxLua

agxViewer starts by default in paused mode. Remember to press 'e' to start simulation.

Press '1' to reload the scenes.

Keybindings and arguments for agxViewer

Tutorial 0: Basic simulation

Create a basic simulation with bodies, geometries and shapes. 

Shows how to:

  • Create a basic simulation with bodies, geometries and shapes.
  • Can be started with luaagx or agxViewer. However, no graphics is generated in this script, so when you start it with agxViewer, you need to press 'g' to see the geometry.
Tutorial0

Tutorial 1: Attaching graphical objects

Create bodies/geometries and attach rendering objects to each of them.

Shows how to: 

  • Create a simulation including graphics which is loadable with agxViewer.
  • Load a graphical object from a file, and connect it to a geometry so that it moves with the geometry.

This script can only be loaded with agxViewer, NOT luaagx.

Tutorial1

Tutorial 2: Supporting both luaagx and agxViewer

Create bodies/geometries and attach rendering objects to each of them.

Shows how to:  

Tutorial2

Tutorial 3: Events and reading forces.

This tutorial show how to listen for simulation event and read forces from contacts and constraints.

Shows how to:

  • Create a LuaStepEventListener to listen for events in the simulation loop
  • Access contact data/forces and write them to the screen
  • Get all constraints in a system
  • Access constraint data and read forces
  • Draw simple text onto the screen

Tutorial3

Tutorial 4: Creating objects during runtime.

This script randomly creates objects during runtime.

Shows how to:

  • Use AutoSleep
  • Create a LuaStepEventListener to listen for events in the simulation loop
  • Create and remove objects during runtime.
Tutorial4

Tutorial 6: Read keyboard events. Change shapes


Shows how to:
  • agxSDK.LuaGuiEventListener for listening to keyboard and mouse events
  • Change a shape in size (radius of a sphere), including the graphics
  • Use the script StatisticsWriter.lua to write statistic information to a file on disk.
Tutorial6

Tutorial 7: Kinematic bodies and listening to contacts


Shows how to:
  •  Create a body, make it KINEMATIC and move it using a Spline in a StepEventListener
  • Make a Geometry into a Sensor (will not generate ContactConstraints for the solver)
  • Create a LuaContactEventListener which listens to contacts 
  • Assign property values to objects
  • Use ExecutionFilter for filtering out which contacts a ContactEventListener will see.
Tutorial7

Tutorial 9: Building deformable objects

Shows how to:

Build a "lumped" object by attaching bodies/constraint to each other

  • Set compliance to make lumped objects stiffer (all the way to infinite)
Tutorial9

Tutorial 10: Pyramids using iterative solver

Shows how to:

Use the iterative solver specified on a per-material basis. The iterative solver does not give the same precision as the direct, but is a lot faster for large contact/friction system.

Pyramid tutorial

Tutorial 11: Using Uuid and RestoreListener

Shows how to:

Each object in AGX has a Uuid (Universially unique Identifier), this can be used to locate previously serialized objects.

In this example a simple scene has been modeled and stored to disk.
By creating a RestoreListener and listen to restore events, the references to the restored constraints can be retrieved.

If you want to support store/restore in your simulation framework, this is the way to do it!

RestoreListener
                      tutorial

Tutorial 12: Constraints

This tutorial demonstrates all the constraints available in AGX.


Constraints
                      tutorial

Tutorial 13: Granular bodies

Granular bodies can be used for simulation of large quantities of spherical objects. It can make use of a parallel iterative solver for better utilization of more simulation cores.

The number of threads can be changed with ALT+<number>


Granular bodies
                      tutorial

Tutorial 14: Tire model

This is a tutorial demonstrating how to use the TireModel class for simulating the wheels of a vehicle.

Tire model tutorial

Tutorial 15: Controlled Robot using electric motor model

This script demonstrates how to model electric motors for a controlled robot.

Robot tutorial

Tutorial 16: Hydraulic winch with plotting

This script demonstrates how to build a hydraulic driven winch with wires. During simulation data will be plotted: rpm, pressure, flow etc.

Included in the tutorial is:

  • RPM controller (written in Lua)
  • Engine
  • Hydraulic pump
  • Shafts
  • Relief valve
  • GearBox
  • Clutch
  • WireWinchActuator
Hydraulic
                              winch
Hydraulic winch

Tutorial 17: Using MergedBody for accelerating performance

This script illustrates how the automatic Merge and Split functionality (AMOR) can be used to seriously reduce the simulation .

  • Explicitly merge a set of rigid bodies
  • Register a agx::MergedBody with the MergedBodyHandler to enable automatic splitting.
Hydraulic
                                winch

Tutorial 18: Tire/deformable terrain

This script demonstrates the use of the tire model and the deformable terrain.

  • How to create a tire model
  • How to create a terrain model
  • Use left/right/up/down keys to steer the vehicle
Hydraulic
                                winch

Tutorial 19: Robotic grasping

This script shows you how to set up a scene with accurate frictional contact simulation using the DIRECT solver

View source code:

Hydraulic
                                winch