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

Introduction

The main goal of this task is to learn to control a robot using multiple behaviours governed by a finite state machine (FSM).

Finite State Machines are a useful tool for programming robots. There are many resources you can read to undestand the concept of FSM, e.g. this article

Your task is to generate a trajectory that uses both trajectory generators from the Task 1 and Task 2. The robot should follow a rounded rectangle path that consists of two half circles and two straight lines:

Task 3

There are three parameters that describe the path: diameter, length and angle:

Task 3

You should write a script solution3.m that implements a callback function solution3. The parameters are passed to the control program through the variable-length argument list in the run_simulation function, e.g. run_simulation(@solution3, false, 1, 3, 0.5) where the arguments are:

The callback function for this task must be declared as:

function [forwBackVel, leftRightVel, rotVel, finish] = solution3(pts, contacts, position, orientation, varargin)
% The control loop callback function - the solution for Task 3

    % get the parameters
    if length(varargin) ~= 3,
         error('Wrong number of additional arguments: %d\n', length(varargin));
    end
    param_diameter = varargin{1};
    param_length = varargin{2};
    param_angle = 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
    ...
end

Please refer to solution solution0a in the Example Task for more details on variable-length argument list.

Task requirements

Grading

You can get 5 points, including: