C++ and EcScript


The goal of this example is to introduce motion scripting using EcScript instead of creating the motion script objects using C++. In this example, the motion is created as a string, and parsed into an EcMotionScriptObject using the EcMotionScriptObject::parseScript method.

Code Review

Code explanation: example4.cpp

In this example, we use the EcScript language to define the motions which specify a move joint motion and a way-point sequence.

This example results in the same motion as the previous example; expressed using the motion script is shown below. The motion sequence contains two motions: move_joint and pose_seq. The pose sequence specifies a serial of waypoints define by (x,y,z) position (r,p,w) rotation expresses as Euler angles.

You can compare the previous example code to the loadMotionScript function which defines this EcScript code block as a string.

  (move_joint 0 (180.0deg -90.0deg 90.0deg 0.0deg 0.0deg 90.0deg) 1.0 1e-6)
  (pose_seq 0 1 0
    (move_pose 0 1 0 ((0.2 0 0.35)(0 -90deg -90deg)) 1.0 0.02)
    (move_pose 0 1 0 ((0.2 0.1 0.45)(0 -90deg -90deg)) 1.0 0.02)
    (move_pose 0 1 0 ((0.2 0.1 0.65)(0 -90deg -90deg)) 0.1 0.02)
    (move_pose 0 1 0 ((0.2 0 0.35)(0 -90deg -90deg)) 0.1 0.02)

The EcScript language, used by Actin has a large number of easy to use functions for motion control. You’ll find the documentation on our website Actin Motion Library and EcScript

Adddional Classes Referenced


Running Example 4

The output for this example will display in the 3D render window.

$ cd examples/build/bin
$ ./trainExample4
Further Excercises

Try creating some more complex motion sequence using EcScript. Try creating additional motions using:

  • move_joint
  • move_pose
  • move_pose_rel
  • speed
  • pose_seq
  • move_linear
  • move_circular
  • interp_pose_seq
  • set_ee_set
  • set_control_description
  • set_tcp
  • attach_manip
  • detach_manip
  • exclude_collision
  • include_collision
  • motion_seq
  • motion_para

Reference: Actin EcScript

Also try introducing more variables, and using boolean control logic.

Another useful modification would be to print out state information each timestep, to get joint position and velocity information. This can provide basis for a simple hardware interface if you were to send that information to a physical robot system.