head (EMYS) API examples

Using Emys API we do not have to worry how to communicate with Emys drives via dynamixel protocol, we simply send new positions to servos or use ready made functions for most of often used movements.

//direct change of joint position (not recommended!)
robot.body.neck.pitch.val = 185 smooth: 2s;//it will change neck pitch position from current one to new one (185 degrees) by smooth trajectory in time of 2s
//remember!
//never write:
//robot.body.neck.pitch.val = 185;
//it will cause rapid movement to new position and might cause damage to robot drives 
//better way to change joint position is to use functions which guarantee safe movement
//using this functions you define new position relative to joint neutral position which is simpler than to remember joint values in degrees
robot.body.neck.pitch.Move(5, 2s);//move to new position in 2 seconds
robot.body.neck.pitch.MoveSpeed(-5, 5);//move to new position with speed of 5 degrees per second
//we can also simultaneously move more joints (neck and head pitch, head yaw) at the time. 
robot.body.neck.head.MoveAt(-10, -20, 3s); //yaw and pitch are given in reference to head neutral position
//often we can use ready functions for simple movements - we just need two parameters (intensity from 0 to 10 and movement duration)
robot.body.neck.head.MoveLeft(10,2s);//turn head to the left (maximum position) in to seconds
robot.body.neck.head.MoveLeft(0,2s);//intensity is 0, so head will go back to neutral position (in head yaw joint) in 2 seconds
//You can also use functions for various Emys expressions (parametrized by intensity and time):
robot.body.neck.head.ExpAngry(10,2s); //Emys will express maximum anger using his eyes and discs
robot.body.neck.head.BehaveAngry(10,2s); //Emys will express maximum anger using all his joints
loop{
   echo(robot.body.neck.head.sensor[up].val); // display touch sensor analog value
   echo(robot.body.neck.head.sensor[up].touch); // display touch sensor digital value
   sleep(200ms);
},
 

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation