Some Tips When Run RatSLAM MATLAB Code
Fangwen Yu
Sep 21, 2017
0. RatSLAM MATLAB Code and Datasets
Open source code:
https://wiki.qut.edu.au/display/cyphy/RatSLAM+MATLAB
Datasets Links:
Here is a link to the iRat's video:
https://www.dropbox.com/s/4905nzbx4pnihr7/log_irat_red.avi?dl=0
The iRat's odom in text form:
https://www.dropbox.com/s/9ns3uknayad8y1t/log_irat_red.txt?dl=0
And the overhead video:
https://www.dropbox.com/s/ffosfmmyzy9gfkq/log_overhead.avi?dl=0
1. Read video data
For latest vision MATLAB, the aviread function was been removed instead by VideoReader function.
In rs_main.m,
/////////////////////
% specify the movie and the frames to read
movinfo = aviinfo(MOV_FILE);
START_FRAME = 1;
END_FRAME = movinfo.NumFrames;
% these are the raw image dimensions
% the offset is the number of pixels from the centre of the image to the
% true zero rotation direction
IMAGE_Y_SIZE = movinfo.Height;
IMAGE_X_SIZE = movinfo.Width;
Can be replaced by follow code
% specify the movie and the frames to read
movinfo = VideoReader(MOV_FILE);
START_FRAME = 1;
END_FRAME = movinfo.NumberOfFrames;
FRAME_NUMBER = movinfo.NumberOfFrames;
% these are the raw image dimensions
% the offset is the number of pixels from the centre of the image to the
% true zero rotation direction
IMAGE_Y_SIZE = movinfo.Height;
IMAGE_X_SIZE = movinfo.Width;
////////////
% grab the video info and first block … send to the vision module
% aviread
% mov = aviread(MOV_FILE, START_FRAME:(BLOCK_READ+START_FRAME));
Can be replaced by follow code
% grab the video info and first block … send to the vision module
mov_temp = read(movinfo, [START_FRAME (BLOCK_READ+START_FRAME)]);
////////////////////////////////
% save the experience map information to the disk for later playback
% read the avi file in blocks and record the delta time
if (mod(frame, BLOCK_READ) == 0)
save(strcat(LOG_FILE, num2str(frame)), 'frame', 'exps', 'exp_history', 'vt_history');
time_delta_s = [time_delta_s; toc]; %#ok<AGROW>
mov = aviread(MOV_FILE, (frame+START_FRAME):min([(frame+BLOCK_READ – 1)+START_FRAME, movinfo.NumFrames]));
if ODO_FILE ~= 0
ododata = csvread(ODO_FILE, frame+START_FRAME, 0, [frame+START_FRAME 0 min([(frame+BLOCK_READ – 1)+START_FRAME, movinfo.NumFrames]) 1]);
end
tic
end
% visual templates and visual odo uses intensity so convert to grayscale
im = rgb2gray(mov(mod(frame, BLOCK_READ) + 1).cdata);
Can be replaced by follow code
% save the experience map information to the disk for later playback
% read the avi file in blocks and record the delta time
if (mod(frame, BLOCK_READ) == 0)
save(strcat(LOG_FILE, num2str(frame)), 'frame', 'exps', 'exp_history', 'vt_history');
time_delta_s = [time_delta_s; toc]; %#ok<AGROW>
mov_temp = read(movinfo, [(frame+START_FRAME) min([(frame+BLOCK_READ – 1)+START_FRAME, FRAME_NUMBER])]);
if ODO_FILE ~= 0
ododata = csvread(ODO_FILE, frame+START_FRAME, 0, [frame+START_FRAME 0 min([(frame+BLOCK_READ – 1)+START_FRAME, FRAME_NUMBER]) 1]);
end
tic
end
% visual templates and visual odo uses intensity so convert to grayscale
% aviread
% im = rgb2gray(mov(mod(frame, BLOCK_READ) + 1).cdata);
mov = immovie(mov_temp);
im = rgb2gray(mov(mod(frame, BLOCK_READ) + 1).cdata);
2. Parameter
'IMAGE_VT_Y_RANGE', (480/2 – 80 – 40):(480/2 + 30 – 40), …
'IMAGE_VT_X_RANGE', (640/2 – 280 + 15):(640/2 – 10 + 15), …
'IMAGE_VTRANS_Y_RANGE', 60:230, …
'IMAGE_VROT_Y_RANGE', 75:235, …
'IMAGE_ODO_X_RANGE', (180 + 15):(400 + 15), …
The range can not exceed the video image size.
3. The Running Results
4. Useful links
VideoReader
readFrame
immovie
Brain Inspired Navigation Blog
New discovery worth spreading on brain-inspired navigation in neurorobotics and neuroscience