Docstoc

guide_english

Document Sample
guide_english Powered By Docstoc
					Getting started instructions for the Khepera robot
    1. Run MatLab
    2. If you are inexperienced with programming in MatLab, it might be a good idea to
        read the MatLab tutorial. Link available from course web page.
        \kurser\TDBD17\VT04\matlab-tutorial.m
    3. Change work directory in MatLab to someone in the groups home directory with
        the command cd
    4. If the robot is not connected already, do so according to the instructions in the
        Khepera manual
    5. Download the drivers to your working directory and unzip the file. The drivers can
        be found at \kurser\TDBD17\VT04\PCdrivers.zip
    6. To be able to send any commands to the robot you need to open the
        communications port. So you need to write the function comm_open according to
        assignment 1, part a1
    7. You can also write the function comm_close to close a port that has already been
        opened.
    8. Now open the communications port with your new function
    9. Create a new MatLab file called Khepcom
    10. Below is a very basic version of Khepcom. With this you are able to send basic
        commands to the robot, but it has no errorchecking and is not able to send
        commands to the camera, but it is a start.

function [ok, values] = khepcom(cmd, arg, N, turretID)
global port
for n = 1:length(arg)
     cmd = sprintf('%s,%d', cmd, arg(n));
     n = n+1;
end
values = ksend([cmd 10], port, 1);
ok = 1;
    11. Now it is time to try some new commands:
           a. Read the ir-sensors, what is the maxvalue?
           b. Let the robot rotate in a circle
           c. Read the its speed while it is moving

    12. What is the difference in MatLab between the commands:
           a. [ok, values] = khepcom(‘N’,[],8,0)
           b. khepcom(‘N’,[],8,0)
    13. Transform the output from ir-sensors to an matrix of numbers
    14. Run a loop where you plot the sum of the ir-sensors versus time. Useful
        commands are plot and hold on, hold off

By this time you should be able to both transmit and receive data from the robot. A good
idea is to start assignment 1 now and increase the functionality of Khepcom according to
the specification.

Hints:
    Create a function start that takes port_id as only argument and runs
       comm_open. Saves keystrokes  It can also be used to run other useful MatLab
       commands, such as format compact
    A function stop can also be very convenient for those times when the robot goes
       out of control...
    Well written functions now will save you time in the long run
    Debug printouts is your best friend during programming! All commands that
       doesn’t have a ‘;’ at the end will give a printout to the screen. A good programmer


Getting started guide for Khepera   Intelligent Robotics, VT04
Fredrik Lindqvist                       fredrikl@cs.umu.se
        can also create a global variable that decides if there should be any printouts or
        not.
       The MatLab command help is very useful
       The output from the robot is in the form of one big string. In order to use it, it
        needs to be analysed and the arguments from the command should be returned
        to the user in a matrix of numbers.
       The camera has problems with taking pictures when the robot is moving to fast.
        The image tends to be just a blur. There are several ways to circumvent this
        problem, such as moving slower or halting the robot whenever it takes a picture.
       You must allow the robot to finish one command before giving a new instruction.
       If the robot should encounter a problem or a bug it can often start to spin out of
        control. In that case there is a reset button underneath it.
       MatLab can have some problems with the UNIX system. Sometimes it is unable to
        see if a file has been changed and may run the old code. If this happens, you can
        use the local hard drive to store the files. Just remember to copy them to your
        home directory and delete the files afterwards. The function
        clear(‘function_name’) can be used to wipe the old function from memory and
        force a reread.
       If you try to open a port that is already open, there is a risk that the
        computer/MatLab will crash, so make sure all port you try to open haven’t already
        been opened.


Khepcom will need much better error control than this version has. It needs to detect
error such as:
     Is the command being sent to the robot ok?
     Is the number of arguments given correct?
     The output from the robot, does it follow the right syntax?
     The output from the robot, does it have enough arguments?
     Commands to the camera follow a special syntax and may need a special solution.
       Remember that these commands also needs to be checked both on the way to the
       robot and when received.
     If an error is encountered, repeat until a correct response has been received or
       until we have tried N times

Remember to answer the questions at the end of the assignment.




Getting started guide for Khepera   Intelligent Robotics, VT04
Fredrik Lindqvist                       fredrikl@cs.umu.se

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:5
posted:5/12/2011
language:English
pages:2