Mobile Robots – lab3

Introduction

The goal of the assignment is to extract features (line segments) from laser scans.
Note – the algorithms of feature extraction will be used in the next assignment on feature based localization.

Preparation

Before class, you should read the description of the task and auxiliary materials in the following scope:
  1. recall transformations of coordinates between the polar and Cartesian systems;
  2. recall the formulas of coordinate transformations between shifted and rotated coordinate systems relative to each other;
  3. read the article Nguyen, V et al. A comparison of line extraction algorithms using 2D laser rangefinder for indoor mobile robotics, IROS 2005, pp. 1929-1934 and choose the line detection algorithm to be implemented in class.

Line detection using JSON file

  1. Implement one of the selected line detection methods.
  2. Tune the parameters of the method
  3. Using the data stored in the files, evaluate the effectiveness and correctness of line detection.

Note: To simplify the task, you can limit the range of scanned data from the scanner by narrowing the observed angle and limiting the maximum distance.

Additional information

Reference data

JSON file content: array { object { array { float(3) } pose # [x,y,theta in degrees] float time array { float(512)} scan # distances in meters in [-pi/2,pi/2] } # a single measurement }

line_detection_1

line_detection_2

line_localization_1

Report

The report should be sent by email in pdf format and should contain:
  1. Brief description of the line detection algorithm used
  2. Results of line detection
  3. Observations and conclusions

Sample code

Scan processing: reading JSON file and plotting

import json ##reading data from the file json_data = open('line_detection_1.json') data = json.load(json_data) ### plot in polar system import matplotlib.pyplot as plt import numpy as np x = np.arange(0,512) theta = (np.pi/512 )*(x-256) # angle in radians # Reading first dataset (index 0) scan_data=data[0]["scan"] fig1 = plt.figure() ax1 = fig1.add_axes([0.1,0.1,0.8,0.8],polar=True) # TODO: modify the code to use Cartesian coordinates line, = ax1.plot(theta,scan_data,lw=2.5) ax1.set_ylim(0,2) # plot range plt.show()

Drawing lines

import numpy as np import pylab as pl from matplotlib import collections as mc lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]] c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)]) lc = mc.LineCollection(lines, colors=c, linewidths=2) lines2 = [[(0.1, 1.1), (1.1, 1.1)], [(2.1, 3.1), (3.1, 3.1)], [(1.1, 2.1), (1.1, 3.1)]] lc2 = mc.LineCollection(lines2, colors=[0,0,0],linewidths=1) fig, ax = pl.subplots() ax.add_collection(lc) ax.add_collection(lc2) ax.autoscale() ax.margins(0.1) pl.show()