Task 2 minimal solution
This tutorial shows how to run a minimal solution for Task 2, and briefly looks at the code for the solution. You can download the solution from github here: https://github.com/sprinkjm/cvchallenge_task2_jms
Overview
Task 2 asks you to interpret data from sensors, and issue environmental "detections" as polygons. This solution uses the most straightforward sensor (a laser line scanner) which coincidentally looks straight and forward on the vehicle. The messages we receive from that sensor are sensor_msgs/LaserScan, which are an array distances at a regular angular spacing.
Algorithm
The algorithm we use is the following: group points together if they are (piecewise) pretty close. The math for this is to see whether the last valid point is within some radius (say, 1m) of the point we are looking at. If it is, add it to the current polygon: else, record the polygon we just finished looking at, and use this point as the next possible start point for a polygon.
Here is some pseudocode that demonstrates the algorithm:
CloseEnough = 1 meter for each range in ranges if range is valid last = 0 if nearby.size > 0 last = nearby.last if nearby.size == 0 nearby.push(range) else if |last - range| < CloseEnough nearby.push(range) else publish(nearby) nearby.clear nearby.push(range) end publish(nearby)
Alternatives
You might wonder: did we need to do it this way? The answer is obviously, "no!" There are many different ways to do it. Here are some interesting alternatives:
- Capture laser points as an image, and find the biggest object: then publish that polygon as a detection
- Use whatever sensor you like, and publish the closes the detection that you find
- Use bayesian classification with existing worlds that you created, and whenever you find a likely candidate, make a polygon that surrounds a generic object of that type
What next?
Consider using this example as a baseline for Task 2 to see whether you can classify types of objects based on the polygons you find. Can you just use polygons to classify, or do other sensor types help you? For tutorials on classification from MathWorks, check out:
- https://www.mathworks.com/help/stats/examples/classification.html
- https://www.mathworks.com/help/stats/classification.html
Have questions? Head over to the forums and post away!