Common Error Advice for Cornell Students

15 views
Skip to first unread message

iRobot Create MATLAB Simulator

unread,
Apr 12, 2011, 12:50:36 AM4/12/11
to Listserv
This question seems to come up a lot so I figured I'd make a post in the Bugs forum and put it out on the listserv. If you are at Cornell and are using a control program with the simulator that is outputting a message along the lines of:
Error retrieving or saving <sensor name> data.
This is not from the simulator program itself. This message is being output by the control program. This is because the function call to read the sensor is surrounded by a try-catch statement that looks something like:
try
    [output variables] = sensorFunction(serPort);
    datastore.sensorName = [datastore.sensorName ; toc output variables];
catch
    disp('Error retrieving or saving <sensor name> data.')
end

Now in general, this is a good thing to have. This will provide a description of where the problem occurred, but it will not interrupt the program every time an error occurs. If it is a one-time or infrequent error, the program could still work fine. However, if this error occurs every time or most of the time, something needs to be fixed.

Usually in the case of frequent errors, the real error message will be a lot more helpful than "Error retrieving or saving...". There are many ways to have the error message show up, but here are two:
One: Comment out or delete the try statement and everything in the catch block. It should look like:
% try
    [output variables] = sensorFunction(serPort);
    datastore.sensorName = [datastore.sensorName ; toc output variables];
% catch
%     disp('Error retrieving or saving <sensor name> data.')
% end

Two: Add a statement to rethrow the error inside the [code]catch[/code] block. It should look like:
try
    [output variables] = sensorFunction(serPort);
    datastore.sensorName = [datastore.sensorName ; toc output variables];
catch me
    disp('Error retrieving or saving <sensor name> data.')
    rethrow(me)
end

These will do essentially the same thing, except the second one will also output "Error retrieving...". In either case, you can look at the normal MATLAB error message output and at least get an idea of where it's coming from. If you still don't know how to fix it or what it means, then you should post in this forum with the contents of that message.

A couple of common errors that occur can mostly be ignored. Firstly, if you tend to get "Overhead localization lost the robot" when you first run the control program, but not after that (on the simulator), this is probably caused by you starting the robot at the default position of (0,0,0). For some reason, the function OverheadLocalizationCreate for the real robot outputs [0,0,0] when it does not see the robot. Cornell's control programs have the statement:
[px, py, pt] = OverheadLocalizationCreate(tagNum);
if (px == 0 && py == 0 && pt == 0)
    % Only display if not just starting program at origin
    disp('Overhead localization lost the robot!')
    norobotcount = norobotcount + 1;

So when you start out at the default position of (0,0,0), it thinks the sensor can't see the robot. You can fix this by setting the robot position somewhere else (even just off by a little), or by changing the if statement to the following, assuming your robot starts moving right away:
if (px == 0 && py == 0 && pt == 0 && toc > 0.01)

Another common thing is to get all of the messages "Error retrieving of saving ..." for each of the sensors when you hit the Stop button to cease execution of the autonomous control program. This is because the simulator will deliberately throw an error when you hit the stop button to quit the control program, and then catch the error within itself before it displays. You can avoid outputting the "Error retrieving or saving..." messages by making all of your catch blocks look like:
catch me
    % Don't display error from quitting control program in simulator
    if ~strcmp(me.identifier,'SIMULATOR:AutonomousDisabled')
        disp('Error retrieving or saving <sensor name> data.')
    end
end

Or, better yet, you can allow the error to propagate through so it quits the control program earlier by doing:
catch me
    % Propagate the error used by the simulator to quit the control program
    if strcmp(me.identifier,'SIMULATOR:AutonomousDisabled')
        rethrow(me)
    else
        disp('Error retrieving or saving <sensor name> data.')
    end
end

Other than that, a couple other fixes to try against repetitive errors are first restarting the simulator. If you accidentally run two versions of SimulatorGUI at once it does funky things. Next try restarting MATLAB. This should also take case of the socket error when getting overhead localization data on the real robot. Finally restarting the computer. I'm not sure what that might do for you though, other than making it run a little faster by freeing up memory.

Sorry for such a long email, but hopefully this proves helpful. Let me know if anything seems to be incorrect, if you have a better method for dealing with stuff like this, or if there are any other common errors that I should address.

Reply all
Reply to author
Forward
0 new messages