Home > src > PF > negative_observations.m

negative_observations

PURPOSE ^

NEGATIVE_OBSERVATIONS - discount particles for which observations

SYNOPSIS ^

function neg_weights = negative_observations( particles, observations,target, sensors,resources, discount)

DESCRIPTION ^

 NEGATIVE_OBSERVATIONS - discount particles for which observations
 should occur (if they were correct) but does not. This function
 checks for each sensor in 'sensors' if they should have detected
 the target if the particles 'in view' were correct hypotheses.

 param: particles - the predicted set of particles
 param: observations - the set of observations relevant for the
        particles
 param: target - the target in question (target struct)
 param: sensors - the array of (possibly all) sensor structs
 param: resources - the array of own forces
 param: discount - the discount to weight the particles
 with. (Numeric between 0 and 1, typically above 0.5)

 AUTHOR  Ronnie Johansson
 CREATED 2004-12-22
 ALTERED 2005-01-05 - changed call to particles in view
 ALTERED 2005-01-18 - minor correction
 ALTERED 2005-01-26 - added support for checking observations by
                      own forces
 ALTERED 2005-01-27 - small hack setting weights of paticles "observed" by
                      own resource to 0

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function neg_weights = negative_observations( particles, observations, ...
0002                                               target, sensors, ...
0003                           resources, discount)
0004 % NEGATIVE_OBSERVATIONS - discount particles for which observations
0005 % should occur (if they were correct) but does not. This function
0006 % checks for each sensor in 'sensors' if they should have detected
0007 % the target if the particles 'in view' were correct hypotheses.
0008 %
0009 % param: particles - the predicted set of particles
0010 % param: observations - the set of observations relevant for the
0011 %        particles
0012 % param: target - the target in question (target struct)
0013 % param: sensors - the array of (possibly all) sensor structs
0014 % param: resources - the array of own forces
0015 % param: discount - the discount to weight the particles
0016 % with. (Numeric between 0 and 1, typically above 0.5)
0017 %
0018 % AUTHOR  Ronnie Johansson
0019 % CREATED 2004-12-22
0020 % ALTERED 2005-01-05 - changed call to particles in view
0021 % ALTERED 2005-01-18 - minor correction
0022 % ALTERED 2005-01-26 - added support for checking observations by
0023 %                      own forces
0024 % ALTERED 2005-01-27 - small hack setting weights of paticles "observed" by
0025 %                      own resource to 0
0026 %
0027 
0028 [no_of_particles no_of_attributes] = size( particles );
0029 
0030 no_of_sensors = length( sensors );
0031 no_of_forces = length( resources );
0032 neg_weights = ones( no_of_particles, 1 );
0033 
0034 for s=1:no_of_sensors
0035   sensor = sensors(s);
0036 
0037   % check if sensor s has detected the target
0038   indices = structfind( observations, 'sensor_id', sensor.id );
0039   if ~isempty(indices)
0040     % sensor s has made some observations
0041     indices = structfind( observations(indices), 'target_id', target.id );
0042     if ~isempty(indices)
0043       % sensor s has observed the target - hence, do not discount
0044       % the particles in its view (instead try the next sensor)
0045       continue;
0046     end
0047   end
0048   
0049   % sensor s has not detected target - discount any particles
0050   % within its view
0051   indices = particles_in_view( particles, target, sensor );
0052   if ~isempty( indices )
0053     neg_weights( indices ) = neg_weights( indices )*discount;
0054   end
0055 end
0056 
0057 %% check if any particles are in view of the own forces
0058 for f=1:no_of_forces
0059   indices = particles_in_view_of_force( particles, target, ...
0060                     resources(f));
0061   if ~isempty( indices )
0062 %    neg_weights( indices ) = neg_weights( indices )*discount;
0063     neg_weights( indices ) = 0; % kill the particles
0064   end
0065 end
0066 
0067 
0068 
0069 
0070

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