Revision 1028
Changes all around. Matlab server is now passive, might work soon.
test.c | ||
---|---|---|
4 | 4 |
|
5 | 5 |
#include <dragonfly_lib.h> |
6 | 6 |
#include <wireless.h> |
7 |
#include <wl_token_ring.h> |
|
7 | 8 |
#include <encoders.h> |
9 |
#include <bom.h> |
|
8 | 10 |
#include "odometry.h" |
9 | 11 |
|
10 | 12 |
#define MAP_REQUEST_GROUP 23 |
11 | 13 |
|
14 |
#define DATA_INIT 4 |
|
12 | 15 |
#define DATA_POINT 2 |
13 | 16 |
#define DATA_REQUEST 3 |
14 | 17 |
|
18 |
#define WL_CHANNEL = 0xE |
|
19 |
|
|
15 | 20 |
int state; |
16 | 21 |
int velocity; |
22 |
int server = -1; |
|
17 | 23 |
char buf[100]; |
18 | 24 |
|
19 | 25 |
void respond(char type, int source, unsigned char* packet, int length); |
26 |
void transmit(void); |
|
20 | 27 |
|
21 | 28 |
PacketGroupHandler requestHandler = {MAP_REQUEST_GROUP, |
22 | 29 |
NULL, NULL, respond, NULL}; |
... | ... | |
24 | 31 |
int main(void) |
25 | 32 |
{ |
26 | 33 |
/* initialize components and join the token ring */ |
27 |
dragonfly_init(ORB | RANGE | BOM | COMM);
|
|
34 |
dragonfly_init(RANGE | BOM | COMM); |
|
28 | 35 |
odometry_init(); |
29 | 36 |
|
30 | 37 |
wl_init(); |
31 |
wl_set_channel(0xE);
|
|
38 |
wl_set_channel(WL_CHANNEL);
|
|
32 | 39 |
wl_register_packet_group(&requestHandler); |
33 | 40 |
|
34 | 41 |
wl_token_ring_register(); |
42 |
wl_token_ring_set_bom_functions(transmit, bom_off, get_max_bom); |
|
35 | 43 |
wl_token_ring_join(); |
36 | 44 |
|
37 | 45 |
while(1) |
... | ... | |
58 | 66 |
store[7] = 125; // IR4 range |
59 | 67 |
store[8] = 125; // IR5 range |
60 | 68 |
|
69 |
char* data = (char*)store; |
|
70 |
|
|
61 | 71 |
wl_send_robot_to_robot_global_packet(MAP_REQUEST_GROUP, |
62 |
DATA_POINT, &store, 0, source, 0);
|
|
72 |
DATA_POINT, data, 18, source, 0);
|
|
63 | 73 |
} |
74 |
else if(type==DATA_INIT){ |
|
75 |
server = source; |
|
76 |
} |
|
64 | 77 |
} |
65 | 78 |
|
79 |
void transmit(){ |
|
80 |
bom_on(); |
|
66 | 81 |
|
82 |
/*If a server hasn't declared itself, return.*/ |
|
83 |
if(server == -1) return; |
|
84 |
|
|
85 |
int store[9]; |
|
86 |
store[0] = 0; //X |
|
87 |
store[1] = 0; //Y |
|
88 |
*((double*)(store + 2)) = 5.0; //Theta. |
|
89 |
store[4] = 125; // IR1 range |
|
90 |
store[5] = 125; // IR2 range |
|
91 |
store[6] = 125; // IR3 range |
|
92 |
store[7] = 125; // IR4 range |
|
93 |
store[8] = 125; // IR5 range |
|
94 |
|
|
95 |
char* data = (char*)store; |
|
96 |
|
|
97 |
wl_send_robot_to_robot_global_packet(MAP_REQUEST_GROUP, |
|
98 |
DATA_POINT, data, 18, server, 0); |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
|
Also available in: Unified diff