Project

General

Profile

Revision 1500

Commented the template file and my implementation of Hunter-Prey to make the code easier to follow.

View differences:

main.c
1
/*
2
 * template.c - A starting point for developing behaviors using the Colony
3
 * 		robots. To create a new behavior, you should copy this "template"
4
 * 		folder to another folder and rename the "template.c" file
5
 * 		appropriately.
6
 *
7
 * This template will have the robot drive in circles and flash the orbs.
8
 *
9
 * Author: John Sexton, Colony Project, CMU Robotics Club
10
 */
11

  
1 12
#include <dragonfly_lib.h>
2 13
#include <wl_basic.h>
3 14

  
15
/* Time delay which determines how long the robot circles before it
16
 * changes direction. */
4 17
#define TIME_DELAY 5000
5 18

  
6 19
int main (void) {
7 20

  
21
	/* Initialize the dragonfly boards, the xbee, and the encoders */
8 22
	dragonfly_init(ALL_ON);
9 23
	xbee_init();
10 24
	encoders_init();
11 25
	
12 26
	while (1) {
27
		/* Drive left, set orbs, and wait */
13 28
		orbs_set_color(RED, GREEN);
14 29
		motor_l_set(FORWARD, 160);
15 30
		motor_r_set(FORWARD, 255);
16 31
		delay_ms(TIME_DELAY);
17 32

  
33
		/* Drive right, change orb colors, and wait */
18 34
		orbs_set_color(PURPLE, BLUE);
19 35
		motor_l_set(FORWARD, 255);
20 36
		motor_r_set(FORWARD, 160);

Also available in: Unified diff