PyChrono tutorials

This is a collection of tutorials for users that installed the PyChrono module.

We suggest you to study them in the presented order of increasing difficulty.

These examples show how to use Chrono API from the Python side. If you want to learn how to parse and execute Python programs from the C++ side see also the tutorials for the C++ Chrono Python module

Introductory tutorials

  • Introduction to Python

    Learn the basics of Python interoperation with Chrono.

    • import the PyChrono module
    • use basic classes: vectors, matrices, etc.
    • inherit classes


  • Introduction to Python (2)

    Basic creation of a physical system and rigid bodies.

    • create a ChSystem
    • create and add rigid bodies
    • iterate on created contacts
    • iterate on added rigid bodies using the Python syntax


  • Introduction to Python (3)

    Create a postprocessing system based on POVray. *(optional reading)*

    • create a basic system with two bodies
    • create a postprocessor object
    • add asset objects to rigid bodies, for visualization
    • generate POVray scripts for rendering 3D animation as post-processing


  • Create a pendulum

    Create a simple pendulum and display it in an interactive 3D view

    • use pychrono.irrlicht, the Irrlicht 3D realtime visualization of PyChrono
    • create bodies and constraints


  • Create a stack of bricks

    Create a small stack of bricks, move the floor like an earthquake, and see the bricks falling. Learn how:

    • impose a motion law to an object (the shaking platform)
    • add soft shadows to the Irrlicht realtime simulation




  • Use paths as constraints

    Create two pendulums following parametric lines. Learn how:

    • create piecewise lines built from sub-lines, and visualize them
      • add a constraint of 'curvilinear glyph' type
    • add a constraint of 'inposed trajectory' type


  • Use mesh shapes

    Create complex rigid body shapes based on meshes. Learn how:

    • load a .obj mesh file and use it for visualization of the shape
    • load a .obj mesh file and use it for collision
      • adjust position of center of mass respect to reference in ChBodyAuxRef
      • change inertia properties.

FEA tutorials


  • Use FEA for beams

    Use the pychrono.fea module to simulate flexible beams

    • use the python.fea module
    • create beams with constraints


  • Use FEA for a rotor

    Use the pychrono.fea module to simulate the Jeffcott rotor

    • use the python.fea module
    • create a flexible rotor passing through instability
      • tweak the integrator and solver settings for higher precision
      • create an ad-hoc motion function by python-side inheritance from ChFunction

OpenCascade tutorials


  • Use the OpenCascade kernel

    Use the pychrono.cascade module to create a shape with the OpenCascade kernel, then let it fall on the ground.

    • use the python.cascade module
    • create collisions with concave meshes
      • control collision tolerances (envelope, margin)


  • Load a STEP file

    Use the pychrono.cascade module to load a STEP file saved from a CAD.

    • load a STEP file, saved from a 3D CAD.
      • fetch parts from the STEP document and conver into Chrono bodies.


Use pychrono.cascade to load a STEP file and create constraints between the bodies.

  • load a STEP file, saved from a 3D CAD.
    • fetch parts and recerences from the STEP document, and create joints between them.
    • assign a ChLinkTrajectory to a part

Tutorials using the SolidWorks add-in


  • Load a system saved from SolidWorks

    Import a SolidWorks scene into your PyChrono program, and simulate it.

    • use the Chrono::SolidWorks Add-In for exporting a mechanical system
    • load the system in PyChrono and simulate it
    • visualize it in Irrlicht


  • Load from SolidWorks and raytrace with POVray

    Import a SolidWorks scene into your PyChrono program, and simulate it.

    • use the Chrono::SolidWorks Add-In for exporting a mechanical system
    • load the system in PyChrono and simulate it
    • visualize it with POVray scripts for rendering a 3D animation


  • Make a spider robot in SolidWorks and simulate it

    Import a SolidWorks model of a crawling robot into your PyChrono program, and simulate it.

    • use the Chrono::SolidWorks Add-In for exporting a mechanical system
    • load the system in PyChrono
      • add actuators and additional items not modeled in CAD
    • show the simulation in an Irrlicht 3D view

Tutorials about AI