Load Model

Example 1 : Load Model

This simple "hello world" example loads an Actin model from a file and prints out information from the system/state of the model. This example loads an EcSystemSimulation object from a file in Actin format, then gets the EcStatedSystem object from it.

Goals

The goal of this example is to show how to link to and include the Actin libraries. Another goal is to show how to load a model and print out some of its system parameters and its state.

Code Review

Code Explanation: example1.cpp

setup() : check for a valid Actin license and load the simulation model. The UR5.ecz file is the simulation model, an XML file compressed with gzip. The models files are located in the actin/data/training/models directory.

run() : Calls a function to describe the manipulators and then to describe the state of each manipulator. In Actin, a model can have multiple manipulators, including objects that the robot interacts with. For example, if grasping a part, the part is also considered a manipulator with appropriate bounding volumes and rendering mesh.

loadSimulation() : loads the simulation file using the EcXMLObjectReaderWriter. The simulation contains the stated system, which is comprise of the system, configuration, and state.

describeManipulators() : for each manipulator, iterate through its links and describe the link.

describeLink() : links are chained in a parent, child relationship. This is a recursive function that walks down the chain and print out the text label for each link.

describeState() : The state of the system contains the positions, velocities and accelerations for each joint in the manipulator. This function prints a table of these values for each manipulator. In this example, the robot is not moving.

Classes Referenced:

  • EcActinLicenseHandle
  • Ec::Application
  • EcXmlObjectReaderWriter
  • EcStatedSystem
  • EcSystemSimulation
  • EcIndividualManipulator
  • EcManipulatorLink
  • EcManipulatorLinkVector
  • EcXmlRealVector

The above classes are documented on the Energid website on this page

Actin Types and Macros

The code makes use of the Actin SDK types (in ecTypes.h, part of the SDK stable library) in order to support cross platform builds for linux, windows, macOSX and real time operating systems (RTOS) in both 64 bit and 32 bit architectures. Some examples in this code are:

  • EcU32 : typedef for an unsigned 32 bit integer.

  • EcInt32 : typedef for 32 bit integer (signed)

  • EcReal : typedef for single precision floating point number

  • EC_PRINT : macro for formatted print output with multiple levels for debugging.

Running Example 1

This explanation is for Linux (Ubuntu 16.04), for Windows is mostly the same thing, except for the creation of the environment variable and path slashes. Let’s assume that you installed the actin SDK in ~/Energid/actin, so we’ll create a shortcut to get there.

    $ export ACTIN_HOME=/home/Energid/<actin> //where actin is your installed SDK name like ActinSDK...
    $ cd $ACTIN_HOME
    $ cd examples/build/bin
    $ ./trainExample1

This should produce the following console output:

UR5 Manipulator Links:

{ Base, Shoulder, Elbow, Wrist1, Wrist2, Wrist3 }

UR5 Manipulator System State:

Joint |   Angle |   Velocity | Acceleration
 (ID) |   (deg) |  (deg/sec) | (deg/sec^2)
------|---------|------------|-------------
    1 |    0.00 |       0.00 |      0.00
    2 |  -40.78 |      -0.00 |      0.00
    3 |   69.61 |      -0.00 |      0.00
    4 | -123.75 |       0.00 |      0.00
    5 |  -78.05 |      -0.00 |      0.00
    6 |    0.00 |      -0.00 |      0.00
Further Excercises

In the interest of learning Actin, it would be educational to attempt a few modifications.

  • Try loading a different model and see how its set up
  • Add a "describeConfiguration" method to print out info on Attachments, and or collision maps.
  • Add to the "describeLink" method to print out more information about a link such as Named Frames, Bounding Volumes, Joint Parameters, etc.