Behavior of provided software
The provided starter-project moves the robot as shown in this animation. In includes some body movements and forward crawling. Note, the front of the robot is to the left in all the animations.
Breakdown of robot body movement function calls
Below are the main code segments in the demonstration program provided, alongside the movements they result in.
// *******************************************************************************************************
// This code segment is a “dance”. With legs planted, the body moves left, back, right, then forward.
// *******************************************************************************************************
move_body_absolute(-move_length, 0, move_up); //moves left: negative on the X-xis
move_body_absolute(0, -move_length, move_up); //moves back: negative on Y-axis
move_body_absolute(move_length, 0, move_up); // moves right: positive on X-axis
move_body_absolute(0, move_length, move_up); // moves fowrard: positive on Y-axis
move_body_absolute(0, 0, move_up); // moves center: 0 on bot X and Y axes
// *******************************************************************************************************
// This code segment is a “dance”. With legs planted, the body moves down and up repeatedly.
// *******************************************************************************************************
// sitting to standing sequence
move_body_absolute(0, 0, 0);
wait_all_reach();
move_body_absolute(0, 0, move_up);
wait_all_reach();
move_body_absolute(0, 0, 0);
wait_all_reach();
move_body_absolute(0, 0, move_up);
wait_all_reach();
move_body_absolute(0, 0, 0);
wait_all_reach();
// *****************************************************************************************
// Demonstration of rotation (nodding)
// *****************************************************************************************
#define rotate_degree 20
move_body_absolute(0, 0, move_up);
delay(200);
rotate_body_absolute_x(-rotate_degree, move_up); // Nose down (negative rotation on X)
rotate_body_absolute_x(rotate_degree, move_up); // Nose up (positive rotation on X)
move_body_absolute(0, 0, move_up);
rotate_body_absolute_y(-rotate_degree, move_up); // Lean left (negative vlalue on Y)
rotate_body_absolute_y(rotate_degree, move_up); // Lean right (positive value on y)
move_body_absolute(0, 0, move_up);
move_body_absolute(0, 0, 0);
wait_all_reach();
delay(2000);
Demonstration of the crawling sequence
////////////////////////////////////////////////////
// PHASE 1 of gait: forward-left and rear-right legs
//Move LEG 2 (forward left)
move_speed = leg_move_speed;
set_site(2, x_default, 0, z_up); // raise it
wait_all_reach();
set_site(2, x_default, 2 * y_step, z_up); // move it fowrard
wait_all_reach();
set_site(2, x_default, 2 * y_step, z_default); // put it down
wait_all_reach();
//Move body forward – flexing LEG 2, and extending LEG 1
move_speed = body_move_speed;
set_site(0, x_default, 0, z_default);
set_site(1, x_default, 2 * y_step, z_default);
set_site(2, x_default, y_step, z_default);
set_site(3, x_default, y_step, z_default);
wait_all_reach();
// Move LEG 1 (rear right)
move_speed = leg_move_speed;
set_site(1, x_default, 2 * y_step, z_up); // raise it (it’s extended from the previous step)
wait_all_reach();
set_site(1, x_default, 0, z_up); // bring it in
wait_all_reach();
set_site(1, x_default, 0, z_default); // put it down
wait_all_reach();
////////////////////////////////////////////////////
// PHASE 2 of gait, forward-right and rear-left legs
//Move LEG 0 (forward right)
set_site(0, x_default, 0, z_up); // raise it
wait_all_reach();
set_site(0, x_default, 2 * y_step, z_up); // move it forward
wait_all_reach();
set_site(0, x_default, 2 * y_step, z_default); // put it down
wait_all_reach();
//Move body forward – flexing LEG 0, and extending LEG 3
move_speed = body_move_speed;
set_site(0, x_default, y_step, z_default);
set_site(1, x_default, y_step, z_default);
set_site(2, x_default, 0, z_default);
set_site(3, x_default, 2 * y_step, z_default);
wait_all_reach();
// Move LEG 3 (rear left)
move_speed = leg_move_speed;
set_site(3, x_default, 2 * y_step, z_up); // raise it (it’s extended from previous step)
wait_all_reach();
set_site(3, x_default, 0, z_up); // bring it in
wait_all_reach();
set_site(3, x_default, 0, z_default); // put it down
wait_all_reach();