$24.99
All of the code for this assignment is in Python, and located within ‘hw4.zip’. A guide for how to install necessary libraries is found in ‘README.md’. The only file where you need to make edits is ‘questions.py’. Please add comments to your code to help the graders understand what you are doing. If you make a mistake, you are much more likely to receive partial credit if the code is understandable.
Q1. Plane fitting (5 points).
In this question, you are given a set P of 100 points and asked to fit a plane to these points. The output of these functions should be a point intercept of the plane (a vector called “center”) and the plane surface normal (a vector called “normal”).
(a) Implement the function q1 a in questions.py: fit a plane by calculating the sample mean and covariance matrix of the points. You will need to obtain the Eigen values and vectors of the covariance matrix in order to complete this question. You can test your implementation by running the command $python q1 a in your terminal.
(b) Test your plane fitting on an example with outliers by running the command $python q1 b. How is this different from the result in part (a) and why?
(c) Implement the function q1 c in questions.py: fit a plane using a ransac based method. You can test your implementation by running $python hw4.py q1 c in your terminal. What are the strengths and weaknesses of each approach?
Figure 1: (a) the sphere localized in Q2. Figure 2: (b) the cylinder localized in Q3.
Q2. Sphere fitting (5 points).
In this question, you must use RANSAC to localize a sphere given point cloud data. The point cloud contains a ball that is only partially visible to the sensor. The position of the center of the ball is unknown. The radius is unknown, but between 5cm (0.05m) and 11cm (0.11m). Write the function q2 in questions.py that calculates these two quantities. You can test your code using the cropped point cloud (see commented hw4.py). But, you should submit code that works on the entire point cloud without cropping. Important: please do NOT use any external libraries for plane fitting.
Hint: one way to generate sphere hypotheses is as follows:
1
(a) sample a point from the cloud;
(b) sample a radius of the candidate sphere between 5 and 11cm;
(c) project a vector from the sampled point in the direction of the associated surface normal for a distanceequal to the sampled radius. This point would be at the center of the candidate sphere.
Q3. Cylinder fitting (5 points).
Same as Q3 except for a cylinder. This question is harder because you need to calculate the center, the orientation, and the radius (between 0.05m and 0.1m). The orientation should be returned in the form of a unit vector pointing along the axis of the cylinder (either direction is fine). You only need to solve this problem for the segmented cloud, as implemented in the code. The function you should implement is q3 in questions.py.
Hint: one way to generate cylinder hypotheses is as follows:
(a) Sample a radius for the candidate cylinder between 5 and 10 cm.
(b) Sample two points from the cloud
(c) Set the cylinder axis direction equal to the direction of the cross product between the surface normalsassociated with the two sampled points.
(d) Pick one of the sampled points from the cloud and use it to estimate a candidate center, just as you didin Q2.
(e) Project the points in the cloud onto the plane orthogonal to the axis you just calculated. You can do thisprojection by multiplying the points in the cloud by this matrix: I −aˆaˆT, where ˆa is equal to the axis of the cylinder. Also project the candidate center into this plane in the same way.
(f) Evaluate number of inliers (i.e. ∥P¯ −c¯∥2 < ϵ where P¯ is the projected point cloud, ¯c is the projected candidate center, and ϵ is the noise threshold)
Q4. Iterated closest point (ICP) (5 points).
Given a set of points M, and another a set of points D with a different pose, ICP algorithm could be used to find a 4-by-4 transformation matrix T so that D = TM.
(a) Implement the function q4 a to find the transformation matrix that aligns two point clouds given full correspondences between points in the two clouds. In other words, D and M are the same point cloud but in different poses. You can test your implementation by running: $python hw4.py q4 a
(b) Run $python hw4.py q4 b to test your implementation from part (a) on noisy data. Explain why the algorithm still works when gaussian noise is added to one of the point clouds, but does not work when the order of the points is shuffled.
(c) Implement the function q4 c to perform iterative closest point (ICP). Your implementation should get reasonably alignment on shuffled and noisy data: run $python hw4.py q4 c to test this.
2