Home > src > PF > particles_in_view.m

particles_in_view

PURPOSE ^

PARTICLES_IN_VIEW - returns the indices of the particles which

SYNOPSIS ^

function indices = particles_in_view( particles, target, sensor )

DESCRIPTION ^

 PARTICLES_IN_VIEW - returns the indices of the particles which
 could be detected by sensor (considering the detection probability)

 param: particles - a MxN matrix of M particles with N attributes
 param: target - the target structure to whom the particles belong
 param: sensor - a sensor struct
 return: indices - the indices of the particles in view of sensor

 AUTHOR  Ronnie Johansson
 CREATED 2004-12-22
 ALTERED 2005-01-05 - added target to parameter list

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function indices = particles_in_view( particles, target, sensor )
0002 % PARTICLES_IN_VIEW - returns the indices of the particles which
0003 % could be detected by sensor (considering the detection probability)
0004 %
0005 % param: particles - a MxN matrix of M particles with N attributes
0006 % param: target - the target structure to whom the particles belong
0007 % param: sensor - a sensor struct
0008 % return: indices - the indices of the particles in view of sensor
0009 %
0010 % AUTHOR  Ronnie Johansson
0011 % CREATED 2004-12-22
0012 % ALTERED 2005-01-05 - added target to parameter list
0013 %
0014 
0015 [no_of_particles no_of_attributes] = size( particles );
0016 
0017 detection_range = sensor.range;
0018 sensor_pos = sensor.pos;
0019 
0020 indices = [];
0021 
0022 for p=1:no_of_particles
0023   dist = euclidean_distance( sensor_pos, particles(p,1:2) );
0024   if (dist < detection_range)
0025     degree = feval( sensor.detection_model, sensor, target ); 
0026     % the detection probability
0027     if rand < degree
0028       indices = [indices p];
0029     end
0030   end
0031 end

Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003