Target sources added.
authorFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Tue, 14 Nov 2017 23:02:09 +0000 (18:02 -0500)
committerFrancoisGrondin <francois.grondin2@usherbrooke.ca>
Tue, 14 Nov 2017 23:02:09 +0000 (18:02 -0500)
39 files changed:
CMakeLists.txt
config/beam.cfg
demo/configs.c
demo/configs.h
demo/objects.c
demo/objects.h
demo/parameters.c
demo/parameters.h
demo/profiler.c
demo/profiler.h
demo/threads.c
include/odas/odas.h
src/aconnector/acon_targets.c [new file with mode: 0644]
src/aconnector/acon_targets.h [new file with mode: 0644]
src/aconnector/acon_tracks.c
src/ainjector/ainj_targets.c [new file with mode: 0644]
src/ainjector/ainj_targets.h [new file with mode: 0644]
src/amessage/amsg_targets.c [new file with mode: 0644]
src/amessage/amsg_targets.h [new file with mode: 0644]
src/amodule/amod_sst.c
src/amodule/amod_sst.h
src/connector/con_targets.c [new file with mode: 0644]
src/connector/con_targets.h [new file with mode: 0644]
src/injector/inj_targets.c [new file with mode: 0644]
src/injector/inj_targets.h [new file with mode: 0644]
src/message/msg_targets.c [new file with mode: 0644]
src/message/msg_targets.h [new file with mode: 0644]
src/module/mod_sss.c
src/module/mod_sst.c
src/module/mod_sst.h
src/signal/target.c [new file with mode: 0644]
src/signal/target.h [new file with mode: 0644]
src/signal/track.c
src/signal/track.h
src/sink/snk_tracks.c
src/system/kalman2kalman.c
src/system/kalman2kalman.h
src/system/particle2particle.c
src/system/particle2particle.h

index 9a699e3b71cfcbd9840c58e3633b695915f62010..81cd971c1d4748289d2b5e32a591be807d1504fe 100644 (file)
@@ -66,6 +66,7 @@ set(SRC
     src/signal/spatialindex.c
     src/signal/spatialmask.c
     src/signal/steer.c
+    src/signal/target.c
     src/signal/tau.c
     src/signal/tdoa.c
     src/signal/track.c
@@ -115,12 +116,15 @@ set(SRC
     src/aconnector/acon_pots.c
     src/aconnector/acon_powers.c
     src/aconnector/acon_spectra.c
+    src/aconnector/acon_targets.c
     src/aconnector/acon_tracks.c
+    src/ainjector/ainj_targets.c
     src/amessage/amsg_categories.c
     src/amessage/amsg_hops.c
     src/amessage/amsg_pots.c
     src/amessage/amsg_powers.c
     src/amessage/amsg_spectra.c
+    src/amessage/amsg_targets.c
     src/amessage/amsg_tracks.c
     src/amodule/amod_classify.c
     src/amodule/amod_istft.c
@@ -144,12 +148,15 @@ set(SRC
     src/connector/con_pots.c
     src/connector/con_powers.c
     src/connector/con_spectra.c
+    src/connector/con_targets.c
     src/connector/con_tracks.c
+    src/injector/inj_targets.c
     src/message/msg_categories.c
     src/message/msg_hops.c
     src/message/msg_pots.c
     src/message/msg_powers.c
     src/message/msg_spectra.c
+    src/message/msg_targets.c
     src/message/msg_tracks.c
     src/module/mod_classify.c
     src/module/mod_istft.c
index 9ca2dc85959741ad7f192669740ad638601bf6f5..39fb55aa1e9db3e53be28752ed2af529f418a787 100644 (file)
@@ -181,6 +181,8 @@ ssl:
 
 };
 
+# Target sources
+
 # Sound Source Tracking
 
 sst:
@@ -190,6 +192,10 @@ sst:
 
     mode = "kalman";
 
+    # Add is either "static" or "dynamic"
+
+    add = "dynamic";
+
     # Parameters used by both the Kalman and particle filter
 
     active = (
@@ -202,6 +208,7 @@ sst:
 
     sigmaR2_prob = 0.0025;
     sigmaR2_active = 0.0225;
+    sigmaR2_target = 0.0025;
     Pfalse = 0.1;
     Pnew = 0.1;
     Ptrack = 0.8;
@@ -238,6 +245,11 @@ sst:
 
     };
 
+    target: 
+    (
+        { tag = "fan"; x = 0.0; y = 0.0; z = 1.0 }
+    );
+
     # Output to export tracked sources
     tracked: {
 
index 3283a7a549bbb2b56ec628ba925874425a05613a..f69296a72babd570d31523a63918707c7802d9f8 100644 (file)
 
                 cfgs->snk_pots_ssl_config = parameters_snk_pots_ssl_config(file_config);
 
+        // +----------------------------------------------------------+
+        // | Target                                                   |
+        // +----------------------------------------------------------+  
+
+            // +------------------------------------------------------+
+            // | Injector                                             |
+            // +------------------------------------------------------+  
+
+                cfgs->inj_targets_sst_config = parameters_inj_targets_sst_config(file_config);
+
+            // +------------------------------------------------------+
+            // | Message                                              |
+            // +------------------------------------------------------+              
+
+                cfgs->msg_targets_sst_config = parameters_msg_targets_sst_config(file_config);
+
         // +----------------------------------------------------------+
         // | SST                                                      |
         // +----------------------------------------------------------+  
             
                 snk_pots_cfg_destroy(cfgs->snk_pots_ssl_config);
 
+        // +----------------------------------------------------------+
+        // | Target                                                   |
+        // +----------------------------------------------------------+  
+
+            // +------------------------------------------------------+
+            // | Injector                                             |
+            // +------------------------------------------------------+  
+
+                inj_targets_cfg_destroy(cfgs->inj_targets_sst_config);
+                
+            // +------------------------------------------------------+
+            // | Message                                              |
+            // +------------------------------------------------------+  
+
+                msg_targets_cfg_destroy(cfgs->msg_targets_sst_config);
+                     
         // +----------------------------------------------------------+
         // | SST                                                      |
         // +----------------------------------------------------------+  
index fa62675f1e0a619af7adbd0b6f94cf41b171ca27..7d136805e8165ce378fdd00807cbe09544c84699 100644 (file)
@@ -27,6 +27,9 @@
         msg_pots_cfg * msg_pots_ssl_config;
         snk_pots_cfg * snk_pots_ssl_config;
 
+        inj_targets_cfg * inj_targets_sst_config;
+        msg_targets_cfg * msg_targets_sst_config;
+
         mod_sst_cfg * mod_sst_config;
         msg_tracks_cfg * msg_tracks_sst_config;
         snk_tracks_cfg * snk_tracks_sst_config;
index 715a533d2be4b99afb6fb1498445b1b28bb480ae..549810f1eab701eeab31310a0af92859fd3e5f99 100644 (file)
@@ -62,7 +62,7 @@
                 // | Connector                                        |
                 // +--------------------------------------------------+  
 
-                    objs->con_hops_mics_rs_object = con_hops_construct(1, cfgs->msg_hops_mics_rs_config);                    
+                    objs->con_hops_mics_rs_object = con_hops_construct(2, cfgs->msg_hops_mics_rs_config);                    
 
             // +------------------------------------------------------+
             // | STFT                                                 |
 
                 objs->con_pots_ssl_object = con_pots_construct(2, cfgs->msg_pots_ssl_config);
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+  
+
+                    objs->inj_targets_sst_object = inj_targets_construct(cfgs->inj_targets_sst_config, 
+                                                                         cfgs->msg_hops_mics_rs_config, 
+                                                                         cfgs->msg_targets_sst_config);
+
+                // +--------------------------------------------------+
+                // | Connector                                        |
+                // +--------------------------------------------------+              
+
+                    objs->con_targets_sst_object = con_targets_construct(1, cfgs->msg_targets_sst_config);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
                     objs->mod_sst_object = mod_sst_construct(cfgs->mod_sst_config, 
                                                              cfgs->mod_ssl_config, 
                                                              cfgs->msg_pots_ssl_config, 
+                                                             cfgs->msg_targets_sst_config,
                                                              cfgs->msg_tracks_sst_config);
 
                 // +--------------------------------------------------+
                     snk_pots_connect(objs->snk_pots_ssl_object,
                                      objs->con_pots_ssl_object->outs[1]);
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+
+
+                    inj_targets_connect(objs->inj_targets_sst_object,
+                                        objs->con_hops_mics_rs_object->outs[1],
+                                        objs->con_targets_sst_object->in);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
 
                     mod_sst_connect(objs->mod_sst_object, 
                                     objs->con_pots_ssl_object->outs[0], 
+                                    objs->con_targets_sst_object->outs[0],
                                     objs->con_tracks_sst_object->in);
 
                 // +--------------------------------------------------+
 
                     con_pots_destroy(objs->con_pots_ssl_object);
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+ 
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+  
+
+                    inj_targets_destroy(objs->inj_targets_sst_object);
+
+                // +--------------------------------------------------+
+                // | Connector                                        |
+                // +--------------------------------------------------+  
+
+                    con_targets_destroy(objs->con_targets_sst_object);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
                 // | Connector                                        |
                 // +--------------------------------------------------+
 
-                    objs->acon_hops_mics_rs_object = acon_hops_construct(1, objs->nMessages, cfgs->msg_hops_mics_rs_config);
+                    objs->acon_hops_mics_rs_object = acon_hops_construct(2, objs->nMessages, cfgs->msg_hops_mics_rs_config);
 
             // +------------------------------------------------------+
             // | STFT                                                 |
 
                     objs->acon_pots_ssl_object = acon_pots_construct(2, objs->nMessages, cfgs->msg_pots_ssl_config);
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+ 
+
+                    objs->ainj_targets_sst_object = ainj_targets_construct(cfgs->inj_targets_sst_config, 
+                                                                           cfgs->msg_hops_mics_rs_config, 
+                                                                           cfgs->msg_targets_sst_config);
+
+                // +--------------------------------------------------+
+                // | Connector                                        |
+                // +--------------------------------------------------+              
+
+                    objs->acon_targets_sst_object = acon_targets_construct(1, objs->nMessages, cfgs->msg_targets_sst_config);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
                     objs->amod_sst_object = amod_sst_construct(cfgs->mod_sst_config, 
                                                                cfgs->mod_ssl_config, 
                                                                cfgs->msg_pots_ssl_config, 
+                                                               cfgs->msg_targets_sst_config,
                                                                cfgs->msg_tracks_sst_config);
 
                 // +--------------------------------------------------+
                     asnk_pots_connect(objs->asnk_pots_ssl_object,
                                       objs->acon_pots_ssl_object->outs[1]);
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+  
+
+                    ainj_targets_connect(objs->ainj_targets_sst_object,
+                                         objs->acon_hops_mics_rs_object->outs[1],
+                                         objs->acon_targets_sst_object->in);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
 
                     amod_sst_connect(objs->amod_sst_object, 
                                      objs->acon_pots_ssl_object->outs[0], 
+                                     objs->acon_targets_sst_object->outs[0],
                                      objs->acon_tracks_sst_object->in);
 
                 // +--------------------------------------------------+
 
                     acon_pots_destroy(objs->acon_pots_ssl_object);   
 
+            // +------------------------------------------------------+
+            // | Target                                               |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+  
+
+                    ainj_targets_destroy(objs->ainj_targets_sst_object);
+
+                // +--------------------------------------------------+
+                // | Connector                                        |
+                // +--------------------------------------------------+  
+
+                    acon_targets_destroy(objs->acon_targets_sst_object);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
index 6424c23b0faad3f957813fa5c8a7319c9b0e0fc3..5c340ad1ac6438085935582fbe9568da8ec9e5b1 100644 (file)
@@ -28,6 +28,9 @@
         snk_pots_obj * snk_pots_ssl_object;
         con_pots_obj * con_pots_ssl_object;
 
+        inj_targets_obj * inj_targets_sst_object;
+        con_targets_obj * con_targets_sst_object;
+
         mod_sst_obj * mod_sst_object;
         snk_tracks_obj * snk_tracks_sst_object;
         con_tracks_obj * con_tracks_sst_object;
@@ -77,6 +80,9 @@
         asnk_pots_obj * asnk_pots_ssl_object;
         acon_pots_obj * acon_pots_ssl_object;
 
+        ainj_targets_obj * ainj_targets_sst_object;
+        acon_targets_obj * acon_targets_sst_object;
+
         amod_sst_obj * amod_sst_object;
         asnk_tracks_obj * asnk_tracks_sst_object;
         acon_tracks_obj * acon_tracks_sst_object;
index 4e2035571d7f224b426f1a634461dc509f4c11dd..e30ef6db4d650c485c4c8c3de67af48c87408ade 100644 (file)
 
     }
 
+    inj_targets_cfg * parameters_inj_targets_sst_config(const char * fileConfig) {
+
+        inj_targets_cfg * cfg;
+        unsigned int iTarget;
+        unsigned int nTargets;
+        float x, y, z;        
+        char * tmpStr1;
+        char * tmpStr2;
+
+        cfg = inj_targets_cfg_construct();
+
+        // +----------------------------------------------------------+
+        // | Number of targets                                        |
+        // +----------------------------------------------------------+        
+
+            nTargets = parameters_count(fileConfig, "sst.target");      
+
+            cfg->nTargets = nTargets;
+
+        // +----------------------------------------------------------+
+        // | Targets                                                  |
+        // +----------------------------------------------------------+        
+
+            cfg->targets = targets_construct_zero(nTargets);
+
+            for (iTarget = 0; iTarget < nTargets; iTarget++) {
+
+                tmpStr1 = (char *) malloc(sizeof(char) * 1024);
+                sprintf(tmpStr1, "sst.target.[%u].tag",iTarget);
+                tmpStr2 = parameters_lookup_string(fileConfig, tmpStr1);
+                free((void *) tmpStr1);
+
+                tmpStr1 = (char *) malloc(sizeof(char) * 1024);
+                sprintf(tmpStr1, "sst.target.[%u].x",iTarget);
+                x = parameters_lookup_float(fileConfig, tmpStr1);
+                free((void *) tmpStr1);
+
+                tmpStr1 = (char *) malloc(sizeof(char) * 1024);
+                sprintf(tmpStr1, "sst.target.[%u].y",iTarget);
+                y = parameters_lookup_float(fileConfig, tmpStr1);
+                free((void *) tmpStr1);
+
+                tmpStr1 = (char *) malloc(sizeof(char) * 1024);
+                sprintf(tmpStr1, "sst.target.[%u].z",iTarget);
+                z = parameters_lookup_float(fileConfig, tmpStr1);
+                free((void *) tmpStr1);                
+
+                strcpy(cfg->targets->tags[iTarget],tmpStr2);
+                cfg->targets->array[iTarget *3 + 0] = x;
+                cfg->targets->array[iTarget *3 + 1] = y;
+                cfg->targets->array[iTarget *3 + 2] = z;
+
+                free((void *) tmpStr2);
+
+            }
+
+        return cfg;
+
+    }
+
+    msg_targets_cfg * parameters_msg_targets_sst_config(const char * fileConfig) {
+
+        msg_targets_cfg * cfg;
+        unsigned int nTargets;
+
+        cfg = msg_targets_cfg_construct();
+
+        // +----------------------------------------------------------+
+        // | Number of targets                                        |
+        // +----------------------------------------------------------+        
+
+            nTargets = parameters_count(fileConfig, "sst.target");      
+
+            cfg->nTargets = nTargets;
+
+        // +----------------------------------------------------------+
+        // | Sample rate                                              |
+        // +----------------------------------------------------------+
+
+            cfg->fS = parameters_lookup_int(fileConfig, "general.samplerate.mu");              
+
+        return cfg;
+
+    }
+
     mod_sst_cfg * parameters_mod_sst_config(const char * fileConfig) {
 
         mod_sst_cfg * cfg;
         float weight;
         float mu;
         float sigma;
-        unsigned int iTrack;
 
+        unsigned int iTrack;
         char * tmpStr1;
 
         cfg = mod_sst_cfg_construct();
 
             free((void *) tmpStr1);
 
+        // +----------------------------------------------------------+
+        // | Add                                                      |
+        // +----------------------------------------------------------+
+
+            tmpStr1 = parameters_lookup_string(fileConfig, "sst.add");
+
+            if (strcmp(tmpStr1, "dynamic") == 0) {
+                cfg->add = 'd';
+            }
+            else if (strcmp(tmpStr1, "static") == 0) {
+                cfg->add = 's';
+            }
+            else {
+                printf("sst.add: Invalid add type.\n");
+                exit(EXIT_FAILURE);
+            }
+
+            free((void *) tmpStr1);
+
         // +----------------------------------------------------------+
         // | nTracksMax                                               |
         // +----------------------------------------------------------+
 
             cfg->sigmaR_active = sqrtf(parameters_lookup_float(fileConfig, "sst.sigmaR2_active"));
             cfg->sigmaR_prob = sqrtf(parameters_lookup_float(fileConfig, "sst.sigmaR2_prob"));
+            cfg->sigmaR_target = sqrtf(parameters_lookup_float(fileConfig, "sst.sigmaR2_target"));
 
         // +----------------------------------------------------------+
         // | GMM Active                                               |
index b05b322e3d0f1b99c6d742a7f02b98b2e3c6df32..bc309aa0bcccfabcf03bd14f0e1b1a227f946e85 100644 (file)
     snk_pots_cfg * parameters_snk_pots_ssl_config(const char * fileConfig);
 
 
+    inj_targets_cfg * parameters_inj_targets_sst_config(const char * fileConfig);
+
+    msg_targets_cfg * parameters_msg_targets_sst_config(const char * fileConfig);
+
+
     mod_sst_cfg * parameters_mod_sst_config(const char * fileConfig);
 
     msg_tracks_cfg * parameters_msg_tracks_sst_config(const char * fileConfig);
index 339eacfb004b64e770f6f4294bb0b294ca397c7b..7f7cf7dc66821dab77ea921895a0c28f23aba298 100644 (file)
@@ -28,6 +28,9 @@
         prf->con_pots_ssl_prf = 0.0f;
         prf->snk_pots_ssl_prf = 0.0f;
 
+        prf->inj_targets_sst_prf = 0.0f;
+        prf->con_targets_sst_prf = 0.0f;
+
         prf->mod_sst_prf = 0.0f;
         prf->con_tracks_sst_prf = 0.0f;
         prf->snk_tracks_sst_prf = 0.0f;
@@ -64,7 +67,7 @@
 
     void profiler_printf(const profiler * prf) {
 
-        float source, sink, module, connector;
+        float source, sink, module, injector, connector;
         float total;
 
         source = prf->src_hops_mics_prf;
                  prf->mod_resample_pfs_prf +
                  prf->mod_classify_prf;
 
+        injector = prf->inj_targets_sst_prf;
+
         connector = prf->con_hops_mics_raw_prf +
                     prf->con_hops_mics_map_prf +
                     prf->con_hops_mics_rs_prf +
                     prf->con_spectra_mics_prf +
                     prf->con_powers_mics_prf +
                     prf->con_pots_ssl_prf +
+                    prf->con_targets_sst_prf +
                     prf->con_tracks_sst_prf +
                     prf->con_spectra_seps_prf +
                     prf->con_spectra_pfs_prf +
         printf("|    - Module.......... %07.3f (%06.2f%%)    |\n",prf->mod_ssl_prf,roundf(10000.0f * prf->mod_ssl_prf / prf->duration) / 100.0f);
         printf("|    - Connector....... %07.3f (%06.2f%%)    |\n",prf->con_pots_ssl_prf,roundf(10000.0f * prf->con_pots_ssl_prf / prf->duration) / 100.0f);
         printf("|    - Sink............ %07.3f (%06.2f%%)    |\n",prf->snk_pots_ssl_prf,roundf(10000.0f * prf->snk_pots_ssl_prf / prf->duration) / 100.0f);  
+        printf("| + Target                                   |\n");
+        printf("|    - Injector........ %07.3f (%06.2f%%)    |\n",prf->inj_targets_sst_prf,roundf(10000.0f * prf->inj_targets_sst_prf / prf->duration) / 100.0f);
+        printf("|    - Connector....... %07.3f (%06.2f%%)    |\n",prf->con_targets_sst_prf,roundf(10000.0f * prf->con_targets_sst_prf / prf->duration) / 100.0f);
         printf("| + SST                                      |\n");
         printf("|    - Module.......... %07.3f (%06.2f%%)    |\n",prf->mod_sst_prf,roundf(10000.0f * prf->mod_sst_prf / prf->duration) / 100.0f);
         printf("|    - Connector....... %07.3f (%06.2f%%)    |\n",prf->con_tracks_sst_prf,roundf(10000.0f * prf->con_tracks_sst_prf / prf->duration) / 100.0f);
index c6cb8a3095db6e2975a2d1e7238b7b8d5d124167..b44ea4252b585c121170040140ba9a1194183737 100644 (file)
@@ -28,6 +28,9 @@
         float con_pots_ssl_prf;
         float snk_pots_ssl_prf;
 
+        float inj_targets_sst_prf;
+        float con_targets_sst_prf;
+
         float mod_sst_prf;
         float con_tracks_sst_prf;
         float snk_tracks_sst_prf;
index 3fac8a59387954a0dbce9b409ee48d4f3d2db9fd..cf7c583c51b70c1d5df1237c0e56292282c8ce34 100644 (file)
 
                 thread_start(aobjs->acon_pots_ssl_object->thread);
 
+        // +----------------------------------------------------------+
+        // | Targets                                                  |
+        // +----------------------------------------------------------+  
+
+            // +------------------------------------------------------+
+            // | Injector                                             |
+            // +------------------------------------------------------+                  
+
+                thread_start(aobjs->ainj_targets_sst_object->thread);
+
+            // +------------------------------------------------------+
+            // | Connector                                            |
+            // +------------------------------------------------------+                  
+
+                thread_start(aobjs->acon_targets_sst_object->thread);
+
         // +----------------------------------------------------------+
         // | SST                                                      |
         // +----------------------------------------------------------+  
 
                 thread_join(aobjs->acon_pots_ssl_object->thread);
 
+        // +----------------------------------------------------------+
+        // | Targets                                                  |
+        // +----------------------------------------------------------+  
+
+            // +------------------------------------------------------+
+            // | Injector                                             |
+            // +------------------------------------------------------+                  
+
+                thread_join(aobjs->ainj_targets_sst_object->thread);
+
+            // +------------------------------------------------------+
+            // | Connector                                            |
+            // +------------------------------------------------------+                  
+
+                thread_join(aobjs->acon_targets_sst_object->thread);
+
         // +----------------------------------------------------------+
         // | SST                                                      |
         // +----------------------------------------------------------+  
                     end = clock();
                     prf->snk_pots_ssl_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);                                                
 
+            // +------------------------------------------------------+
+            // | Targets                                              |
+            // +------------------------------------------------------+  
+
+                // +--------------------------------------------------+
+                // | Injector                                         |
+                // +--------------------------------------------------+  
+
+                    begin = clock();
+                    inj_targets_process(objs->inj_targets_sst_object);
+                    end = clock();
+                    prf->inj_targets_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
+                // +--------------------------------------------------+
+                // | Connector                                        |
+                // +--------------------------------------------------+                      
+
+                    begin = clock();
+                    con_targets_process(objs->con_targets_sst_object);
+                    end = clock();
+                    prf->con_targets_sst_prf += (float) (((double) (end-begin)) / CLOCKS_PER_SEC);
+
             // +------------------------------------------------------+
             // | SST                                                  |
             // +------------------------------------------------------+  
index 0d1925002abeb1a47938e64dee3f95f853d897b7..14cf8540638c3eb8c5e99506734efe296c29a723 100644 (file)
@@ -4,12 +4,15 @@
     #include "../../src/connector/con_pots.h"
     #include "../../src/connector/con_powers.h"
     #include "../../src/connector/con_spectra.h"
+    #include "../../src/connector/con_targets.h"
     #include "../../src/connector/con_tracks.h"
+    #include "../../src/injector/inj_targets.h"
     #include "../../src/message/msg_categories.h"
     #include "../../src/message/msg_hops.h"
     #include "../../src/message/msg_pots.h"
     #include "../../src/message/msg_powers.h"
     #include "../../src/message/msg_spectra.h"
+    #include "../../src/message/msg_targets.h"
     #include "../../src/message/msg_tracks.h"
     #include "../../src/module/mod_classify.h"
     #include "../../src/module/mod_istft.h"
     #include "../../src/aconnector/acon_pots.h"
     #include "../../src/aconnector/acon_powers.h"
     #include "../../src/aconnector/acon_spectra.h"
+    #include "../../src/aconnector/acon_targets.h"
     #include "../../src/aconnector/acon_tracks.h"
+    #include "../../src/ainjector/ainj_targets.h"
     #include "../../src/amessage/amsg_categories.h"
     #include "../../src/amessage/amsg_hops.h"
     #include "../../src/amessage/amsg_pots.h"
     #include "../../src/amessage/amsg_powers.h"
     #include "../../src/amessage/amsg_spectra.h"
+    #include "../../src/amessage/amsg_targets.h"
     #include "../../src/amessage/amsg_tracks.h"
     #include "../../src/amodule/amod_classify.h"
     #include "../../src/amodule/amod_istft.h"
diff --git a/src/aconnector/acon_targets.c b/src/aconnector/acon_targets.c
new file mode 100644 (file)
index 0000000..af9dfbd
--- /dev/null
@@ -0,0 +1,84 @@
+    
+    #include "acon_targets.h"
+
+    acon_targets_obj * acon_targets_construct(const unsigned int nOuts, const unsigned int nMessages, const msg_targets_cfg * msg_targets_config) {
+
+        acon_targets_obj * obj;
+        unsigned int iOut;
+
+        obj = (acon_targets_obj *) malloc(sizeof(acon_targets_obj));
+
+        obj->in = amsg_targets_construct(nMessages, msg_targets_config);
+
+        obj->outs = (amsg_targets_obj **) malloc(sizeof(amsg_targets_obj *) * nOuts);
+        for (iOut = 0; iOut < nOuts; iOut++) {
+            obj->outs[iOut] = amsg_targets_construct(nMessages, msg_targets_config);
+        }
+
+        obj->con_targets = con_targets_construct(nOuts, msg_targets_config);
+
+        obj->thread = thread_construct(&acon_targets_thread, (void *) obj);
+
+        return obj;
+
+    }
+
+    void acon_targets_destroy(acon_targets_obj * obj) {
+
+        unsigned int iOut;
+        unsigned int nOuts;
+
+        nOuts = obj->con_targets->nOuts;
+
+        thread_destroy(obj->thread);
+
+        con_targets_destroy(obj->con_targets);
+
+        for (iOut = 0; iOut < nOuts; iOut++) {
+            amsg_targets_destroy(obj->outs[iOut]);
+        }
+        free((void *) obj->outs);
+
+        amsg_targets_destroy(obj->in);
+
+        free((void *) obj);
+
+    }
+
+    void * acon_targets_thread(void * ptr) {
+
+        msg_targets_obj * msg_targets_in;
+        msg_targets_obj * msg_targets_out;
+
+        acon_targets_obj * obj;
+        unsigned int iOut;
+        unsigned int nOuts;
+        int rtnValue;
+
+        obj = (acon_targets_obj *) ptr;
+
+        nOuts = obj->con_targets->nOuts;
+
+        while(1) {
+
+            msg_targets_in = amsg_targets_filled_pop(obj->in);
+            msg_targets_copy(obj->con_targets->in, msg_targets_in);
+            amsg_targets_empty_push(obj->in, msg_targets_in);
+
+            rtnValue = con_targets_process(obj->con_targets);
+
+            for (iOut = 0; iOut < nOuts; iOut++) {
+                
+                msg_targets_out = amsg_targets_empty_pop(obj->outs[iOut]);
+                msg_targets_copy(msg_targets_out, obj->con_targets->outs[iOut]);
+                amsg_targets_filled_push(obj->outs[iOut], msg_targets_out);
+
+            }
+
+            if (rtnValue == -1) {
+                break;
+            }
+
+        }
+
+    }
\ No newline at end of file
diff --git a/src/aconnector/acon_targets.h b/src/aconnector/acon_targets.h
new file mode 100644 (file)
index 0000000..633809e
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __ODAS_ACONNECTOR_TARGETS
+#define __ODAS_ACONNECTOR_TARGETS
+
+    #include "../connector/con_targets.h"
+    #include "../amessage/amsg_targets.h"
+    #include "../message/msg_targets.h"
+    #include "../general/thread.h"
+
+    #include <stdlib.h>
+    #include <stdio.h>
+
+    typedef struct acon_targets_obj {
+
+        amsg_targets_obj * in;
+        amsg_targets_obj ** outs;
+        con_targets_obj * con_targets;
+        thread_obj * thread;
+
+    } acon_targets_obj;
+
+    acon_targets_obj * acon_targets_construct(const unsigned int nOuts, const unsigned int nMessages, const msg_targets_cfg * msg_targets_config);
+
+    void acon_targets_destroy(acon_targets_obj * obj);
+
+    void * acon_targets_thread(void * ptr);
+
+#endif
\ No newline at end of file
index a29eb53b4264824d3768ccd254443058184e8e19..006f66d542f9a89e465b478eddc7b6d8ebb0d7f6 100644 (file)
@@ -43,7 +43,6 @@
 
         free((void *) obj);
 
-
     }
 
     void * acon_tracks_thread(void * ptr) {
diff --git a/src/ainjector/ainj_targets.c b/src/ainjector/ainj_targets.c
new file mode 100644 (file)
index 0000000..b4e8e18
--- /dev/null
@@ -0,0 +1,72 @@
+    
+    #include "ainj_targets.h"
+
+    ainj_targets_obj * ainj_targets_construct(const inj_targets_cfg * inj_targets_config, const msg_hops_cfg * msg_hops_config, const msg_targets_cfg * msg_targets_config) {
+
+        ainj_targets_obj * obj;
+
+        obj = (ainj_targets_obj *) malloc(sizeof(ainj_targets_obj));
+
+        obj->inj_targets = inj_targets_construct(inj_targets_config, msg_hops_config, msg_targets_config);
+
+        obj->in = (amsg_hops_obj *) NULL;
+        obj->out = (amsg_targets_obj *) NULL;
+
+        obj->thread = thread_construct(&ainj_targets_thread, (void *) obj);
+
+        return obj;
+
+    }
+
+    void ainj_targets_destroy(ainj_targets_obj * obj) {
+
+        inj_targets_destroy(obj->inj_targets);
+        thread_destroy(obj->thread);
+
+        free((void *) obj);   
+
+    }
+
+    void ainj_targets_connect(ainj_targets_obj * obj, amsg_hops_obj * in, amsg_targets_obj * out) {
+
+        obj->in = in;
+        obj->out = out;
+
+    }
+
+    void ainj_targets_disconnect(ainj_targets_obj * obj) {
+
+        obj->in = (amsg_hops_obj *) NULL;
+        obj->out = (amsg_targets_obj *) NULL;
+
+    }
+
+    void * ainj_targets_thread(void * ptr) {
+
+        ainj_targets_obj * obj;
+        msg_hops_obj * msg_hops_in;
+        msg_targets_obj * msg_targets_out;
+        int rtnValue;
+
+        obj = (ainj_targets_obj *) ptr;
+
+        while(1) {
+
+            // Pop a message, process, and push back
+            msg_hops_in = amsg_hops_filled_pop(obj->in);
+            msg_targets_out = amsg_targets_empty_pop(obj->out);
+            inj_targets_connect(obj->inj_targets, msg_hops_in, msg_targets_out);
+            rtnValue = inj_targets_process(obj->inj_targets);
+            inj_targets_disconnect(obj->inj_targets);
+            amsg_hops_empty_push(obj->in, msg_hops_in);
+            amsg_targets_filled_push(obj->out, msg_targets_out);
+
+            // If this is the last frame, rtnValue = -1
+            if (rtnValue == -1) {
+                break;
+            }
+
+        }
+
+
+    }
\ No newline at end of file
diff --git a/src/ainjector/ainj_targets.h b/src/ainjector/ainj_targets.h
new file mode 100644 (file)
index 0000000..60af2da
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __ODAS_AINJECTOR_TARGETS
+#define __ODAS_AINJECTOR_TARGETS
+
+    #include "../injector/inj_targets.h"
+    #include "../amessage/amsg_hops.h"
+    #include "../amessage/amsg_targets.h"
+    #include "../general/thread.h"
+
+    typedef struct ainj_targets_obj {
+
+        inj_targets_obj * inj_targets;
+        amsg_hops_obj * in;
+        amsg_targets_obj * out;
+        thread_obj * thread;    
+
+    } ainj_targets_obj;
+
+    ainj_targets_obj * ainj_targets_construct(const inj_targets_cfg * inj_targets_config, const msg_hops_cfg * msg_hops_config, const msg_targets_cfg * msg_targets_config);
+
+    void ainj_targets_destroy(ainj_targets_obj * obj);
+
+    void ainj_targets_connect(ainj_targets_obj * obj, amsg_hops_obj * in, amsg_targets_obj * out);
+
+    void ainj_targets_disconnect(ainj_targets_obj * obj);
+
+    void * ainj_targets_thread(void * ptr); 
+
+#endif
\ No newline at end of file
diff --git a/src/amessage/amsg_targets.c b/src/amessage/amsg_targets.c
new file mode 100644 (file)
index 0000000..b8fadeb
--- /dev/null
@@ -0,0 +1,64 @@
+    
+    #include "amsg_targets.h"
+
+    amsg_targets_obj * amsg_targets_construct(const unsigned int nMessages, const msg_targets_cfg * msg_targets_config) {
+
+        amsg_targets_obj * obj;
+        unsigned int iMessage;
+
+        obj = (amsg_targets_obj *) malloc(sizeof(amsg_targets_obj));
+
+        obj->nMessages = nMessages;
+        obj->filled = fifo_construct_zero(nMessages);
+        obj->empty = fifo_construct_zero(nMessages);
+
+        for (iMessage = 0; iMessage < nMessages; iMessage++) {
+
+            fifo_push(obj->empty, (void *) msg_targets_construct(msg_targets_config));
+
+        }
+
+        return obj;   
+
+    }
+
+    void amsg_targets_destroy(amsg_targets_obj * obj) {
+
+        while(fifo_nElements(obj->filled) > 0) {
+            msg_targets_destroy((void *) fifo_pop(obj->filled));
+        }
+
+        while(fifo_nElements(obj->empty) > 0) {
+            msg_targets_destroy((void *) fifo_pop(obj->empty));
+        }
+
+        fifo_destroy(obj->filled);
+        fifo_destroy(obj->empty);
+
+        free((void *) obj);
+
+    }
+
+    msg_targets_obj * amsg_targets_filled_pop(amsg_targets_obj * obj) {
+
+        return ((msg_targets_obj *) fifo_pop(obj->filled));
+
+    }
+
+    void amsg_targets_filled_push(amsg_targets_obj * obj, msg_targets_obj * msg_targets) {
+
+        fifo_push(obj->filled, (void *) msg_targets);
+
+    }
+
+    msg_targets_obj * amsg_targets_empty_pop(amsg_targets_obj * obj) {
+
+        return ((msg_targets_obj *) fifo_pop(obj->empty));
+
+    }
+
+    void amsg_targets_empty_push(amsg_targets_obj * obj, msg_targets_obj * msg_targets) {
+
+        fifo_push(obj->empty, (void *) msg_targets);
+
+    }
\ No newline at end of file
diff --git a/src/amessage/amsg_targets.h b/src/amessage/amsg_targets.h
new file mode 100644 (file)
index 0000000..da8f72e
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __ODAS_AMESSAGE_TARGETS
+#define __ODAS_AMESSAGE_TARGETS
+
+    #include <stdlib.h>
+
+    #include "../message/msg_targets.h"
+    #include "../utils/fifo.h"
+
+    typedef struct amsg_targets_obj {
+
+        unsigned int nMessages;
+        fifo_obj * filled;
+        fifo_obj * empty;
+
+    } amsg_targets_obj;
+
+    amsg_targets_obj * amsg_targets_construct(const unsigned int nMessages, const msg_targets_cfg * msg_targets_config);
+
+    void amsg_targets_destroy(amsg_targets_obj * obj);
+
+    msg_targets_obj * amsg_targets_filled_pop(amsg_targets_obj * obj);
+
+    void amsg_targets_filled_push(amsg_targets_obj * obj, msg_targets_obj * msg_targets);
+
+    msg_targets_obj * amsg_targets_empty_pop(amsg_targets_obj * obj);
+
+    void amsg_targets_empty_push(amsg_targets_obj * obj, msg_targets_obj * msg_targets);
+
+#endif
\ No newline at end of file
index a04e82261200ae6a713b543820f1699b228d9c24..29680b1eeb89bb5fe3a91bbc2bf9c67c8714684f 100644 (file)
@@ -1,15 +1,16 @@
     
     #include "amod_sst.h"
 
-    amod_sst_obj * amod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_tracks_cfg * msg_tracks_config) {
+    amod_sst_obj * amod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_targets_cfg * msg_targets_config, const msg_tracks_cfg * msg_tracks_config) {
 
         amod_sst_obj * obj;
 
         obj = (amod_sst_obj *) malloc(sizeof(amod_sst_obj));
 
-        obj->mod_sst = mod_sst_construct(mod_sst_config, mod_ssl_config, msg_pots_config, msg_tracks_config);
+        obj->mod_sst = mod_sst_construct(mod_sst_config, mod_ssl_config, msg_pots_config, msg_targets_config, msg_tracks_config);
         
-        obj->in = (amsg_pots_obj *) NULL;
+        obj->in1 = (amsg_pots_obj *) NULL;
+        obj->in2 = (amsg_targets_obj *) NULL;
         obj->out = (amsg_tracks_obj *) NULL;
 
         obj->thread = thread_construct(&amod_sst_thread, (void *) obj);
 
     }
 
-    void amod_sst_connect(amod_sst_obj * obj, amsg_pots_obj * in, amsg_tracks_obj * out) {
+    void amod_sst_connect(amod_sst_obj * obj, amsg_pots_obj * in1, amsg_targets_obj * in2, amsg_tracks_obj * out) {
 
-        obj->in = in;
+        obj->in1 = in1;
+        obj->in2 = in2;
         obj->out = out;
 
     }
 
     void amod_sst_disconnect(amod_sst_obj * obj) {
 
-        obj->in = (amsg_pots_obj *) NULL;
+        obj->in1 = (amsg_pots_obj *) NULL;
+        obj->in2 = (amsg_targets_obj *) NULL;
         obj->out = (amsg_tracks_obj *) NULL;
 
     }
@@ -45,6 +48,7 @@
 
         amod_sst_obj * obj;
         msg_pots_obj * msg_pots_in;
+        msg_targets_obj * msg_targets_in;
         msg_tracks_obj * msg_tracks_out;
         int rtnValue;
 
         while(1) {
 
             // Pop a message, process, and push back
-            msg_pots_in = amsg_pots_filled_pop(obj->in);
+            msg_pots_in = amsg_pots_filled_pop(obj->in1);
+            msg_targets_in = amsg_targets_filled_pop(obj->in2);
             msg_tracks_out = amsg_tracks_empty_pop(obj->out);
-            mod_sst_connect(obj->mod_sst, msg_pots_in, msg_tracks_out);
+            mod_sst_connect(obj->mod_sst, msg_pots_in, msg_targets_in, msg_tracks_out);
             rtnValue = mod_sst_process(obj->mod_sst);
             mod_sst_disconnect(obj->mod_sst);
-            amsg_pots_empty_push(obj->in, msg_pots_in);
+            amsg_pots_empty_push(obj->in1, msg_pots_in);
+            amsg_targets_empty_push(obj->in2, msg_targets_in);
             amsg_tracks_filled_push(obj->out, msg_tracks_out);
 
             // If this is the last frame, rtnValue = -1
index f0dcda8d042110967247e486d97d4b2a55fa8188..e6381648e0520816506e7e1a4c055bf073d3749c 100644 (file)
@@ -4,23 +4,25 @@
     #include "../module/mod_ssl.h"
     #include "../module/mod_sst.h"
     #include "../amessage/amsg_pots.h"
+    #include "../amessage/amsg_targets.h"
     #include "../amessage/amsg_tracks.h"
     #include "../general/thread.h"
 
     typedef struct amod_sst_obj {
 
         mod_sst_obj * mod_sst;
-        amsg_pots_obj * in;
+        amsg_pots_obj * in1;
+        amsg_targets_obj * in2;
         amsg_tracks_obj * out;
         thread_obj * thread;    
 
     } amod_sst_obj;
 
-    amod_sst_obj * amod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_tracks_cfg * msg_tracks_config);
+    amod_sst_obj * amod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_targets_cfg * msg_targets_config, const msg_tracks_cfg * msg_tracks_config);
 
     void amod_sst_destroy(amod_sst_obj * obj);
 
-    void amod_sst_connect(amod_sst_obj * obj, amsg_pots_obj * in, amsg_tracks_obj * out);
+    void amod_sst_connect(amod_sst_obj * obj, amsg_pots_obj * in1, amsg_targets_obj * in2, amsg_tracks_obj * out);
 
     void amod_sst_disconnect(amod_sst_obj * obj);
 
diff --git a/src/connector/con_targets.c b/src/connector/con_targets.c
new file mode 100644 (file)
index 0000000..96dd85d
--- /dev/null
@@ -0,0 +1,57 @@
+
+    #include "con_targets.h"
+
+    con_targets_obj * con_targets_construct(const unsigned int nOuts, const msg_targets_cfg * msg_targets_config) {
+
+        con_targets_obj * obj;
+        unsigned int iOut;
+
+        obj = (con_targets_obj *) malloc(sizeof(con_targets_obj));
+
+        obj->nOuts = nOuts;
+
+        obj->in = msg_targets_construct(msg_targets_config);
+
+        obj->outs = (msg_targets_obj **) malloc(sizeof(msg_targets_obj *) * nOuts);
+        for (iOut = 0; iOut < obj->nOuts; iOut++) {
+            obj->outs[iOut] = msg_targets_construct(msg_targets_config);
+        }
+
+        return obj;    
+
+    }
+
+    void con_targets_destroy(con_targets_obj * obj) {
+
+        unsigned int iOut;
+
+        for (iOut = 0; iOut < obj->nOuts; iOut++) {
+            msg_targets_destroy(obj->outs[iOut]);
+        }
+        free((void *) obj->outs);
+
+        msg_targets_destroy(obj->in);
+
+        free((void *) obj);
+
+    }
+
+    int con_targets_process(con_targets_obj * obj) {
+
+        unsigned int iOut;
+        int rtnValue;
+
+        for (iOut = 0; iOut < obj->nOuts; iOut++) {
+            msg_targets_copy(obj->outs[iOut], obj->in);
+        }
+
+        if (msg_targets_isZero(obj->in) == 1) {
+            rtnValue = -1;
+        }
+        else {
+            rtnValue = 0;
+        }
+
+        return rtnValue;
+
+    }
\ No newline at end of file
diff --git a/src/connector/con_targets.h b/src/connector/con_targets.h
new file mode 100644 (file)
index 0000000..4d8828f
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __ODAS_CONNECTOR_TARGETS
+#define __ODAS_CONNECTOR_TARGETS
+
+    #include "../message/msg_targets.h"
+
+    #include <stdlib.h>
+    #include <stdio.h>
+
+    typedef struct con_targets_obj {
+
+        msg_targets_obj * in;
+        msg_targets_obj ** outs;
+
+        unsigned int nOuts;
+
+    } con_targets_obj;
+
+    con_targets_obj * con_targets_construct(const unsigned int nOuts, const msg_targets_cfg * msg_targets_config);
+
+    void con_targets_destroy(con_targets_obj * obj);
+
+    int con_targets_process(con_targets_obj * obj);
+
+#endif
\ No newline at end of file
diff --git a/src/injector/inj_targets.c b/src/injector/inj_targets.c
new file mode 100644 (file)
index 0000000..ff0c878
--- /dev/null
@@ -0,0 +1,110 @@
+    
+    #include "inj_targets.h"
+
+    inj_targets_obj * inj_targets_construct(const inj_targets_cfg * inj_targets_config, const msg_hops_cfg * msg_hops_config, const msg_targets_cfg * msg_targets_config) {
+
+        inj_targets_obj * obj;
+
+        obj = (inj_targets_obj *) malloc(sizeof(inj_targets_obj));
+
+        obj->nTargets = msg_targets_config->nTargets;
+        obj->fS = msg_hops_config->fS;
+
+        obj->timeStamp = 0;
+
+        obj->in = (msg_hops_obj *) NULL;
+        obj->out = (msg_targets_obj *) NULL;
+
+        obj->targets = targets_clone(inj_targets_config->targets);
+
+        return obj;
+
+    }
+
+    void inj_targets_destroy(inj_targets_obj * obj) {
+
+        targets_destroy(obj->targets);
+        free((void *) obj);
+
+    }
+
+    void inj_targets_connect(inj_targets_obj * obj, msg_hops_obj * in, msg_targets_obj * out) {
+
+        obj->in = in;
+        obj->out = out;
+
+    }
+
+    void inj_targets_disconnect(inj_targets_obj * obj) {
+
+        obj->in = (msg_hops_obj *) NULL;
+        obj->out = (msg_targets_obj *) NULL;
+
+    }
+    
+    int inj_targets_process(inj_targets_obj * obj) {
+
+        int rtnValue;
+
+        if (msg_hops_isZero(obj->in) == 0) {
+
+            targets_copy(obj->out->targets, obj->targets);
+            obj->out->fS = obj->in->fS;
+            obj->out->timeStamp = obj->in->timeStamp;
+
+            rtnValue = 0;
+
+        }
+        else {
+
+            msg_targets_zero(obj->out);
+
+            rtnValue = -1;
+
+        }
+
+        return rtnValue;        
+
+    }
+
+    inj_targets_cfg * inj_targets_cfg_construct(void) {
+
+        inj_targets_cfg * cfg;
+
+        cfg = (inj_targets_cfg *) malloc(sizeof(inj_targets_cfg));
+
+        cfg->nTargets = 0;
+        cfg->targets = NULL;
+
+        return cfg;
+
+    }
+
+    void inj_targets_cfg_destroy(inj_targets_cfg * cfg) {
+
+        if (cfg->targets != NULL) {
+            targets_destroy(cfg->targets);
+        }
+
+        free((void *) cfg);
+
+    }
+
+    void inj_targets_cfg_printf(const inj_targets_cfg * cfg) {
+
+        printf("nTargets = %u\n", cfg->nTargets);        
+        
+        if (cfg->targets != NULL) {
+            
+            targets_printf(cfg->targets);
+
+        }
+        else {
+
+            printf("targets: NULL\n");
+
+        }
+
+        
+
+    }
\ No newline at end of file
diff --git a/src/injector/inj_targets.h b/src/injector/inj_targets.h
new file mode 100644 (file)
index 0000000..bfcbfba
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __ODAS_INJECTOR_TARGETS
+#define __ODAS_INJECTOR_TARGETS
+
+    #include "../message/msg_hops.h"
+    #include "../message/msg_targets.h"
+
+    #include "../general/format.h"
+    #include "../general/interface.h"
+
+    #include <stdlib.h>
+    #include <string.h>
+    #include <stdio.h>
+
+    typedef struct inj_targets_obj {
+
+        unsigned long long timeStamp;
+
+        unsigned int nTargets;
+        unsigned int fS;
+
+        msg_hops_obj * in;
+        msg_targets_obj * out;
+
+        targets_obj * targets;
+
+    } inj_targets_obj;
+
+    typedef struct inj_targets_cfg {
+
+        unsigned int nTargets;
+        targets_obj * targets;
+
+    } inj_targets_cfg;
+
+    inj_targets_obj * inj_targets_construct(const inj_targets_cfg * inj_targets_config, const msg_hops_cfg * msg_hops_config, const msg_targets_cfg * msg_targets_config);
+
+    void inj_targets_destroy(inj_targets_obj * obj);
+
+    void inj_targets_connect(inj_targets_obj * obj, msg_hops_obj * in, msg_targets_obj * out);
+
+    void inj_targets_disconnect(inj_targets_obj * obj);
+    
+    int inj_targets_process(inj_targets_obj * obj);
+
+    inj_targets_cfg * inj_targets_cfg_construct(void);
+
+    void inj_targets_cfg_destroy(inj_targets_cfg * cfg);
+
+    void inj_targets_cfg_printf(const inj_targets_cfg * cfg);
+
+#endif
\ No newline at end of file
diff --git a/src/message/msg_targets.c b/src/message/msg_targets.c
new file mode 100644 (file)
index 0000000..10ba405
--- /dev/null
@@ -0,0 +1,80 @@
+
+    #include "msg_targets.h"
+
+    msg_targets_obj * msg_targets_construct(const msg_targets_cfg * cfg) {
+
+        msg_targets_obj * obj;
+
+        obj = (msg_targets_obj *) malloc(sizeof(msg_targets_obj));
+
+        obj->timeStamp = 0;
+        obj->fS = cfg->fS;
+        obj->targets = targets_construct_zero(cfg->nTargets);
+
+        return obj;
+
+    }
+
+    void msg_targets_destroy(msg_targets_obj * obj) {
+
+        targets_destroy(obj->targets);
+        free((void *) obj);
+
+    }
+
+    void msg_targets_copy(msg_targets_obj * dest, const msg_targets_obj * src) {
+
+        dest->timeStamp = src->timeStamp;
+        dest->fS = src->fS;
+        targets_copy(dest->targets, src->targets);
+
+    }
+
+    void msg_targets_zero(msg_targets_obj * obj) {
+
+        obj->timeStamp = 0;
+        obj->fS = 0;
+        targets_zero(obj->targets);
+
+    }
+
+    unsigned int msg_targets_isZero(const msg_targets_obj * obj) {
+
+        unsigned int rtnValue;
+
+        if (obj->timeStamp == 0) {
+            rtnValue = 1;
+        }
+        else {
+            rtnValue = 0;
+        }
+
+        return rtnValue;
+
+    }
+
+    msg_targets_cfg * msg_targets_cfg_construct(void) {
+
+        msg_targets_cfg * cfg;
+
+        cfg = (msg_targets_cfg *) malloc(sizeof(msg_targets_cfg));
+
+        cfg->nTargets = 0;
+        cfg->fS = 0;
+
+        return cfg;
+
+    }
+
+    void msg_targets_cfg_destroy(msg_targets_cfg * cfg) {
+
+        free((void *) cfg);
+
+    }
+
+    void msg_targets_cfg_printf(const msg_targets_cfg * msg_targets_config) {
+
+        printf("nTargets = %u\n", msg_targets_config->nTargets);
+        printf("fS = %u\n", msg_targets_config->fS);        
+
+    }    
\ No newline at end of file
diff --git a/src/message/msg_targets.h b/src/message/msg_targets.h
new file mode 100644 (file)
index 0000000..c0feeee
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __ODAS_MESSAGE_TARGETS
+#define __ODAS_MESSAGE_TARGETS
+
+    #include <stdlib.h>
+    #include "../signal/target.h"
+
+    typedef struct msg_targets_obj {
+
+        unsigned long long timeStamp;
+        unsigned int fS;
+        targets_obj * targets;
+
+    } msg_targets_obj;
+
+    typedef struct msg_targets_cfg {
+
+        unsigned int nTargets;
+        unsigned int fS;
+
+    } msg_targets_cfg;
+
+    msg_targets_obj * msg_targets_construct(const msg_targets_cfg * cfg);
+
+    void msg_targets_destroy(msg_targets_obj * obj);
+
+    void msg_targets_copy(msg_targets_obj * dest, const msg_targets_obj * src);
+
+    void msg_targets_zero(msg_targets_obj * obj);
+
+    unsigned int msg_targets_isZero(const msg_targets_obj * obj);
+
+    msg_targets_cfg * msg_targets_cfg_construct(void);
+
+    void msg_targets_cfg_destroy(msg_targets_cfg * cfg);
+
+    void msg_targets_cfg_printf(const msg_targets_cfg * msg_targets_config);
+
+#endif
\ No newline at end of file
index f9618ab93bf4f14ca92b3b24e05754f6ff2a2458..c5ef5dc0c9fd4bf8d20d05ca6abe1aa3ce662d93 100644 (file)
 
         int rtnValue;
 
-        if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) ||
-            (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) {
+        if ((obj->in1->timeStamp != obj->in2->timeStamp) ||
+            (obj->in1->timeStamp != obj->in3->timeStamp)) {
 
             printf("Time stamp mismatch.\n");
             exit(EXIT_FAILURE);
 
         int rtnValue;
 
-        if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) ||
-            (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) {
+        if ((obj->in1->timeStamp != obj->in2->timeStamp) ||
+            (obj->in1->timeStamp != obj->in3->timeStamp)) {
 
             printf("Time stamp mismatch.\n");
             exit(EXIT_FAILURE);
 
         int rtnValue;
 
-        if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) ||
-            (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) {
+        if ((obj->in1->timeStamp != obj->in2->timeStamp) ||
+            (obj->in1->timeStamp != obj->in3->timeStamp)) {
 
             printf("Time stamp mismatch.\n");
             exit(EXIT_FAILURE);
 
         int rtnValue;
 
-        if ((msg_spectra_isZero(obj->in1) != msg_powers_isZero(obj->in2)) ||
-            (msg_spectra_isZero(obj->in1) != msg_tracks_isZero(obj->in3))) {
+        if ((obj->in1->timeStamp != obj->in2->timeStamp) ||
+            (obj->in1->timeStamp != obj->in3->timeStamp)) {
 
             printf("Time stamp mismatch.\n");
             exit(EXIT_FAILURE);
index dde8e4e06c27124164f3a88b33773125b5c7d21f..9fb212191a622969c4934837e6f4918f3be09a8e 100644 (file)
@@ -1,7 +1,7 @@
     
     #include "mod_sst.h"
 
-    mod_sst_obj * mod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_tracks_cfg * msg_tracks_config) {
+    mod_sst_obj * mod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_targets_cfg * msg_targets_config, const msg_tracks_cfg * msg_tracks_config) {
 
         mod_sst_obj * obj;
         
         obj->nPots = msg_pots_config->nPots;
         obj->nTracksMax = msg_tracks_config->nTracks;
         obj->nTracks = 0;
+        obj->nTargetsMax = msg_targets_config->nTargets;
 
         obj->mode = mod_sst_config->mode;
+        obj->add = mod_sst_config->add;
 
         obj->mixtures = (mixture_obj **) malloc(sizeof(mixture_obj *) * (obj->nTracksMax+1));
         obj->coherences = (coherences_obj **) malloc(sizeof(coherences_obj *) * (obj->nTracksMax+1));
         }
 
         obj->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nTracksMax);
+        memset(obj->ids, 0x00, sizeof(unsigned long long) * obj->nTracksMax);
         obj->idsAdded = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nTracksMax);
+        memset(obj->idsAdded, 0x00, sizeof(unsigned long long) * obj->nTracksMax);
         obj->idsRemoved = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nTracksMax);
-                
+        memset(obj->idsRemoved, 0x00, sizeof(unsigned long long) * obj->nTracksMax);
+        
+        obj->tags = (char **) malloc(sizeof(char *) * obj->nTracksMax);
+
+        for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+
+            obj->tags[iTrackMax] = (char *) malloc(sizeof(char) * 256);
+            strcpy(obj->tags[iTrackMax],"");
+
+        }
+
         obj->type = (char *) malloc(sizeof(char) * obj->nTracksMax);
+        memset(obj->type, 0x00, sizeof(char) * obj->nTracksMax);
         
         obj->kalmans = (kalman_obj **) malloc(sizeof(kalman_obj *) * obj->nTracksMax); 
         memset(obj->kalmans, 0x00, sizeof(kalman_obj *) * obj->nTracksMax);
         obj->theta_inactive = mod_sst_config->theta_inactive;
 
         obj->n_prob = (unsigned int *) malloc(sizeof(unsigned int) * obj->nTracksMax);
+        memset(obj->n_prob, 0x00, sizeof(unsigned int) * obj->nTracksMax);
         obj->mean_prob = (float *) malloc(sizeof(float) * obj->nTracksMax);
+        memset(obj->mean_prob, 0x00, sizeof(float) * obj->nTracksMax);
         obj->n_inactive = (unsigned int *) malloc(sizeof(unsigned int) * obj->nTracksMax);
+        memset(obj->n_inactive, 0x00, sizeof(unsigned int) * obj->nTracksMax);
 
         for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-            obj->ids[iTrackMax] = 0;
-            obj->idsAdded[iTrackMax] = 0;
-            obj->idsRemoved[iTrackMax] = 0;
-
             obj->type[iTrackMax] = 'I';
 
             switch(obj->mode) {
             
             obj->N_inactive[iTrackMax] = mod_sst_config->N_inactive[iTrackMax];
 
-            obj->n_prob[iTrackMax] = 0;
-            obj->mean_prob[iTrackMax] = 0.0f;
-            obj->n_inactive[iTrackMax] = 0;
-
         }       
 
         points = space_sphere(mod_ssl_config->levels[mod_ssl_config->nLevels-1]);
                 obj->kalman2kalman_active = kalman2kalman_construct(deltaT,
                                                                     mod_sst_config->sigmaQ,
                                                                     mod_sst_config->sigmaR_active,
-                                                                    mod_sst_config->epsilon);    
+                                                                    mod_sst_config->epsilon);   
+
+                obj->kalman2kalman_target = kalman2kalman_construct(deltaT,
+                                                                    mod_sst_config->sigmaQ,
+                                                                    mod_sst_config->sigmaR_target,
+                                                                    mod_sst_config->epsilon);
 
                 obj->kalman2coherence_prob = kalman2coherence_construct(mod_sst_config->epsilon, 
                                                                         mod_sst_config->sigmaR_prob);
                 obj->kalman2coherence_active = kalman2coherence_construct(mod_sst_config->epsilon, 
                                                                           mod_sst_config->sigmaR_active);
 
+                obj->kalman2coherence_target = kalman2coherence_construct(mod_sst_config->epsilon,
+                                                                          mod_sst_config->sigmaR_target);
+
                 obj->particle2particle_prob = NULL;
                 obj->particle2particle_active = NULL;
+                obj->particle2particle_target = NULL;
                 obj->particle2coherence_prob = NULL;
                 obj->particle2coherence_active = NULL;                
+                obj->particle2coherence_target = NULL;
 
             break;
 
 
                 obj->kalman2kalman_prob = NULL;
                 obj->kalman2kalman_active = NULL;
+                obj->kalman2kalman_target = NULL;
                 obj->kalman2coherence_prob = NULL;
                 obj->kalman2coherence_active = NULL;
+                obj->kalman2coherence_target = NULL;
 
                 obj->particle2particle_prob = particle2particle_construct(mod_sst_config->nParticles,
                                                                           deltaT,
                                                                             mod_sst_config->ac_ratio,
                                                                             (double) mod_sst_config->epsilon,
                                                                             mod_sst_config->sigmaR_active,
-                                                                            mod_sst_config->Nmin);    
+                                                                            mod_sst_config->Nmin);   
+
+                obj->particle2particle_target = particle2particle_construct(mod_sst_config->nParticles,
+                                                                            deltaT,
+                                                                            mod_sst_config->st_alpha,
+                                                                            mod_sst_config->st_beta,
+                                                                            mod_sst_config->st_ratio,
+                                                                            mod_sst_config->ve_alpha,
+                                                                            mod_sst_config->ve_beta,
+                                                                            mod_sst_config->ve_ratio,
+                                                                            mod_sst_config->ac_alpha,
+                                                                            mod_sst_config->ac_beta,
+                                                                            mod_sst_config->ac_ratio,
+                                                                            (double) mod_sst_config->epsilon,
+                                                                            mod_sst_config->sigmaR_target,
+                                                                            mod_sst_config->Nmin);  
 
                 obj->particle2coherence_prob = particle2coherence_construct(mod_sst_config->sigmaR_prob);
 
                 obj->particle2coherence_active = particle2coherence_construct(mod_sst_config->sigmaR_active);
 
+                obj->particle2coherence_target = particle2coherence_construct(mod_sst_config->sigmaR_target);
+
             break;
 
             default:
 
         obj->id = 0;
 
-        obj->in = (msg_pots_obj *) NULL;
+        obj->in1 = (msg_pots_obj *) NULL;
+        obj->in2 = (msg_targets_obj *) NULL;
         obj->out = (msg_tracks_obj *) NULL;
 
         return obj;
         free((void *) obj->ids);
         free((void *) obj->idsAdded);
         free((void *) obj->idsRemoved);
+        
+        for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+            free((void *) obj->tags[iTrackMax]);
+        }
+        free((void *) obj->tags);
+        
         free((void *) obj->type);
 
         free((void *) obj->kalmans);
         if (obj->kalman2kalman_active != NULL) {
             kalman2kalman_destroy(obj->kalman2kalman_active);
         }
+        if (obj->kalman2kalman_target != NULL) {
+            kalman2kalman_destroy(obj->kalman2kalman_target);
+        }
         if (obj->kalman2coherence_prob != NULL) {
             kalman2coherence_destroy(obj->kalman2coherence_prob);
         }
         if (obj->kalman2coherence_active != NULL) {
             kalman2coherence_destroy(obj->kalman2coherence_active);
         }
+        if (obj->kalman2coherence_target != NULL) {
+            kalman2coherence_destroy(obj->kalman2coherence_target);
+        }
         if (obj->particle2particle_prob != NULL) {
             particle2particle_destroy(obj->particle2particle_prob);
         }
         if (obj->particle2particle_active != NULL) {
             particle2particle_destroy(obj->particle2particle_active);
         }
+        if (obj->particle2particle_target != NULL) {
+            particle2particle_destroy(obj->particle2particle_target);
+        }
         if (obj->particle2coherence_prob != NULL)  {
             particle2coherence_destroy(obj->particle2coherence_prob);
         }
-        if (obj->particle2coherence_active != NULL)  {
+        if (obj->particle2coherence_active != NULL) {
             particle2coherence_destroy(obj->particle2coherence_active);
         }
+        if (obj->particle2coherence_target != NULL) {
+            particle2coherence_destroy(obj->particle2coherence_target);
+        }
 
         mixture2mixture_destroy(obj->mixture2mixture);
 
         unsigned int iPot;
         unsigned int iTrackMax;
         unsigned int iTrack;
+        unsigned int iTargetMax;
         float x,y,z;
         float sourceActivity;
         int rtnValue;
+        char targetFound;
+
+        if (obj->in1->timeStamp != obj->in2->timeStamp) {
+
+            printf("Time stamp mismatch.\n");
+            exit(EXIT_FAILURE);
+
+        }
+
+        if (msg_pots_isZero(obj->in1) == 0) {
+
+            // +----------------------------------------------------------------------+
+            // | Update tracked sources from target sources                           |
+            // +----------------------------------------------------------------------+
+
+            // Add sources
+
+            for (iTargetMax = 0; iTargetMax < obj->nTargetsMax; iTargetMax++) {
+
+                targetFound = 0x00;
+
+                for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+
+                    if (strcmp(obj->in2->targets->tags[iTargetMax],obj->tags[iTrackMax])==0) {
+                        
+                        targetFound = 0x01;
+                        break;
+
+                    }
+
+                }
+
+                if (targetFound == 0x00) {
+
+                    for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+
+                        if (obj->ids[iTrackMax] == 0) {
+
+                            obj->id++;
+                            obj->ids[iTrackMax] = obj->id;
+                            strcpy(obj->tags[iTrackMax],obj->in2->targets->tags[iTargetMax]);
+
+                            switch(obj->mode) {
+
+                                case 'k':
+
+                                    kalman2kalman_init_targets(obj->kalman2kalman_prob, 
+                                                               obj->in2->targets,
+                                                               iTargetMax, 
+                                                               obj->kalmans[iTrackMax]); 
+
+                                break;
+
+                                case 'p':
+
+                                    particle2particle_init_targets(obj->particle2particle_prob, 
+                                                                   obj->in2->targets,
+                                                                   iTargetMax, 
+                                                                   obj->particles[iTrackMax]);
+
+                                break;
+
+                                default:
+
+                                    printf("Invalid filter type.\n");
+                                    exit(EXIT_FAILURE);
+
+                                break;
+
+                            }
+
+                            obj->type[iTrackMax] = 'T';
+                            obj->n_prob[iTrackMax] = 0;
+                            obj->mean_prob[iTrackMax] = 0.0f;
+
+                            break;
+
+                        }
+
+                    }
+
+                }
+
+            }
+
+            // Remove sources
+
+            for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+
+                if (strcmp(obj->tags[iTrackMax],"dynamic") != 0) {
+
+                    targetFound = 0x00;
+
+                    for (iTargetMax = 0; iTargetMax < obj->nTargetsMax; iTargetMax++) {
 
-        if (msg_pots_isZero(obj->in) == 0) {
+                        if (strcmp(obj->tags[iTrackMax],obj->in2->targets->tags[iTargetMax]) == 0) {
 
-            // Count
+                            targetFound = 0x01;
+                            break;
+
+                        }
+
+                    }
+
+                    if (targetFound == 0x00) {
+
+                        obj->ids[iTrackMax] = 0;
+                        strcpy(obj->tags[iTrackMax],"");
+                        obj->type[iTrackMax] = 'I';
+                        obj->n_prob[iTrackMax] = 0;
+                        obj->mean_prob[iTrackMax] = 0.0f;
+
+                    }
+
+                }
+
+            }
+
+            // +----------------------------------------------------------------------+
+            // | Count tracked sources                                                |
+            // +----------------------------------------------------------------------+
 
             obj->nTracks = 0;
 
 
             }
 
-            // Predict  
+            // +----------------------------------------------------------------------+
+            // | Predict                                                              |
+            // +----------------------------------------------------------------------+
 
             for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
 
                                 break;
 
+                                case 'T':
+
+                                    kalman2kalman_predict_static(obj->kalman2kalman_target,
+                                                                 obj->kalmans[iTrackMax]);
+
+                                break;
+
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Predict: Unknown state.\n");
+                                    printf("%u, %c\n",iTrackMax,obj->type[iTrackMax]);
                                     exit(EXIT_FAILURE);                        
 
                                 break;
 
                                 break;
 
+                                case 'T':
+
+                                    particle2particle_predict_static(obj->particle2particle_target,
+                                                                     obj->particles[iTrackMax]);
+
+                                break;
+
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Predict: Unknown state.\n");
                                     exit(EXIT_FAILURE);                        
 
                                 break;
 
             }
 
-            // Coherence
+            // +----------------------------------------------------------------------+
+            // | Coherence                                                            |
+            // +----------------------------------------------------------------------+
 
             iTrack = 0;
 
 
                                     kalman2coherence_process(obj->kalman2coherence_prob,
                                                              obj->kalmans[iTrackMax],
-                                                             obj->in->pots,
+                                                             obj->in1->pots,
                                                              iTrack,
                                                              obj->coherences[obj->nTracks]);
 
 
                                     kalman2coherence_process(obj->kalman2coherence_active,
                                                              obj->kalmans[iTrackMax],
-                                                             obj->in->pots,
+                                                             obj->in1->pots,
+                                                             iTrack,
+                                                             obj->coherences[obj->nTracks]);
+
+                                break;
+
+                                case 'T':
+
+                                    kalman2coherence_process(obj->kalman2coherence_target,
+                                                             obj->kalmans[iTrackMax],
+                                                             obj->in1->pots,
                                                              iTrack,
                                                              obj->coherences[obj->nTracks]);
 
 
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Coherence: Unknown state.\n");
                                     exit(EXIT_FAILURE);                            
 
                                 break;
 
                                     particle2coherence_process(obj->particle2coherence_prob,
                                                                obj->particles[iTrackMax],
-                                                               obj->in->pots,
+                                                               obj->in1->pots,
                                                                iTrack,
                                                                obj->coherences[obj->nTracks]);
 
 
                                     particle2coherence_process(obj->particle2coherence_active,
                                                                obj->particles[iTrackMax],
-                                                               obj->in->pots,
+                                                               obj->in1->pots,
                                                                iTrack,
                                                                obj->coherences[obj->nTracks]);
 
                                 break;
 
+                                case 'T':
+
+                                    particle2coherence_process(obj->particle2coherence_target,
+                                                               obj->particles[iTrackMax],
+                                                               obj->in1->pots,
+                                                               iTrack,
+                                                               obj->coherences[obj->nTracks]);                                
+
+                                break;
+
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Coherence: Unknown state.\n");
                                     exit(EXIT_FAILURE);                            
 
                                 break;                        
 
             }
 
-            // Mixture
+            // +----------------------------------------------------------------------+
+            // | Mixture                                                              |
+            // +----------------------------------------------------------------------+
 
             mixture2mixture_process(obj->mixture2mixture, 
                                    obj->mixtures[obj->nTracks], 
-                                   obj->in->pots, 
+                                   obj->in1->pots, 
                                    obj->coherences[obj->nTracks], 
                                    obj->postprobs[obj->nTracks]);
 
-            // Update
+            // +----------------------------------------------------------------------+
+            // | Update                                                               |
+            // +----------------------------------------------------------------------+
 
             iTrack = 0;
 
                                     kalman2kalman_update(obj->kalman2kalman_prob,
                                                          obj->postprobs[obj->nTracks],
                                                          iTrack,
-                                                         obj->in->pots,
+                                                         obj->in1->pots,
                                                          obj->kalmans[iTrackMax]);
 
                                 break;
                                     kalman2kalman_update(obj->kalman2kalman_active,
                                                          obj->postprobs[obj->nTracks],
                                                          iTrack,
-                                                         obj->in->pots,
+                                                         obj->in1->pots,
                                                          obj->kalmans[iTrackMax]);
 
                                 break;
 
+                                case 'T':
+
+                                    kalman2kalman_update_static(obj->kalman2kalman_target,
+                                                                obj->postprobs[obj->nTracks],
+                                                                iTrack,
+                                                                obj->in1->pots,
+                                                                obj->kalmans[iTrackMax]);
+
+                                break;
+
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Update: Unknown state.\n");
                                     exit(EXIT_FAILURE); 
 
                                 break;
                                     particle2particle_update(obj->particle2particle_prob,
                                                              obj->postprobs[obj->nTracks],
                                                              iTrack,
-                                                             obj->in->pots,
+                                                             obj->in1->pots,
                                                              obj->particles[iTrackMax]);
 
                                 break;
                                     particle2particle_update(obj->particle2particle_active,
                                                              obj->postprobs[obj->nTracks],
                                                              iTrack,
-                                                             obj->in->pots,
+                                                             obj->in1->pots,
                                                              obj->particles[iTrackMax]);
 
                                 break;
 
+                                case 'T':
+
+                                    particle2particle_update_static(obj->particle2particle_target,
+                                                                    obj->postprobs[obj->nTracks],
+                                                                    iTrack,
+                                                                    obj->in1->pots,
+                                                                    obj->particles[iTrackMax]);
+
+                                break;
+
                                 default:
 
-                                    printf("Unknown state.\n");
+                                    printf("Update: Unknown state.\n");
                                     exit(EXIT_FAILURE);                         
 
                                 break;
 
             }
 
-            // Activity
+            // +----------------------------------------------------------------------+
+            // | Activity                                                             |
+            // +----------------------------------------------------------------------+
 
             iTrack = 0;
             memset(obj->sourceActivities, 0x00, sizeof(float) * obj->nTracksMax);
 
                         break;
 
+                        case 'T':
+
+                            // No counter to update
+
+                        break;
+
                         default:
 
                             printf("Unknown state.\n");
 
             }        
 
-            // Transitions
+            // +----------------------------------------------------------------------+
+            // | Transitions                                                          |
+            // +----------------------------------------------------------------------+
 
             iTrack = 0;
 
 
             }          
 
-            // Add source
-            
-            for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+            // +----------------------------------------------------------------------+
+            // | Update tracked sources from potential sources                        |
+            // +----------------------------------------------------------------------+
 
-                obj->idsAdded[iTrackMax] = 0;
+            // Only if the tracking is dynamic (i.e. sources may be created automatically)
 
-            }
+            if (obj->add = 'd') {
 
-            for (iPot = 0; iPot < obj->nPots; iPot++) {
+                // Add sources
+                
+                for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-                if (obj->postprobs[obj->nTracks]->arrayNew[iPot] > obj->theta_new) {                
+                    obj->idsAdded[iTrackMax] = 0;
 
-                    for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+                }
 
-                        if (obj->ids[iTrackMax] == 0) {
+                for (iPot = 0; iPot < obj->nPots; iPot++) {
 
-                            obj->id++;
-                            obj->idsAdded[iTrackMax] = obj->id;
-                            
-                            switch(obj->mode) {
+                    if (obj->postprobs[obj->nTracks]->arrayNew[iPot] > obj->theta_new) {                
 
-                                case 'k':
+                        for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-                                    kalman2kalman_init(obj->kalman2kalman_prob, 
-                                                       obj->in->pots,
-                                                       iPot, 
-                                                       obj->kalmans[iTrackMax]); 
+                            if (obj->ids[iTrackMax] == 0) {
 
-                                break;
+                                obj->id++;
+                                obj->idsAdded[iTrackMax] = obj->id;
+                                
+                                switch(obj->mode) {
 
-                                case 'p':
+                                    case 'k':
 
-                                    particle2particle_init(obj->particle2particle_prob, 
-                                                           obj->in->pots,
-                                                           iPot, 
-                                                           obj->particles[iTrackMax]);
+                                        kalman2kalman_init_pots(obj->kalman2kalman_prob, 
+                                                                obj->in1->pots,
+                                                                iPot, 
+                                                                obj->kalmans[iTrackMax]); 
 
-                                break;
+                                    break;
 
-                                default:
+                                    case 'p':
 
-                                    printf("Invalid filter type.\n");
-                                    exit(EXIT_FAILURE);
+                                        particle2particle_init_pots(obj->particle2particle_prob, 
+                                                                    obj->in1->pots,
+                                                                    iPot, 
+                                                                    obj->particles[iTrackMax]);
 
-                                break;
+                                    break;
 
-                            }
+                                    default:
 
-                            obj->type[iTrackMax] = 'P';
-                            obj->n_prob[iTrackMax] = 0;
-                            obj->mean_prob[iTrackMax] = 0.0f;
+                                        printf("Invalid filter type.\n");
+                                        exit(EXIT_FAILURE);
 
-                            break;
+                                    break;
+
+                                }
+
+                                obj->type[iTrackMax] = 'P';
+                                obj->n_prob[iTrackMax] = 0;
+                                obj->mean_prob[iTrackMax] = 0.0f;
+
+                                break;
+
+                            }
 
                         }
 
 
                 }
 
-            }
+                // Remove source
 
-            // Remove source
+                for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-            for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+                    obj->idsRemoved[iTrackMax] = 0;
+                    
+                }
 
-                obj->idsRemoved[iTrackMax] = 0;
-                
-            }
+                iTrack = 0;
 
-            iTrack = 0;
+                for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-            for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+                    if (obj->ids[iTrackMax] != 0) {
 
-                if (obj->ids[iTrackMax] != 0) {
+                        if ((obj->type[iTrackMax] == 'P') && 
+                            (obj->n_prob[iTrackMax] == obj->N_prob) && 
+                            (obj->mean_prob[iTrackMax]/((float) obj->N_prob) < obj->theta_prob)) {
 
-                    if ((obj->type[iTrackMax] == 'P') && 
-                        (obj->n_prob[iTrackMax] == obj->N_prob) && 
-                        (obj->mean_prob[iTrackMax]/((float) obj->N_prob) < obj->theta_prob)) {
+                            obj->idsRemoved[iTrackMax] = obj->ids[iTrackMax];
 
-                        obj->idsRemoved[iTrackMax] = obj->ids[iTrackMax];
+                        }
 
-                    }
+                        if ((obj->type[iTrackMax] == 'A') &&
+                            (obj->n_inactive[iTrackMax] >= obj->N_inactive[obj->nTracks-1])) {
+
+                            obj->idsRemoved[iTrackMax] = obj->ids[iTrackMax];
 
-                    if ((obj->type[iTrackMax] == 'A') &&
-                        (obj->n_inactive[iTrackMax] >= obj->N_inactive[obj->nTracks-1])) {
+                        }
 
-                        obj->idsRemoved[iTrackMax] = obj->ids[iTrackMax];
+                        iTrack++;
 
                     }
 
-                    iTrack++;
-
                 }
 
-            }
+                // Update IDs
 
-            // Update IDs
+                for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
 
-            for (iTrackMax = 0; iTrackMax < obj->nTracksMax; iTrackMax++) {
+                    if (obj->idsAdded[iTrackMax] != 0) {
 
-                if (obj->idsAdded[iTrackMax] != 0) {
+                        obj->ids[iTrackMax] = obj->idsAdded[iTrackMax];
+                        strcpy(obj->tags[iTrackMax], "dynamic");
 
-                    obj->ids[iTrackMax] = obj->idsAdded[iTrackMax];
+                    }
 
-                }
+                    if (obj->idsRemoved[iTrackMax] != 0) {
 
-                if (obj->idsRemoved[iTrackMax] != 0) {
+                        obj->ids[iTrackMax] = 0;
+                        strcpy(obj->tags[iTrackMax], "");                   
 
-                    obj->ids[iTrackMax] = 0;
+                    }
 
                 }
 
             }
 
-            // Count
+            // +----------------------------------------------------------------------+
+            // | Count tracked sources                                                |
+            // +----------------------------------------------------------------------+
 
             obj->nTracks = 0;
 
 
             }
 
-
-            // Copy in tracking
+            // +----------------------------------------------------------------------+
+            // | Copy in tracking                                                     |
+            // +----------------------------------------------------------------------+
        
             memset(obj->out->tracks->array, 0x00, sizeof(float) * obj->out->tracks->nTracks * 3);
             memset(obj->out->tracks->ids, 0x00, sizeof(unsigned long long) * obj->out->tracks->nTracks);
 
                 if (obj->ids[iTrackMax] != 0) {
 
-                    if (obj->type[iTrackMax] == 'A') {
+                    if ((obj->type[iTrackMax] == 'A') || (obj->type[iTrackMax] == 'T')) {
 
                         switch(obj->mode) {
 
                         obj->out->tracks->array[iTrackMax * 3 + 1] = y;
                         obj->out->tracks->array[iTrackMax * 3 + 2] = z;
                         obj->out->tracks->ids[iTrackMax] = obj->ids[iTrackMax];
+                        strcpy(obj->out->tracks->tags[iTrackMax],obj->tags[iTrackMax]);
                         obj->out->tracks->activity[iTrackMax] = obj->sourceActivities[iTrackMax];
 
                     }
 
             }
 
-            obj->out->timeStamp = obj->in->timeStamp;
+            obj->out->timeStamp = obj->in2->timeStamp;
 
             rtnValue = 0;
 
 
     }
 
-    void mod_sst_connect(mod_sst_obj * obj, msg_pots_obj * in, msg_tracks_obj * out) {
+    void mod_sst_connect(mod_sst_obj * obj, msg_pots_obj * in1, msg_targets_obj * in2, msg_tracks_obj * out) {
 
-        obj->in = in;
+        obj->in1 = in1;
+        obj->in2 = in2;
         obj->out = out;
 
     }
 
     void mod_sst_disconnect(mod_sst_obj * obj) {
 
-        obj->in = (msg_pots_obj *) NULL;
+        obj->in1 = (msg_pots_obj *) NULL;
+        obj->in2 = (msg_targets_obj *) NULL;
         obj->out = (msg_tracks_obj *) NULL;
 
     }
index ceb80c381fd59cfd7ff99be5641c6f0ef6c46e69..16cdf9eea8a9e0f913d3ab69c76e9ef7b8201cab 100644 (file)
@@ -20,6 +20,7 @@
     #include "../system/mixture2mixture.h"
 
     #include "../message/msg_pots.h"
+    #include "../message/msg_targets.h"
     #include "../message/msg_tracks.h"
     #include "../module/mod_ssl.h"
 
         unsigned int nPots;
         unsigned int nTracksMax;
         unsigned int nTracks;
+        unsigned int nTargetsMax;
 
         char mode;
+        char add;
 
         mixture_obj ** mixtures;
         coherences_obj ** coherences;
         unsigned long long * ids;
         unsigned long long * idsAdded;
         unsigned long long * idsRemoved;
+        char ** tags;
         
         char * type;
 
         kalman_obj ** kalmans;
         kalman2kalman_obj * kalman2kalman_prob;
         kalman2kalman_obj * kalman2kalman_active;
+        kalman2kalman_obj * kalman2kalman_target;
         kalman2coherence_obj * kalman2coherence_prob;
         kalman2coherence_obj * kalman2coherence_active;
+        kalman2coherence_obj * kalman2coherence_target;
         
         particles_obj ** particles;
         particle2particle_obj * particle2particle_prob;
         particle2particle_obj * particle2particle_active;
+        particle2particle_obj * particle2particle_target;
         particle2coherence_obj * particle2coherence_prob;
         particle2coherence_obj * particle2coherence_active;
+        particle2coherence_obj * particle2coherence_target;
 
         mixture2mixture_obj * mixture2mixture;
         
@@ -69,7 +77,8 @@
 
         unsigned long long id;
 
-        msg_pots_obj * in;
+        msg_pots_obj * in1;
+        msg_targets_obj * in2;
         msg_tracks_obj * out;
 
     } mod_sst_obj;
@@ -77,6 +86,7 @@
     typedef struct mod_sst_cfg {
 
         char mode;
+        char add;
 
         unsigned int nTracksMax;
         unsigned int hopSize;
         float epsilon;
         float sigmaR_active;
         float sigmaR_prob;
+        float sigmaR_target;
         gaussians_1d_obj * active_gmm;
         gaussians_1d_obj * inactive_gmm;
         float Pfalse;
 
     } mod_sst_cfg;
 
-    mod_sst_obj * mod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_tracks_cfg * msg_tracks_config);
+    mod_sst_obj * mod_sst_construct(const mod_sst_cfg * mod_sst_config, const mod_ssl_cfg * mod_ssl_config, const msg_pots_cfg * msg_pots_config, const msg_targets_cfg * msg_targets_config, const msg_tracks_cfg * msg_tracks_config);
 
     void mod_sst_destroy(mod_sst_obj * obj);
 
     int mod_sst_process(mod_sst_obj * obj);
 
-    void mod_sst_connect(mod_sst_obj * obj, msg_pots_obj * in, msg_tracks_obj * out);
+    void mod_sst_connect(mod_sst_obj * obj, msg_pots_obj * in1, msg_targets_obj * in2, msg_tracks_obj * out);
 
     void mod_sst_disconnect(mod_sst_obj * obj);
 
diff --git a/src/signal/target.c b/src/signal/target.c
new file mode 100644 (file)
index 0000000..dad6466
--- /dev/null
@@ -0,0 +1,110 @@
+    
+    #include "target.h"
+
+    targets_obj * targets_construct_zero(const unsigned int nTargets) {
+
+        targets_obj * obj;
+        unsigned int iTarget;
+
+        obj = (targets_obj *) malloc(sizeof(targets_obj));
+
+        obj->nTargets = nTargets;
+        
+        obj->tags = (char **) malloc(sizeof(char *) * nTargets);
+
+        for (iTarget = 0; iTarget < nTargets; iTarget++) {
+
+            obj->tags[iTarget] = (char *) malloc(sizeof(char) * 256);
+            strcpy(obj->tags[iTarget], "");
+
+        }
+
+        obj->array = (float *) malloc(sizeof(float) * 3 * nTargets);
+        memset(obj->array, 0x00, sizeof(float) * 3 * nTargets);
+
+        return obj;
+
+    }
+
+    void targets_destroy(targets_obj * obj) {
+
+        unsigned int iTarget;
+
+        for (iTarget = 0; iTarget < obj->nTargets; iTarget++) {
+            free((void *) obj->tags[iTarget]);
+        }
+        free((void *) obj->tags);
+
+        free((void *) obj->array);
+        free((void *) obj);
+
+    }
+
+    targets_obj * targets_clone(const targets_obj * obj) {
+
+        targets_obj * clone;
+        unsigned int iTarget;
+
+        clone = (targets_obj *) malloc(sizeof(targets_obj));
+
+        clone->nTargets = obj->nTargets;
+        clone->array = (float *) malloc(sizeof(float) * 3 * obj->nTargets);
+        memcpy(clone->array, obj->array, sizeof(float) * 3 * obj->nTargets);
+        
+        clone->tags = (char **) malloc(sizeof(char *) * obj->nTargets);
+
+        for (iTarget = 0; iTarget < obj->nTargets; iTarget++) {
+
+            clone->tags[iTarget] = (char *) malloc(sizeof(char) * 256);
+            strcpy(clone->tags[iTarget], obj->tags[iTarget]);
+            
+        }
+
+        return clone;
+
+    }
+
+    void targets_copy(targets_obj * dest, const targets_obj * src) {
+
+        unsigned int iTarget;
+
+        dest->nTargets = src->nTargets;
+        memcpy(dest->array, src->array, sizeof(float) * 3 * src->nTargets);
+        
+        for (iTarget = 0; iTarget < src->nTargets; iTarget++) {
+
+            strcpy(dest->tags[iTarget], src->tags[iTarget]);
+
+        }
+
+    }
+
+    void targets_zero(targets_obj * obj) {
+
+        unsigned int iTarget;
+
+        memset(obj->array, 0x00, sizeof(float) * 3 * obj->nTargets);
+        
+        for (iTarget = 0; iTarget < obj->nTargets; iTarget++) {
+            
+            strcpy(obj->tags[iTarget], "");
+
+        }
+
+    }
+
+    void targets_printf(const targets_obj * obj) {
+
+        unsigned int iTarget;
+
+        for (iTarget = 0; iTarget < obj->nTargets; iTarget++) {
+
+            printf("[%s]: %+1.3f %+1.3f %+1.3f\n",
+                   obj->tags[iTarget],
+                   obj->array[iTarget * 3 + 0],
+                   obj->array[iTarget * 3 + 1],
+                   obj->array[iTarget * 3 + 2]);
+            
+        }
+
+    }
\ No newline at end of file
diff --git a/src/signal/target.h b/src/signal/target.h
new file mode 100644 (file)
index 0000000..04a3d58
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __ODAS_SIGNAL_TARGET
+#define __ODAS_SIGNAL_TARGET
+
+    #include <stdlib.h>
+    #include <string.h>
+    #include <stdio.h>
+
+    typedef struct targets_obj {
+
+        unsigned int nTargets;
+        char ** tags;
+        float * array;
+        
+    } targets_obj;
+
+    targets_obj * targets_construct_zero(const unsigned int nTargets);
+
+    void targets_destroy(targets_obj * obj);
+
+    targets_obj * targets_clone(const targets_obj * obj);
+
+    void targets_copy(targets_obj * dest, const targets_obj * src);
+
+    void targets_zero(targets_obj * obj);
+
+    void targets_printf(const targets_obj * obj);    
+
+#endif
\ No newline at end of file
index a0ee965dedaf913f6bff738549ea824da55f7607..7049e2c7536932f574a63f39a83473e808c0fdb1 100644 (file)
@@ -4,6 +4,7 @@
     tracks_obj * tracks_construct_zero(const unsigned int nTracks) {
 
         tracks_obj * obj;
+        unsigned int iTrack;
 
         obj = (tracks_obj *) malloc(sizeof(tracks_obj));
 
         memset(obj->array, 0x00, sizeof(float) * 3 * nTracks);
         obj->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * nTracks);
         memset(obj->ids, 0x00, sizeof(unsigned long long) * nTracks);
+
+        obj->tags = (char **) malloc(sizeof(char *) * nTracks);
+
+        for (iTrack = 0; iTrack < nTracks; iTrack++) {
+
+            obj->tags[iTrack] = (char *) malloc(sizeof(char) * 256);
+            strcpy(obj->tags[iTrack], "");
+
+        }
+
         obj->activity = (float *) malloc(sizeof(float) * nTracks);
         memset(obj->activity, 0x00, sizeof(float) * nTracks);
 
 
     void tracks_destroy(tracks_obj * obj) {
 
+        unsigned int iTrack;
+
         free((void *) obj->array);
         free((void *) obj->ids);
+
+        for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
+            free((void *) obj->tags[iTrack]);
+        }
+        free((void *) obj->tags);
+
         free((void *) obj->activity);
         free((void *) obj);
 
@@ -31,6 +50,7 @@
     tracks_obj * tracks_clone(const tracks_obj * obj) {
 
         tracks_obj * clone;
+        unsigned int iTrack;
 
         clone = (tracks_obj *) malloc(sizeof(tracks_obj));
 
         memcpy(clone->array, obj->array, sizeof(float) * 3 * obj->nTracks);
         clone->ids = (unsigned long long *) malloc(sizeof(unsigned long long) * obj->nTracks);
         memcpy(clone->ids, obj->ids, sizeof(unsigned long long) * obj->nTracks);
+
+        clone->tags = (char **) malloc(sizeof(char *) * obj->nTracks);
+
+        for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
+
+            clone->tags[iTrack] = (char *) malloc(sizeof(char) * 256);
+            strcpy(clone->tags[iTrack], "");
+            
+        }
+
         clone->activity = (float *) malloc(sizeof(float) * obj->nTracks);
         memcpy(clone->activity, obj->activity, sizeof(float) * obj->nTracks);
 
 
     void tracks_copy(tracks_obj * dest, const tracks_obj * src) {
 
+        unsigned int iTrack;
+
         dest->nTracks = src->nTracks;
         memcpy(dest->array, src->array, sizeof(float) * 3 * src->nTracks);
         memcpy(dest->ids, src->ids, sizeof(unsigned long long) * src->nTracks);
+        
+        for (iTrack = 0; iTrack < src->nTracks; iTrack++) {
+
+            strcpy(dest->tags[iTrack], src->tags[iTrack]);
+
+        }
+
         memcpy(dest->activity, src->activity, sizeof(float) * src->nTracks);
 
     }
 
     void tracks_zero(tracks_obj * obj) {
 
-        obj->nTracks = 0;
+        unsigned int iTrack;
+
         memset(obj->array, 0x00, sizeof(float) * 3 * obj->nTracks);
-        memset(obj->ids, 0x00, sizeof(unsigned long long) * obj->nTracks);
+        memset(obj->ids, 0x00, sizeof(unsigned long long) * obj->nTracks);       
+
+        for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
+            
+            strcpy(obj->tags[iTrack], "");
+
+        }
+
         memset(obj->activity, 0x00, sizeof(float) * obj->nTracks);
 
     }
 
         for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
 
-            printf("(%04llu): %+1.3f %+1.3f %+1.3f - %1.3f\n",
+            printf("(%04llu)-[%s]: %+1.3f %+1.3f %+1.3f - %1.3f\n",
                    obj->ids[iTrack],
+                   obj->tags[iTrack],
                    obj->array[iTrack * 3 + 0],
                    obj->array[iTrack * 3 + 1],
                    obj->array[iTrack * 3 + 2],
             
         }
 
-
     }
\ No newline at end of file
index 3a329e2bd257b6ef16466f17a704944b59777ad5..9986db21472ae385b6b72b8cda10728fe9d4ace6 100644 (file)
@@ -9,6 +9,7 @@
 
         unsigned int nTracks;
         unsigned long long * ids;
+        char ** tags;
         float * array;
         float * activity;
         
index 19c91f13205faf7063a354db3bead9876f45f6dd..701e0700d238a95d9e87e516f2ec1bdeea490e39 100644 (file)
 
         for (iTrack = 0; iTrack < obj->nTracks; iTrack++) {
 
-            sprintf(obj->buffer,"%s        { \"id\": %llu, \"x\": %1.3f, \"y\": %1.3f, \"z\": %1.3f, \"activity\": %1.3f }", 
+            sprintf(obj->buffer,"%s        { \"id\": %llu, \"tag\": %s, \"x\": %1.3f, \"y\": %1.3f, \"z\": %1.3f, \"activity\": %1.3f }", 
                     obj->buffer,
                     obj->in->tracks->ids[iTrack],
+                    obj->in->tracks->tags[iTrack],
                     obj->in->tracks->array[iTrack*3+0], 
                     obj->in->tracks->array[iTrack*3+1], 
                     obj->in->tracks->array[iTrack*3+2],
index 24c22a702970f8fab1495637267bd8476c870cfa..e470f55b1870971af9fcc7d298132103306282c9 100644 (file)
 
     }
 
-    void kalman2kalman_init(kalman2kalman_obj * obj, const pots_obj * pots, const unsigned int iPot, kalman_obj * kalman) {
+    void kalman2kalman_init_pots(kalman2kalman_obj * obj, const pots_obj * pots, const unsigned int iPot, kalman_obj * kalman) {
 
         matrix_copy_zero(kalman->x_llm1);
         matrix_copy_zero(kalman->x_lm1lm1);
 
     }
 
+    void kalman2kalman_init_targets(kalman2kalman_obj * obj, const targets_obj * targets, const unsigned int iTarget, kalman_obj * kalman) {
+
+        matrix_copy_zero(kalman->x_llm1);
+        matrix_copy_zero(kalman->x_lm1lm1);
+        matrix_copy_zero(kalman->P_llm1);
+        matrix_copy_zero(kalman->P_lm1lm1);
+
+        kalman->P_lm1lm1->array[0*(kalman->P_lm1lm1->nCols)+0] = obj->sigmaQ * obj->sigmaQ;
+        kalman->P_lm1lm1->array[1*(kalman->P_lm1lm1->nCols)+1] = obj->sigmaQ * obj->sigmaQ;
+        kalman->P_lm1lm1->array[2*(kalman->P_lm1lm1->nCols)+2] = obj->sigmaQ * obj->sigmaQ;
+        kalman->P_lm1lm1->array[3*(kalman->P_lm1lm1->nCols)+3] = obj->sigmaQ * obj->sigmaQ;
+        kalman->P_lm1lm1->array[4*(kalman->P_lm1lm1->nCols)+4] = obj->sigmaQ * obj->sigmaQ;
+        kalman->P_lm1lm1->array[5*(kalman->P_lm1lm1->nCols)+5] = obj->sigmaQ * obj->sigmaQ;
+
+        kalman->x_lm1lm1->array[0*(kalman->x_lm1lm1->nCols)+0] = targets->array[iTarget * 3 + 0];
+        kalman->x_lm1lm1->array[1*(kalman->x_lm1lm1->nCols)+0] = targets->array[iTarget * 3 + 1];
+        kalman->x_lm1lm1->array[2*(kalman->x_lm1lm1->nCols)+0] = targets->array[iTarget * 3 + 2];
+
+    }
+
     void kalman2kalman_predict(kalman2kalman_obj * obj, kalman_obj * kalman) {
 
         float xx, xy, xz;
 
     }
 
+    void kalman2kalman_predict_static(kalman2kalman_obj * obj, kalman_obj * kalman) {
+
+        matrix_copy_matrix(kalman->x_llm1, kalman->x_lm1lm1);
+        matrix_copy_matrix(kalman->P_llm1, kalman->P_lm1lm1);
+
+    }    
+
     void kalman2kalman_update(kalman2kalman_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, kalman_obj * kalman) {
 
         unsigned int iPot;
         matrix_scale(obj->pKz_Hx, obj->Kz_Hx, updateFactor);
         matrix_add(kalman->x_lm1lm1, kalman->x_llm1, obj->pKz_Hx);
 
-
         // Update P
         matrix_mul(obj->KHP, obj->K, obj->HP);
         matrix_scale(obj->pKHP, obj->KHP, updateFactor);
 
     }
 
+    void kalman2kalman_update_static(kalman2kalman_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, kalman_obj * kalman) {
+
+        matrix_copy_matrix(kalman->x_lm1lm1, kalman->x_llm1);
+        matrix_copy_matrix(kalman->P_lm1lm1, kalman->P_llm1);
+
+    }
+
     void kalman2kalman_estimate(kalman2kalman_obj * obj, const kalman_obj * kalman, float * x, float * y, float * z) {
 
         *x = kalman->x_lm1lm1->array[0*(kalman->x_lm1lm1->nCols)+0];
index e102bfb5b6b4e318edd3125bc5abbc7eac1fbc04..7fd971741bf63e2d80d12cc86c2e358f3a1b5c97 100644 (file)
@@ -8,6 +8,7 @@
     #include "../signal/postprob.h"
     #include "../signal/kalman.h"
     #include "../signal/pot.h"
+    #include "../signal/target.h"
     #include "../utils/matrix.h"
 
     typedef struct kalman2kalman_obj {
 
     void kalman2kalman_destroy(kalman2kalman_obj * obj);
 
-    void kalman2kalman_init(kalman2kalman_obj * obj, const pots_obj * pots, const unsigned int iPot, kalman_obj * kalman);
+    void kalman2kalman_init_pots(kalman2kalman_obj * obj, const pots_obj * pots, const unsigned int iPot, kalman_obj * kalman);
+
+    void kalman2kalman_init_targets(kalman2kalman_obj * obj, const targets_obj * targets, const unsigned int iTarget, kalman_obj * kalman);
 
     void kalman2kalman_predict(kalman2kalman_obj * obj, kalman_obj * kalman);
 
+    void kalman2kalman_predict_static(kalman2kalman_obj * obj, kalman_obj * kalman);
+
     void kalman2kalman_update(kalman2kalman_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, kalman_obj * kalman);
 
+    void kalman2kalman_update_static(kalman2kalman_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, kalman_obj * kalman);    
+
     void kalman2kalman_estimate(kalman2kalman_obj * obj, const kalman_obj * kalman, float * x, float * y, float * z);
 
 #endif
\ No newline at end of file
index 3823f9ae1471d8d9447e2790c27cee984b701937..a76d6229abfaf8393cb7c853c2c16070fff07c80 100644 (file)
@@ -72,7 +72,7 @@
 
     }
 
-    void particle2particle_init(particle2particle_obj * obj, const pots_obj * pots, const unsigned int iPot, particles_obj * particles) {
+    void particle2particle_init_pots(particle2particle_obj * obj, const pots_obj * pots, const unsigned int iPot, particles_obj * particles) {
 
         unsigned int iParticle;
 
 
     }
 
+    void particle2particle_init_targets(particle2particle_obj * obj, const targets_obj * targets, const unsigned int iTarget, particles_obj * particles) {
+
+        unsigned int iParticle;
+
+        random_generate(obj->rnd_ratio, obj->nParticles, obj->indexes_ratio);        
+
+        memset(particles->array, 0x00, sizeof(float) * 7 * obj->nParticles);
+
+        for (iParticle = 0; iParticle < obj->nParticles; iParticle++) {
+
+            particles->array[iParticle * 7 + 0] = targets->array[iTarget * 3 + 0];
+            particles->array[iParticle * 7 + 1] = targets->array[iTarget * 3 + 1];
+            particles->array[iParticle * 7 + 2] = targets->array[iTarget * 3 + 2];
+            particles->array[iParticle * 7 + 6] = (1.0f / ((float) obj->nParticles));
+
+            particles->state[iParticle] = (unsigned char) (obj->indexes_ratio[iParticle]);
+
+        }        
+
+    }
+
     void particle2particle_predict(particle2particle_obj * obj, particles_obj * particles) {
 
         unsigned int iParticle;
 
     }
 
+    void particle2particle_predict_static(particle2particle_obj * obj, particles_obj * particles) {
+
+        // Do nothing: keep old particles distribution
+
+    }
+
     void particle2particle_update(particle2particle_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, particles_obj * particles) {
 
         unsigned int iParticle;
 
     }
 
+    void particle2particle_update_static(particle2particle_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, particles_obj * particles) {
+
+        // Do nothing: keep old particles distribution
+
+    }
+
     void particle2particle_estimate(const particle2particle_obj * obj, const particles_obj * particles, float * x, float * y, float * z) {
 
         unsigned int iParticle;
index 0dfa4f46d04a4fbe47071c4eac408d883ef2a58a..e545757d9b7f013c396b9b6ae78a8675e0253473 100644 (file)
@@ -6,6 +6,7 @@
     #include "../signal/particle.h"
     #include "../signal/postprob.h"
     #include "../signal/pot.h"
+    #include "../signal/target.h"
 
     typedef struct particle2particle_obj {
 
 
     void particle2particle_destroy(particle2particle_obj * obj);
 
-    void particle2particle_init(particle2particle_obj * obj, const pots_obj * pots, const unsigned int iPot, particles_obj * particles);
+    void particle2particle_init_pots(particle2particle_obj * obj, const pots_obj * pots, const unsigned int iPot, particles_obj * particles);
+
+    void particle2particle_init_targets(particle2particle_obj * obj, const targets_obj * targets, const unsigned int iTarget, particles_obj * particles);
 
     void particle2particle_predict(particle2particle_obj * obj, particles_obj * particles);
 
+    void particle2particle_predict_static(particle2particle_obj * obj, particles_obj * particles);
+
     void particle2particle_update(particle2particle_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, particles_obj * particles);
 
+    void particle2particle_update_static(particle2particle_obj * obj, const postprobs_obj * postprobs, const unsigned int iTrack, const pots_obj * pots, particles_obj * particles);
+
     void particle2particle_estimate(const particle2particle_obj * obj, const particles_obj * particles, float * x, float * y, float * z);
 
 #endif
\ No newline at end of file