Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
task_avoid.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_avoid(void)
21 {
23  {
24  // Update Bump sensor
25 #ifndef s_CONFIG_TEST_ENABLE
27 #endif
28 
29  // Check collision
30  if(g_ois->oiss->wheeldrop_bump > 0)
31  {
32  debug_printf("Collision\n");
33  }
34 
35  // Choose direction of rotation depending on the side it hit
36  // Right Bump
37  if(g_ois->oiss->wheeldrop_bump == 1)
38  {
40  return;
41  }
42  // Left Bump
43  else if(g_ois->oiss->wheeldrop_bump == 2)
44  {
46  return;
47  }
48  // Center Bump
49  else if(g_ois->oiss->wheeldrop_bump == 3)
50  {
51  if((rand() % 10) > 5)
53  else
55 
56  return;
57  }
58  }
59 }
void debug_printf(const char *format,...)
Definition: debug.c:25
int enabled
Definition: task.h:46
config_t g_config
Definition: config.c:22
openinterface_sensor_t * oiss
#define s_OI_SENSOR_PACKET_1_SIZE
int robot_speed
Definition: config.h:50
int openinterface_drive(openinterface_t *ois, int velocity, int radius)
openinterface_t * g_ois
Definition: task.c:24
int openinterface_sensors_update(openinterface_t *ois, const unsigned int sensor_id, const unsigned int size)
task_t g_task_avoid
Definition: task.c:45
#define s_TRUE
Definition: def.h:60
#define s_OI_SENSOR_PACKET_1
void task_avoid(void)
Definition: task_avoid.c:20