5. Coordinate-Based Motion

5.1. Angular Motion

There are two types of angular motion inside of dLib (more can be added):

  • turn_with_pid: turns to an absolute heading that is relative to the start heading of the bot

  • turn_to_point: turns to a specific coordinate point that is relative to the start heading & position of the robot

Example:

// turn to point
void  turn_to_point(dlib::Vector2d  point, bool  reverse  =  false) {
auto  angle  =  odom.angle_to(point,reverse);
turn_with_pid(angle);
}

turn_to_point({12,12},false); // turns to 12,12

5.2. Lateral Motion

There are two types of angular motion inside of dLib (more can be added):

  • move_with_pid: moves to a relative displacement (always x distance away from the setpoint)

  • move_to_point: turns to a specific coordinate point that is relative to the start heading & position of the robot and moves to it afterwards

Example:

// turn to point
void  move_to_point(dlib::Vector2d  point, bool  reverse  =  false) {
    turn_to_point(point,reverse);

    auto  displacement  =  odom.displacement_to(point,reverse);
    move_with_pid(displacement);
    }

    move_to_point({12,12},false); // turns & moves to 12,12