Guest User

Untitled

a guest
Nov 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. % Open the file with the laser scan.
  2. fileid = fopen('/home/g33ky/Documents/Programming/Python/visualise_logs/simulated_data/oneframe');
  3.  
  4. % Read a line/scan, remove the trailing whitespace and split the
  5. % measurements. Should be 181 laser beams / measurements for the simulated
  6. % data, because the degrees are in the range [-90, 90] moving with 1
  7. % degree.
  8. tline = deblank(fgets(fileid));
  9. cellscan = regexp(tline, ' ', 'split');
  10.  
  11. % Convert into an array of numbers.
  12. measurements = cellfun(@str2num, cellscan)
  13. maxdist = max(max(measurements)); % max distance.
  14.  
  15. % Number of scans.
  16. numofscans = length(measurements);
  17.  
  18. % Image results: original image + 2 grayscales.
  19. original = zeros(200);
  20. graydist = zeros(200);
  21. grayangle = zeros(200);
  22.  
  23. %imshow(original)
  24.  
  25. for deg = 1:numofscans
  26.  
  27. % Convert to radians.
  28. anglerad = degtorad(deg-91);
  29.  
  30. % Find Euclidean coordinates. Adjust to matlab arrays (+1)
  31. x = cos(anglerad) * measurements(deg) + 1;
  32. y = sin(anglerad) * measurements(deg) + 1;
  33.  
  34. % Round the coordinates, after some scaling (multiply with 10) to
  35. % get cm accuracy. Robot's position at [1, 100].
  36. imgx = round(10 * x);
  37. imgy = round(10 * y + 100);
  38.  
  39.  
  40. orginal(imgx, imgy) = 255;
  41.  
  42. end
  43.  
  44. %imshow(original)
  45. %original
  46.  
  47. % Close the file.
  48. fclose(fileid);
Add Comment
Please, Sign In to add comment