Mobile Robots (EMOR) tutorials at WUT logo Mobile Robots (EMOR) tutorials at WUT

Introduction

The main goal of the first tutorial is to learn to generate simple trajectory for a mobile robot. The robot should follow a desired trajectory, i.e. move along a straight line to a commanded target point and reach both the commanded position and orientation.

The trajectory is a straight line to the specified destination point represented as three coordinates: [x, y, phi], where x and y is the position of the robot in the XY plane, and phi is the orientation of the robot. You need to provide the youBot with a program that allows it to move along the straight-line trajectory from the starting point (any starting point is possible) to the user-defined destination point.

The commanded orientation (phi) may be reached before or after reaching the desired position (x,y). However, the orientation should change during the linear motion:

Task 1 Task 1 Task 1

You can assume there are no obstacles and the destination point can be reached by moving on a straight line.

References

Please refer to:

The program

The script should be named solution1.m and it should be located in ~/ws_emor/emor_trs/youbot directory. The callback function for this task should be declared as:

function [forwBackVel, leftRightVel, rotVel, finish] = solution1(pts, contacts, position, orientation, varargin)
% The control loop callback function - the solution for task 1A

    % get the destination point
    if length(varargin) ~= 3,
        error('Wrong number of additional arguments: %d\n', length(varargin));
    end
    dest_x = varargin{1};
    dest_y = varargin{2};
    dest_phi = varargin{3};

    % declare the persistent variable that keeps the state of the Finite
    % State Machine (FSM)
    persistent state;
    if isempty(state),
        % the initial state of the FSM is 'init'
        state = 'init';
    end

    % initialize the robot control variables (returned by this function)
    finish = false;
    forwBackVel = 0;
    leftRightVel = 0;
    rotVel = 0;

    % TODO: manage the states of FSM
    % Write your code here...
end

To run the simulation and the control program using with the callback control function solution1 you have to run run-simulation function with proper arguments. The destination point is passed to the control program through the variable-length argument list in the run_simulation function, e.g. run_simulation(@solution1, false, 1, 2, deg2rad(90)) where the arguments are:

Note that the steps from the instruction in the Example Task page must be followed in order to enable the communication between Matlab and CoppeliaSim. Also, the CoppeliaSim application must be running with a proper scene!

Task requirements

Please Note that the regulator of angular velocity and regulators of linear velocities are independent, so the following cases are acceptable:

Still, at the end, both desired orientation and position must be reached within some tolerance, e.g. 0.05 meters for position and 5 degrees for orientation.

Grading

You can get 5 points, including:

A complete solution for a task is the source code and a report.

Please refer to the Schedule page for consultation dates and deadlines.