My code:
% Program to make the robot run by setting specified distance.
comm = strcat('COM', num2str(8));
a = instrfind('port',comm);
[serialObject] = RoombaInit(8) ;
%initialize the port
pause (2)
% Pause for 2 seconds
travelDist(serialObject,0.2,2)
% travel with speed of 0.2 m/s and distance of given mts.
[Distance] = DistanceSensorRoomba(serialObject);
% Read the distance traveled.
The actual and experimental distance are almost equal. the error max is about 0.01 m and the actual distance is always higher. {but error is negligible}.
A few limitations: The speed could be set up using this function is in the range of 0.025m/s and 0.5m/s. If negative speed is entered, function uses absolute value. When this and turnAngle commands are used, they use the scripting from create Open Interface thus limiting to the fact tht until these commands are completed, it will not be able to accept any other commands.
The travelDist function can be edited though!!
btw thanks to Dr.Joel Esposito.
Citation: Esposito, Joel M., Barton, Owen, Koehler Joshua, "Matlab Toolbox for the
Create Robot", www.usna.edu/Users/weapsys/esposito/roomba.matlab/,
Copyright 2008