Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
task.h
Go to the documentation of this file.
1 
11 #ifndef __TASK_H
12 #define __TASK_H
13 
14 /* -- Includes -- */
15 /* system libraries */
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <time.h>
20 /* project libraries */
21 #include "config.h"
22 #include "def.h"
23 #include "enviroment.h"
24 #include "serialport.h"
25 #include "openinterface.h"
26 #include "rfid.h"
27 #include "robot.h"
28 #include "pf.h"
29 #include "queue.h"
30 #include "protocol.h"
31 #include "udp.h"
32 #include "pheromone.h"
33 #include "timelib.h"
34 #include "doublylinkedlist.h"
35 #include "debug.h"
36 
37 /* -- Enumurations -- */
38 
39 /* -- Types -- */
40 
44 typedef struct s_TASK_STRUCT
45 {
46  int enabled;
47 
48 } task_t;
49 
53 typedef struct s_TASK_MISSION_STRUCT
54 {
55  // Victims
58 
59  // Stream
61  struct timeval stream_timer;
62 
63  // Go ahead
64  struct timeval go_ahead_timer;
65 
67 
71 typedef struct s_TASK_CONTROL_STRUCT
72 {
73  // OpenInterface request timer
74  struct timeval request_timer;
75 
77 
82 {
83  int event; // Boolean that notifies that victim id has been updated
84  char victim_id[11]; // ID of tag 10 chars + '\0'
85 
87 
92 {
93  int event; // Boolean that notifies that victim structure has been updated
94  victim_t victim; // Victim structure
95 
97 
102 {
103  int event; // Boolean that notifies that next move has been updated
104  int move; // Move
105 
107 
108 
109 
110 /* -- Constants -- */
111 #define s_TASK_EVENT_SET 1
112 #define s_TASK_EVENT_RESET 0
113 
114 /* Task IDs */
115 #define s_TASK_NOP_ID 0
116 #define s_TASK_MISSION_ID 1
117 #define s_TASK_NAVIGATE_ID 2
118 #define s_TASK_CONTROL_ID 3
119 #define s_TASK_REFINE_ID 4
120 #define s_TASK_REPORT_ID 5
121 #define s_TASK_COMMUNICATE_ID 6
122 #define s_TASK_AVOID_ID 7
123 
124 
125 /* -- Exported Variables -- */
126 
127 /* -- Global Variables -- */
128 
129 /* System structures */
130 extern enviroment_t *g_envs; // Enviroment definition
131 extern openinterface_t *g_ois; // Open Interface
132 extern rfid_t *g_rfids; // RFID Reader
133 extern pf_t *g_pfs; // Particle filter
134 extern robot_t *g_robot; // Estimated robot pose
135 extern pheromone_t *g_phs; // Pheromones
136 extern udp_t *g_udps; // UDP sockets connection
137 
138 /* Data lists */
139 extern doublylinkedlist_t *g_list_send; // Queue for data to be sent away (communication)
140 
141 /* Data queues */
142 extern queue_t *g_queue_mission; // Queue for data to mission task (commands, victims)
143 extern queue_t *g_queue_navigate; // Queue for data to navigate task (pheromones)
144 
145 /* Task structures */
146 extern task_t g_task_mission; // Control for the mission task
147 extern task_t g_task_navigate; // Control for the navigate task
148 extern task_t g_task_control; // Control for the control task
149 extern task_t g_task_refine; // Control for the refine task
150 extern task_t g_task_report; // Control for the report task
151 extern task_t g_task_communicate; // Control for the communicate task
152 extern task_t g_task_avoid; //Control for the collision detection task
153 extern task_t g_task_gen_data_stream; // Control for the video streaming task
154 
155 
156 /* Specific task related structure */
157 extern task_mission_t g_task_mission_data; // Structure that holds found victims and mission related things
158 extern task_control_t g_task_control_data; // Structure that holds control task related variables
159 
160 /* Task pipes */
161 extern taskpipe_refine_report_t g_tp_refine_report; // refine -> report
162 extern taskpipe_report_mission_t g_tp_report_mission; // report -> mission
163 extern taskpipe_navigate_control_t g_tp_navigate_control; // navigate -> control
164 
165 /* Communication information */
166 extern int g_message_sequence_id; // Massi thing
167 extern int g_tdma_slot; // Massi thing
168 
169 extern int g_go_ahead;
170 
171 /* -- Function Prototypes -- */
172 void task_init(int enable); // Initialize tasks
173 void task_destroy(void); // Deinitialize tasks
174 
175 /* Tasks */
176 void task_mission(void); // Control mission
177 void task_navigate(void); // Control navigation
178 void task_control(void); // Sense, control, localization
179 void task_avoid(void); // Check the bump sensors for collision
180 void task_refine(void); // Refine position, localization
181 void task_report(void); // Report victim
182 void task_communicate(void); // Communication (receive and send data)
183 
184 #endif /* __TASK_H */
void task_destroy(void)
Definition: task.c:162
queue_t * g_queue_navigate
Definition: task.c:36
Pheromone structure.
Definition: pheromone.h:27
struct s_TASKPIPE_REPORT_MISSION_STRUCT taskpipe_report_mission_t
Task pipe: report -&gt; mission.
int g_message_sequence_id
Definition: task.c:57
struct timeval request_timer
Definition: task.h:74
task_t g_task_communicate
Definition: task.c:44
int enabled
Definition: task.h:46
taskpipe_refine_report_t g_tp_refine_report
Definition: task.c:52
void task_control(void)
Definition: task_control.c:20
#define s_CONFIG_VICTIM_MAX_COUNT
Definition: config.h:87
robot_t * g_robot
Definition: task.c:27
void task_init(int enable)
Definition: task.c:69
int g_tdma_slot
Definition: task.c:58
Open Interface structure.
Particle filter structure.
Definition: pf.h:24
doublylinkedlist_t * g_list_send
Definition: task.c:32
UDP structure.
Definition: udp.h:28
task_t g_task_gen_data_stream
task_t g_task_report
Definition: task.c:43
Victim structure.
Definition: def.h:28
task_t g_task_control
Definition: task.c:41
struct s_TASKPIPE_NAVIGATE_CONTROL_STRUCT taskpipe_navigate_control_t
Task pipe: navigate -&gt; control.
taskpipe_report_mission_t g_tp_report_mission
Definition: task.c:53
taskpipe_navigate_control_t g_tp_navigate_control
Definition: task.c:54
void task_communicate(void)
struct s_TASKPIPE_REFINE_REPORT_STRUCT taskpipe_refine_report_t
Task pipe: refine -&gt; report.
struct s_TASK_CONTROL_STRUCT task_control_t
Task control structure.
rfid_t * g_rfids
Definition: task.c:25
task_t g_task_mission
Definition: task.c:39
int g_go_ahead
Definition: task.c:60
enviroment_t * g_envs
Definition: task.c:23
struct timeval go_ahead_timer
Definition: task.h:64
victim_t victims[s_CONFIG_VICTIM_MAX_COUNT]
Definition: task.h:57
udp_t * g_udps
Definition: task.c:29
task_mission_t g_task_mission_data
Definition: task.c:48
pheromone_t * g_phs
Definition: task.c:28
Robot structure.
Definition: robot.h:25
RFID structure.
Definition: rfid.h:24
queue_t * g_queue_mission
Definition: task.c:35
Doubly linked list structure.
openinterface_t * g_ois
Definition: task.c:24
Task pipe: navigate -&gt; control.
Definition: task.h:101
Queue structure.
Definition: queue.h:34
task_t g_task_refine
Definition: task.c:42
void task_navigate(void)
Definition: task_navigate.c:20
task_t g_task_avoid
Definition: task.c:45
struct timeval stream_timer
Definition: task.h:61
Task structure.
Definition: task.h:44
Task mission structure.
Definition: task.h:53
task_t g_task_navigate
Definition: task.c:40
Task pipe: report -&gt; mission.
Definition: task.h:91
void task_mission(void)
Definition: task_mission.c:20
void task_refine(void)
Definition: task_refine.c:20
void task_report(void)
Definition: task_report.c:20
task_control_t g_task_control_data
Definition: task.c:49
struct s_TASK_STRUCT task_t
Task structure.
pf_t * g_pfs
Definition: task.c:26
Task pipe: refine -&gt; report.
Definition: task.h:81
Task control structure.
Definition: task.h:71
long stream_counter
Definition: task.h:60
void task_avoid(void)
Definition: task_avoid.c:20
struct s_TASK_MISSION_STRUCT task_mission_t
Task mission structure.
Enviroment Structure - room points, tags, room point number, tag number.
Definition: enviroment.h:49