udacity / CarND-Kidnapped-Vehicle-Project

MIT License
121 stars 1.3k forks source link

Confusing description of method ParticleFilter::updateWeights #8

Closed vernor1 closed 5 years ago

vernor1 commented 7 years ago

The method description says:

         * @param std_landmark[] Array of dimension 2 [standard deviation of range [m],                                                                            
         *   standard deviation of bearing [rad]] 
...
        void updateWeights(double sensor_range, double std_landmark[], std::vector<LandmarkObs> observations,                                                      
                        Map map_landmarks);

However in main.cpp, the 2nd argument's nature is different:

        double sigma_landmark [2] = {0.3, 0.3}; // Landmark measurement uncertainty [x [m], y [m]]
...
                pf.updateWeights(sensor_range, sigma_landmark, noisy_observations, map);

It's better define a structure for passing this kind of data into the method.

yonomitt commented 7 years ago

This threw me off, too.

However, if you assume the standard deviations are actually range and bearing, converting them to x and y gives you a very small standard deviation for y, which causes the exponent in the gaussian to be a large negative number, which then leads to weights of zero.

Comment should definitely be fixed. I also agree with the idea of using a struct to minimize confusion.

mvirgo commented 5 years ago

Fixed by c0c726b, thanks for noting!