Project

General

Profile

Revision 1469

Tried to get it to work to no avail. Various small changes.

View differences:

trunk/code/projects/hunter_prey/abenico/main.c
4 4
#include "smart_run_around_fsm.h"
5 5
#include "hunter_prey.h"
6 6

  
7
#define CHAN 0xF
7
#define CHAN 0xC
8 8
#define ACK_PAUSE 5000
9 9

  
10 10
#define ROBOT_HUNTER 0
......
82 82

  
83 83
  id = get_robotid();
84 84
  packet[1] = id;
85
  usb_puts("hello, I am robot \n");
85
  usb_puts("hello, I am robot ");
86 86
  usb_puti(id);
87 87
  usb_putc('\n');
88 88

  
......
94 94

  
95 95
  run_around_init();
96 96

  
97
  usb_puts("channel\n");
97
  usb_puts("channel");
98 98

  
99 99
  //use a specific channel to avoid interfering with other tasks
100 100
  wl_set_channel(CHAN);
101 101
  usb_puti(CHAN);
102 102

  
103
  usb_puts("orb set\n");
103
  usb_puts("\norb set");
104 104

  
105 105
  // initially in hunter state
106 106
  robotState = ROBOT_HUNTER;
......
116 116

  
117 117
    if(robotState==ROBOT_TAGGED) {
118 118
      usb_puts("tagged, waiting to send ACK\n");
119
      orb_set_color(YELLOW);
119 120
      //delay_ms(TAG_PAUSE);
120 121
      move(0,0);
121 122
      usb_puts("sending ACK to ");
......
160 161
	    packet[0] = HUNTER_PREY_ACTION_TAG;
161 162
	    packet[1] = id;
162 163
	    wl_basic_send_global_packet (42, &packet, 2);
164
	    wl_do();
163 165
	    rtc_reset();
164 166
	}
165 167
    }
......
177 179

  
178 180
  if(length>=2){
179 181
    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
182
	usb_puts("received a tag packet\n");
180 183
      if(robotState == ROBOT_PREY) {
184
	  usb_puts("it was for me\n");
181 185
	robotState = ROBOT_TAGGED;
182 186
	bom_off();
183 187
	tagger = packet[1];
......
186 190
	usb_puts("tagged, but I'm not it!\n");
187 191
      }
188 192
    }
189
    else if(packet[0] == HUNTER_PREY_ACTION_ACK && robotState == ROBOT_HUNTER) {
193
    else if(packet[0] == HUNTER_PREY_ACTION_ACK) {
190 194
      robotState = ROBOT_IDLE;
191 195
    }
192 196
    usb_puts("got '");
trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.c
3 3

  
4 4
void run_around_init(void)
5 5
{
6
  range_init();
7
  orb_init();
6
  //range_init();
7
  //orb_init();
8 8
 
9 9
  state = SRA_FORWARD;  // start out moving forward
10 10
  // initialize rangefinder values to 0
......
86 86
    switch (state)
87 87
    {
88 88
	case SRA_FORWARD:
89
	    orb_set_color(GREEN);
89
	    //orb_set_color(GREEN);
90 90
	    move(220, 0);	// drive straight forward
91 91
	    break;
92 92
	case SRA_LEFT:
93
	    orbs_set_color(GREEN, YELLOW);  // green on left side
93
	    //orbs_set_color(GREEN, YELLOW);  // green on left side
94 94
	    move(HALF_SPD, NRML_TURN);	// drive forward and to the left
95 95
	    break;
96 96
	case SRA_RIGHT:
97
	    orbs_set_color(YELLOW, GREEN);  // green on right side
97
	    //orbs_set_color(YELLOW, GREEN);  // green on right side
98 98
	    move(HALF_SPD, -NRML_TURN);	// drive forward and to the right
99 99
	    break;
100 100
	case SRA_SPIN:
101
	    orb_set_color(RED);
101
	    //orb_set_color(RED);
102 102
	    move(0, NRML_TURN);	// spin CCW without traveling
103 103
	    break;
104 104
	default:    // should never reach this
105
	    orb_set_color(PURPLE);
105
	    //orb_set_color(PURPLE);
106 106
	    move(0, 0);	// stop completely
107 107
    }
108 108
}

Also available in: Unified diff