Revision 1806
Made some slight upgrades to cicle.c, cincluding formatting.
trunk/code/behaviors/formation_control/circle/circle.c | ||
---|---|---|
1 | 1 |
|
2 | 2 |
/*** PROGRAM INFORMATION *** |
3 | 3 |
|
4 |
This program assembles a group of robots into a circle and allows them movement |
|
5 |
within that formation. Robots should be able to break formation and travel as a |
|
6 |
line, readjust in the face of obstacles, and reform if conditions are necessary. |
|
4 |
This program assembles a group of robots into a circle and allows the |
|
5 |
movement within that formation. Robots should be able to break formation and |
|
6 |
travel as a line, readjust in the face of obstacles, and reform if conditions |
|
7 |
are necessary. |
|
7 | 8 |
|
8 |
The program begins waiting for a button press. When pressed, a robot assumes the |
|
9 |
BEACON position, which means that it is the robot in the center of the circle and |
|
10 |
therefore in charge. It then gathers robots around it by sending them commands. |
|
11 |
This code is executed using two finite state machines, nested inside one another. |
|
12 |
One controls the overall state of the robot (whether it is a BEACON, an EDGE, or |
|
13 |
WAITING, for example). |
|
9 |
The program begins waiting for a button press. When pressed, a robot assumes |
|
10 |
the BEACON position, which means that it is the robot in the center of the |
|
11 |
circle and therefore in charge. It then gathers robots around it by sending |
|
12 |
them commands. This code is executed using two finite state machines, nested |
|
13 |
inside one another. |
|
14 |
One controls the overall state of the robot (whether it is a BEACON, an EDGE, |
|
15 |
or WAITING, for example). |
|
14 | 16 |
|
15 |
This code should be implemented so that most useful functions are built in to the
|
|
16 |
machine. For example, the BEACON robot should be able to call methods such as
|
|
17 |
CircleUp() to gather robots around it, and Move(distance) to move the circle group
|
|
18 |
all at once.
|
|
17 |
This code should be implemented so that most useful functions are built in
|
|
18 |
to the machine. For example, the BEACON robot should be able to call methods
|
|
19 |
such as CircleUp() to gather robots around it, and Move(distance) to move the
|
|
20 |
circle group all at once.
|
|
19 | 21 |
|
20 |
This Code is the property of the Carnegie Mellon Robotics Club and is being used |
|
21 |
to test formation control in a low-cost robot colony. Thanks to all members of |
|
22 |
RoboClub, especially Colony president John Sexton and the ever-present Chris Mar. |
|
22 |
This Code is the property of the Carnegie Mellon Robotics Club and is being |
|
23 |
used to test formation control in a low-cost robot colony. Thanks to all |
|
24 |
members of RoboClub, especially Colony president John Sexton and graduade |
|
25 |
student representative Chris Mar. |
|
23 | 26 |
|
24 |
AUTHORS: James Carroll, Steve DeVincentis, Hanzhang (Echo) Hu, Nico Paris, Joel Rey,
|
|
25 |
Reva Street, Alex Zirbel */
|
|
27 |
AUTHORS: James Carroll, Steve DeVincentis, Hanzhang (Echo) Hu, Nico Paris,
|
|
28 |
Joel Rey, Reva Street, Alex Zirbel */
|
|
26 | 29 |
|
27 | 30 |
|
28 | 31 |
#include <dragonfly_lib.h> |
... | ... | |
32 | 35 |
|
33 | 36 |
/*** TODO: *** |
34 | 37 |
|
35 |
- Transform the code into a method-based state machine that uses the procedural state |
|
36 |
machines, which are hardcoded and hard to edit, as a backup. |
|
37 |
- Implement a drive straight method for use in keeping the robots more accurate as a |
|
38 |
group. |
|
39 |
- Fix the approach method: good robots usually work well, but bad robots often have |
|
40 |
errors which might be avoidable with the use of error checking. |
|
41 |
- Make robots more robust: packages are often lost, which throws the entire procedural |
|
42 |
nature of the program off. |
|
43 |
- Consider using the center bot to check distances |
|
44 |
- More testing is always good and necessary. */ |
|
38 |
-Transform the code into a method-based state machine that uses the |
|
39 |
procedural state machines, which are hardcoded and hard to edit, as a backup. |
|
45 | 40 |
|
41 |
-Implement a drive straight method for use in keeping the robots more |
|
42 |
accurate as a group. |
|
43 |
|
|
44 |
-Fix the approach method: good robots usually work well, but bad robots often |
|
45 |
have errors which might be avoidable with the use of error checking. |
|
46 |
|
|
47 |
-Make robots more robust: packages are often lost, which throws the entire |
|
48 |
procedural nature of the program off. |
|
49 |
|
|
50 |
-Consider using the center bot to check distances |
|
51 |
|
|
52 |
-More testing is always good and necessary. */ |
|
53 |
|
|
46 | 54 |
/*** BOT LOG *** |
47 | 55 |
|
48 |
4-1-2010: BOT 7 as BEACON and BOT 1 as EDGE worked extremely well.
|
|
49 |
4-2-2010: BOT 7 and BOT 14 worked extremely well, no matter states. BOT 1 started
|
|
50 |
well, but malfunctioned later. */
|
|
56 |
4-1-2010: BOT 7 as BEACON and BOT 1 as EDGE worked extremely well.
|
|
57 |
4-2-2010: BOT 7 and BOT 14 worked extremely well, no matter states. BOT 1
|
|
58 |
started well, but malfunctioned later. */
|
|
51 | 59 |
|
52 | 60 |
/*** TERMINOLOGY *** |
53 | 61 |
|
54 | 62 |
WAITINGSTATE: |
55 |
The robot waits to be given a signal to do something. Wireless is on, in
|
|
63 |
The robot waits to be given a signal to do something. Wireless is on, in |
|
56 | 64 |
case the robot is called on to turn into an EDGE. The color should be LIME |
57 | 65 |
or YELLOW-GREEN. |
58 | 66 |
|
... | ... | |
141 | 149 |
motor_r_set(FORWARD,speed); |
142 | 150 |
} |
143 | 151 |
void left(int speed){ // turn left at this speed. |
152 |
motor_l_set(BACKWARD,speed); |
|
153 |
motor_r_set(FORWARD,speed); |
|
154 |
} |
|
155 |
void right(int speed){ |
|
144 | 156 |
motor_l_set(FORWARD,speed); |
145 | 157 |
motor_r_set(BACKWARD,speed); |
146 | 158 |
} |
147 |
void right(int speed){ |
|
148 |
motor_l_set(BACKWARD,speed); |
|
149 |
motor_r_set(FORWARD,speed); |
|
150 |
} |
|
151 | 159 |
void stop(void){ // could be set to motors_off(), or just use this as an alternative. |
152 | 160 |
motor_l_set(BACKWARD,0); // stop() is better - motors_off() creates a slight delay to turn them back on. |
153 | 161 |
motor_r_set(FORWARD,0); |
Also available in: Unified diff