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
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:
pose_seq. The pose sequence specifies a serial of waypoints define by
(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.
(motion_seq (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
The output for this example will display in the 3D render window.
$ cd $ACTIN_HOME $ cd examples/build/bin $ ./trainExample4
Try creating some more complex motion sequence using EcScript. Try creating additional motions using:
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.