MATLAB: Do the TurtleBot examples “Obstacle Avoidance using TurtleBot” and “Controlling the TurtleBot with Teleoperation” not work as expected

Robotics System Toolbox

Why does the map visualization look incorrect in the "Obstacle Avoidance using TurtleBot" and “Controlling the TurtleBot with Teleoperation” examples (it looks like it’s rotated by 90 degrees)? Also, why does the robot collide with the obstacles in the "Obstacle Avoidance using TurtleBot" example?

Best Answer

This is a known bug in MATLAB R2015a. As a workaround, you have to edit some files in the following location:
<matlabroot>\toolbox\robotics\robotexamples\ros\helpers\
Please replace “<matlabroot>” with the actual path of your MATLAB installation. It can be found by typing the following command at the MATLAB command prompt,
>> matlabroot
You need to change three files:
1) Line 272 in ExampleHelperTurtleBotCommunicator.m
2) Line 117 in exampleHelperTurtleBotObstacleTimer.m
3) Line 20 in exampleHelperTurtleBotShowGrid.m
On the mentioned lines, multiply the output from the readCartesian function with a matrix ([0 1; -1 0]). This will change the orientation of the laser scan to match the expectation of the example code.
For example,
>> readCartesian(message);
Should be changed to,
>> readCartesian(message) * [0 1; -1 0];
Save these files after the above changes. You may need administrative privileges to save the modified files. Use the REHASH command to force MATLAB to update the toolbox cache file:
>> rehash toolboxcache
Related Question