Project

General

Profile

Revision 1409

Added by Brad Neuman over 13 years ago

Changed BOM threshold to 120, seems to be helping for some robot and causing problems for others
hunter-prey is done except the hunting part

View differences:

main.c
20 20
volatile uint8_t tagger;
21 21
uint8_t id;
22 22

  
23
void test_bom() {
24
  int i;
25
  int val;
26

  
27
  while(1) {
28
    bom_refresh(BOM_ALL);
29

  
30
    for(i=0; i<16; i++) {
31
      val = bom_get(i);
32
      usb_puti(val);
33
      usb_putc(' ');
34
    }
35

  
36
    usb_putc('\n');
37
    delay_ms(500);
38
  }
39

  
40
}
41

  
23 42
int main(void) {
24 43

  
25 44
  int frontRange;
......
27 46
  uint8_t i;
28 47
  int onTarget = 0;
29 48
  char packet[2];
49
  uint8_t bom = 0;
30 50
  
31 51
  //intialize the robot and wireless
32 52
  dragonfly_init(ALL_ON);
33 53

  
54
  //test_bom();
55

  
34 56
  id = get_robotid();
35 57
  packet[1] = id;
36 58
  usb_puts("hello, I am robot \n");
......
45 67

  
46 68
  run_around_init();
47 69

  
48
  //  bom_init(BOM15);
49

  
50 70
  usb_puts("channel\n");
51 71

  
52 72
  //use a specific channel to avoid interfering with other tasks
......
60 80
  //if button 2 is held, you are prey
61 81
  if(button2_read()) {
62 82
    robotState = ROBOT_PREY;
83
    bom_on();
63 84
  }
64 85

  
65 86

  
......
86 107

  
87 108
    else { //ROBOT_HUNTER
88 109

  
89
      //    bom_refresh(BOM_ALL);
110
      bom_refresh(BOM_ALL);
90 111

  
91 112
      frontRange = range_read_distance (IR2);
92 113

  
93
/*       usb_puti(frontRange); */
94
/*       usb_putc('\n'); */
114
      usb_puti(frontRange);
115
      usb_putc(',');
95 116

  
96 117
      //BUG: when get_max_bom is called, the rangefinder seems to stop
97 118
      //working
98
      //angle = get_max_bom();
99
      angle = 4;
119
      angle = bom_get_max();
120
      usb_puti(angle);
121
      usb_putc('\n');
100 122

  
101 123
      if(angle == 4 && frontRange > 0 && frontRange < TAG_RANGE) {
102 124
	if(onTarget == 0) {
......
124 146
	      usb_puts("ACK!\n");
125 147
	      //	      delay_ms(TAG_PAUSE);
126 148
	      robotState = ROBOT_PREY;
149
	      bom_on();
127 150
	    }
128 151
	    else {
129 152
	      usb_puts("ACK failed!\n");
......
156 179
    if(packet[0] == 'T') {
157 180
      if(robotState == ROBOT_PREY) {
158 181
	robotState = ROBOT_TAGGED;
182
	bom_off();
159 183
	color = BLUE;
160 184
	orb_set_color(BLUE);
161 185
	tagger = packet[1];

Also available in: Unified diff