Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
task_refine.c
Go to the documentation of this file.
1 
11 /* -- Includes -- */
12 /* system libraries */
13 
14 /* project libraries */
15 #include "task.h"
16 
20 void task_refine(void)
21 {
22  // Check if task is enabled
24  {
25  // Local variables
26  int res;
27 
28  // Ping RFID reader
29 #ifndef s_CONFIG_TEST_ENABLE
31 #endif
32 
33  // Check RFID tag
35  // If tag is known -> weight particles and resample
36  if(res >= 0)
37  {
38  // Measurement Update (Particle filter)
39  pf_weight_tag(g_pfs, g_envs, res);
42  pf_random(g_pfs, g_envs, res);
43  //pf_estimate(g_pfs, g_robot); // !!!
44  }
45  // If s_ENVIROMENT_TAG_UNKNOWN, tag is unknown. Most probably a victim
46  else if(res == s_ENVIROMENT_TAG_UNKNOWN)
47  {
48  // Redirect to task_report()
49  // Copy ID to pipe
50  strncpy(g_tp_refine_report.victim_id, g_rfids->id, 11);
51  // Set event
53  }
54  else if(res == s_ENVIROMENT_TAG_DISABLED)
55  {
56  // Do nothing
57  debug_printf("disabled tag red.\n");
58  }
59 
60  }
61 }
void debug_printf(const char *format,...)
Definition: debug.c:25
int rfid_read(rfid_t *rfids)
Definition: rfid.c:124
void pf_random(pf_t *pfs, enviroment_t *envs, int tag_num)
Definition: pf.c:261
int enabled
Definition: task.h:46
char id[11]
Definition: rfid.h:27
taskpipe_refine_report_t g_tp_refine_report
Definition: task.c:52
robot_t * g_robot
Definition: task.c:27
#define s_TASK_EVENT_SET
Definition: task.h:111
rfid_t * g_rfids
Definition: task.c:25
int enviroment_tag_check(enviroment_t *env, char tag_id[11])
Definition: enviroment.c:219
enviroment_t * g_envs
Definition: task.c:23
void pf_estimate(pf_t *pfs, robot_t *robot)
Definition: pf.c:215
void pf_weight_tag(pf_t *pfs, enviroment_t *envs, int tag_num)
Definition: pf.c:117
#define s_ENVIROMENT_TAG_UNKNOWN
Definition: enviroment.h:64
task_t g_task_refine
Definition: task.c:42
#define s_TRUE
Definition: def.h:60
void pf_resample(pf_t *pfs)
Definition: pf.c:152
void task_refine(void)
Definition: task_refine.c:20
#define s_ENVIROMENT_TAG_DISABLED
Definition: enviroment.h:65
pf_t * g_pfs
Definition: task.c:26