Tutorials

From ChronoWiki

Revision as of 15:20, 25 November 2013 by Tasora (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


File:logo_chrono_engine_h90.png

The following is the list of all tutorials available for the Chrono::Engine, they represent a good starting point to learn programming with this multibody library.

Source code for all the examples presented in these tutorials is included in the SDK. (Note: the actual C++ code of the examples in the SDK might be slightly different because we constantly update them.)


Demos with Irrlicht 3D interface

These examples are the most descriptive and amusing, since they show Chrono::Engine features within a graphical user interface, using a realtime 3D visualization engine called Irrlicht. (To compile these examples you must install also the Irrlicht API on your computer) . These demos are also available as precompiled binaries in the Chrono::Engine directory bin/Win32_VisualStudio/, if you used the installer of the Simplified_installation. To play the precompiled binaries you don't need Irrlicht installed on your computer.

We used Irrlicht, but of course you can use alternative libraries, such as GLUT, OpenGL, Ogre, etc. Consider these tutorial as suggestions. The visualization runs in real-time for most systems with a decent graphic adaptor and a recent processor.



demo_crank

The simpliest way to integrate Chrono::Engine in the Irrlicht 3D visualization library: in fact the coordinates of the joints are simply used as end-points of simple polygonal lines which are drawn in the 3D space for each frame redraw, to show a very simplified 'skeleton' of a slider-crank mechanism. The demo also teaches how to:

  • create constraints and 'engine' objects
  • make a real-time application, where Chrono::Engine adapts the integration step to the speed of the CPU.

File:ico_crank.jpg

demo_fourbar

This tutorial is similar to the demo_crank example, but here a small user-interface is created, so that the user can play with a slider to modify the speed of the motor. The user interface is created with simple GUI features of Irrlicht, but other kind of interfaces/visualization systems could be used. Here you can also learn

  • how to make a four-bar linkage
  • an example of how to plot/fetch data during the simulation.
  • use a direct solver instead of iterative solver, for highest precision.

File:ico_fourbar.jpg

demo_collision

A bunch of random shapes will fall into a box, stacking in random order. Differently from the two examples above, here a special object is used to encapsulate Chrono::Engine rigid bodies, and some 'shortcuts' are used to manage them in Irrlicht. Learn about:

  • collisions, contacts and friction
  • use the easy ChBodySceneNode class for managing Irrlicht objects which encapsulates ChBody items.
  • describe compound shapes

File:ico_collision.jpg

demo_bricks

Another tutorial about collisions. Create a stack of geometric primitives. Learn about:

  • how to change the settings of the stepper in sake of higher precision or higher computing speed.
  • create a motor between two parts.
  • turn on the information panel by pressing the 'i' key on the keyboard.

File:ico_bricks.jpg

demo_pendulum

Create some swinging pendulums, anchored to sliding joints. They move when the fan pushes some air toward them. This tutorial shows how to:

  • create a pendulum
  • apply custom forces using 'force accumulators' (the simplified aereodinamic drag, in this case)
  • create constraints with upper-lower limits (the horizontal sliding joints between pendula and truss)

File:ico_pendulum.jpg

demo_gears

Create a transmission made of pulleys, spur gears, bevel gears. Custom simplified constraints are available, to avoid the simulation of contacts between gear teeth. This tutorial shows how to:

  • use ChLinkGear constraints to represent simplified gear interaction in 3D space
  • the ChLinkPulley constraint is used to model simplified pulleys in 3D space.
  • manage rotations of references using ChCoordsys and ChFrame classes.
  • create a motor between two parts.

File:ico_gears.jpg

demo_mecanum

Simulate a small mobile robot with omnidirectional 'mecanum' wheels. Use keyboard to perform basic motion. This tutorial shows how to:

  • make complex models, with 'barrel' collision shapes.
  • add motors between parts.
  • use the keyboard in Irrlicht 3D view, to interact with the system in realtime.
  • manage rotations of references using ChCoordsys and ChFrame classes.

File:ico_mecanum.jpg

demo_friction

A benchmark that show the feature of spinning friction (aka 'drilling' friction) and rolling friction. These types of frictions are useful for rolling objects like wheels, spheres etc. and can be optionally turned on. This tutorial shows how to:

  • enable rolling and spinning friction.
  • impose initial velocity and angular velocity to objects.

File:ico_friction.jpg

demo_suspension

Simulate a simplified vehicle with double-wishbone suspensions (like racing cars) and drive it using the mouse over some sliders in the interface. This tutorial shows how to:

  • use the ChLinkDistance to represent massless rods, saving computational efforts.
  • change the friction coefficient depending on the contact zone (here, half of the ground plane has lower friction).
  • use the Irrlicht interface system to interact with a model.
  • use ChLinkSpring to make spring-dampers

File:ico_suspension.jpg

demo_tracks

Simulate a simplified vehicle with tracks, that interact with obstacles, and that can be driven by the user. This tutorial shows how to:

  • create different 'families' of collision objects (ex. to avoid that unnecessry contacts are created between adjacent track shoes).
  • make custom compound collision shapes.
  • load a non-concave collision mesh that is decomposed in convex parts

File:ico_tracks.jpg

demo_irr_assets

Use the assets system to create shapes that can be shown in the Irrlicht 3D view. This is a less invasive approach respect to the previous Irrlicht demos. This tutorial shows how to:

  • add geometric visualization shapes to an object.
  • visualize them in the realtime view of Irrlicht.

Note: the same assets that you use for Irrlicht display can be used for postprocessing, ex. with POVray as explained in demo_postprocess.

File:ico_irr_assets.jpg

demo_import_solidworks

Learn how you can use few C++ lines of code to load a mechanism that you exported from SolidWorks. This tutorial shows how to:

  • load a SolidWorks mechanism into Chrono::Engine
  • retrieve pointers to SolidWorks exported parts, given their name
  • show a realtime simulation with Irrlicht

File:ico_import_solidworks.jpg

Core features

These examples are about the basic features of the Chrono::Engine programming system, which can be used also for non-physics stuff. Some of these tutorials can be skipped (they deal with 'low level' stuff..).

demo_math

Demo on how to use Chrono mathematical objects and functions (vector math, matrices, linear algebra, etc.). No GUI: only text output.

File:ico_shell.jpg

demo_coords

Tutorial on how to perform 3D coordinate manipulation (rotation and translations of points, frames, etc.) thank to C++ objects and custom operators introduced in Chrono::Engine. No GUI: only text output.

File:ico_shell.jpg

demo_stream

Tutorial on files, streams, serialization. Learn:

  • streams and files
  • serialization, with versioning and dynamic creation (class factory)
  • class runtime type identification.

No GUI: only text output.

File:ico_shell.jpg

demo_sharedptr

Tutorial on how Chrono::Engine core functionality can handle smart pointers and shared objects. These smart pointers can be useful also in projects non related to physics simulation too. No GUI: only text output.

File:ico_shell.jpg

Basics

These tutorials teach how to setup physical systems in Chrono::Engine. Here we do not use any graphical user interface: see the 'Irrlicht' tutorials for demos with a 3D graphical output.


demo_buildsystem

Tutorial which teaches the basic approach to build and simulate mechanical systems. No 3D user interface is used here, so you compile this example even if you do not have Irrlicht 3D visualization library installed. Learn how:

  • create a physical system (a slider-crank)
  • add/remove rigid bodies
  • create mechanical joints between bodies
  • perform a simulation

No GUI: only text output.

File:ico_shell.jpg

demo_powertrain

Tutorial which teaches the basic approach to build systems that embed powertrains, made with 1-degree-of-freedom items (rotating shafts).

  • connect 1D shafts with transmission ratios
  • connect 1D shafts with 1D clutches, brakes, etc.
  • connect a 1D shaft to a 3D body.

No GUI: only text output.

File:ico_shell.jpg

demo_chfunctions

Tutorial that teaches how to use the ChFunction inherited classes to build math functions of y=f(x) type. The ChFunction objects are 'building blocks' whose main usage is to describe motion laws, such as trajectories in automation and robotics, etc.

  • create and use ChFunction objects, from available classes.
  • define a custom function by inheriting from ChFunction class.

No GUI: only text output.

File:ico_shell.jpg

demo_postprocess

Tutorial that teaches how to use the unit_POSTPROCESSING to create animations with POVray. When the simulation is run, a set of .pov and .ini files are saved on disk, so that one can use POVray later to do high-quality rendering of simulations.

Note: the same assets can be used to render animations in real-time in the interactive 3D view of Irrlicht, as explained in demo_irr_assets.

File:ico_postprocess.jpg

MS VisualStudio C++ IDE

Compile an develop Chrono::Engine applictions without using the CMake system. These examples are contained in the demo/msvc/ directory. Read the README.TXT for informations about how to configure your Microsoft VisualStudio IDE.

demo_oscillator

Develop a C++/CLI .NET application that uses Chrono::Engine and embeds a small Irrlicht view. Of course you are not forced to embed the Irrlicht 3D viewing system in the GUI of your .NET projects, but this is a general example - if you prefer, you can use directly OpenGL or DirectX or other methods. This tutorial shows how to:

  • use Chrono::Engine in .NET, using C++/CLI.
  • use an Irrlicht 3D view in a .NET user interface.
  • configure the Micosoft VisualStudio IDE to compile Chrono applications without using 'makefiles'.
  • simulate a simple 1-DOF oscillator.

File:ico_oscillator.jpg

VC++ Wizard

This is not a ready-to-use example, but it is a tutorial on how to use the ChronoEngineWizard in your Microsoft Visual C++ Express IDE to set up quickly a new project. This tutorial shows how to:

  • use Visual C++ IDE to create a new project using the custom ChronoEngineWizard
  • quickly integrate Chrono::Engine in your C++ projects
  • create a spring-damper system between two bodies
  • easy display of springs in Irrlicht view

File:ico_wizard.jpg


Matlab

These demos are about the unit_MATLAB.

If you own a copy of the Matlab(TM) software, you can interact with it from Chrono::Engine, in order to plot data, make complex computations, perform co-simulations, etc.

demo_matlab

Entry level demo about how to use Matlab(TM) to plot Chrono::Engine data, to perform computations, etc. This example requires that you own a copy of Matlab(TM), properly installed on your system (if you do not have Matlab(TM) installed and you try to execute demo_matlab.exe, it will give an error because it cannot load the Matlab engine dll). This tutorial shows how to:

  • do basic interaction with Matlab (copy matrices from/to Matlab workspace)
  • plot data using Matlab.

Note that the unit_MATLAB is used.

File:ico_matlab.jpg

demo_chfunctions_plot

Use Matlab(TM) to plot Chrono::Engine ChFunction objects. This example requires that you own a copy of Matlab(TM), properly installed on your system (if you do not have Matlab(TM) installed and you try to execute demo_matlab.exe, it will give an error because it cannot load the Matlab engine dll). This tutorial shows how to:

  • use ChFunction objects
  • plot data using Matlab.

Note that the unit_MATLAB is used.

File:ico_matlab.jpg

Co-simulation with Simulink

If you own a copy of the Simulink software, you can use the cosimulation unit in order to simulate pneumatic, hydraulic, electrical subsystems that interact with mechanisms modeled in Chrono::Engine.

demo_cosim_hydraulics

Tutorial that covers the fundamentals concepts of Simulink<->Chrono::Engine cosimulation, with the following example: an hydraulic piston moves a rigid body connected to a hinge.

  • The hydraulic subsystem and the closed loop control are simulated in Simulink
  • The rigid body and the joints are simulated in Chrono::Engine.


OpenCascade

These examples are only for users that have installed the OpenCASCADE library, because the CASCADE unit is used in these tutorials. Thank to this additional module it is possible to load 3D CAD files saved in the STEP format.

demo_converter

This example builds a minimal application where the user can load a STEP model into the Irrlicht 3D visalization window. This tutorial shows how to:

  • load a STEP file with the CASCADE unit
  • convert STEP geometries into triangulated meshes

File:ico_conv.gif

demo_stepfile

Entry level example that shows how to use the CASCADE unit to load a 3D STEP model saved from a professional CAD software. This tutorial shows how to:

  • load a STEP file,
  • fetch sub-parts and sub-assemblies, if any, from the STEP document,
  • make Chrono::Engine rigid bodies out of the STEP shapes
  • compute the center of mass and inertia from the STEP shapes

File:ico_stepfile.gif

demo_robot

Advanced example that shows how to use the CASCADE unit to load a 3D STEP model of a robot, containing many parts. This tutorial shows how to:

  • load a STEP file,
  • fetch sub-parts and sub-assemblies from the STEP document,
  • do inverse kinematics (impose the motion of the end effector of a robot)
  • use ChFunction_Sequence to create complex motion laws.

File:ico_robot.gif

File:logo_chrono_pyengine_h90.png

These examples are only for users that are using Chrono::PyEngine, that is the Python module for using Chrono::Engine with Python.

demo_python1

Learn the basics of Python interoperation with Chrono::Engine.

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

File:ico_shell.jpg

demo_python2

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

File:ico_shell.jpg

demo_python3

Create a postprocessing system based on POVray.

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

File:ico_shell.jpg

demo_masonry

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

  • use Irrlicht 3D realtime visualization in Chrono::PyEngine
  • impose a motion law to an object (the shaking platform)
  • add soft shadows to the realtime simulation

File:ico_masonry.jpg

demo_solidworks

Import a SolidWorks scene into your Chrono::PyEngine program, and simulate it.

File:ico_escapement.jpg

File:logo_chrono_solidworks_h90.png

Tutorials for users that installed the Chrono::SolidWorks add-in for SolidWorks into their SolidWorks CAD.

demo_engine

Learn the basics of Chrono::SolidWorks add-in for SolidWorks:

  • model a 3D assembly using SolidWorks,
  • export it as a .py file containing the Chrono::Engine system description.
  • run a Python simulation of the exported system
  • render the simulation using POVray

demo_engine advanced

Tips for advanced use of Chrono::SolidWorks add-in, with some Python tricks and tips for:

  • modify the exported scene by creating custom constraints
  • assigning POVray materials
  • creating custom POVray objects
  • attaching a camera to a moving part

demo collision shapes

This tutorial is about how to define collision shapes when using the Chrono::SolidWorks add-in for SolidWorks.

  • assign collision shapes to parts in SolidWorks
  • create and assign surface materials to parts using Python
  • customize advanced POVray pigments and textures
  • move the ground to simulate an earthquake

Personal tools