Revision 759
fiddled with run around, filmed some demos. i have yet to make videos...i need to look that up
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/departing.c | ||
---|---|---|
33 | 33 |
{ |
34 | 34 |
int front_distance = range_read_distance(IR2); |
35 | 35 |
|
36 |
if(front_distance != -1 && front_distance < 160)
|
|
36 |
if(front_distance != -1 && front_distance < 200)
|
|
37 | 37 |
leave_station_count++; |
38 | 38 |
else |
39 | 39 |
leave_station_count = 0; |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/smart_run_around_fsm.c | ||
---|---|---|
24 | 24 |
/*Initialize distances to zero.*/ |
25 | 25 |
d1=0; d2=0; d3=0; d4=0; d5=0; |
26 | 26 |
|
27 |
orb_set_color(CYAN);
|
|
27 |
orb_set_color(BLUE);
|
|
28 | 28 |
|
29 | 29 |
} |
30 | 30 |
|
... | ... | |
67 | 67 |
|
68 | 68 |
//Checks the forward distance to see if it should back up, if so...state backwards. |
69 | 69 |
if((d2!=-1)&&(d2 < 150)){ |
70 |
if(prev_state == MOVING) { |
|
71 |
delay_motors(); |
|
72 |
} |
|
73 | 70 |
backup_count=BACKUP_MAX; |
74 | 71 |
avoid_state=BACKWARDS; |
75 | 72 |
evaluate_state(); |
... | ... | |
85 | 82 |
return; |
86 | 83 |
} |
87 | 84 |
|
88 |
if(prev_state == BACKWARDS) { |
|
89 |
delay_motors(); |
|
90 |
} |
|
91 | 85 |
//usb_puts("avoid_state set to MOVING\n\r"); |
92 | 86 |
avoid_state = MOVING; |
93 | 87 |
|
... | ... | |
121 | 115 |
void evaluate_state(){ |
122 | 116 |
switch(avoid_state){ |
123 | 117 |
case(MOVING): //orb_set_color(GREEN); |
118 |
if(prev_state == BACKWARDS) { |
|
119 |
delay_motors(); |
|
120 |
} |
|
124 | 121 |
move(STRAIT_SPEED,-pControl); |
125 | 122 |
//motor1_set(FORWARD,200); |
126 | 123 |
//motor2_set(FORWARD,200); |
127 | 124 |
break; |
128 | 125 |
|
129 | 126 |
case(BACKWARDS): //orb_set_color(RED); |
127 |
if(prev_state == MOVING) { |
|
128 |
delay_motors(); |
|
129 |
} |
|
130 | 130 |
move(-STRAIT_SPEED-50,0); |
131 | 131 |
//motor1_set(BACKWARD,200); |
132 | 132 |
//motor2_set(BACKWARD,200); |
... | ... | |
134 | 134 |
|
135 | 135 |
case(CRAZY): //orb_set_color(RED); |
136 | 136 |
/*TODO: Implement a crazy state.*/ |
137 |
if(prev_state == BACKWARDS) { |
|
138 |
delay_motors(); |
|
139 |
} |
|
137 | 140 |
move(STRAIT_SPEED,-pControl); |
138 | 141 |
break; |
139 | 142 |
|
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/smart_run_around_fsm.h | ||
---|---|---|
15 | 15 |
|
16 | 16 |
#define BACKUP_MAX 60 |
17 | 17 |
#define CRAZY_MAX 200 //The number of counts between "crazy moments" |
18 |
#define STRAIT_SPEED 175 //The speed when going strait or backing up.
|
|
18 |
#define STRAIT_SPEED 162 //The speed when going strait or backing up.
|
|
19 | 19 |
#define TURN_CONSTANT 5 |
20 | 20 |
#define PCONTROL_CRAZY_LIMIT 80 |
21 | 21 |
|
Also available in: Unified diff