root / trunk / code / projects / mapping / matlab / testRobot / test.c @ 953
History | View | Annotate | Download (1.47 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wireless.h> |
3 |
#include <encoders.h> |
4 |
|
5 |
#define MAP_RECEIVE_GROUP 1 |
6 |
#define MAP_REQUEST_GROUP 2 |
7 |
|
8 |
#define POINT_RAW 1 // packet type for map data points w/ raw encoder data |
9 |
#define POINT_ODO 2 // packet type for map data points w/ odometry data |
10 |
|
11 |
#define WL_CNTL_GROUP 4 |
12 |
|
13 |
int state;
|
14 |
int velocity;
|
15 |
char buf[100]; |
16 |
|
17 |
void respond(char type, int source, unsigned char* packet, int length); |
18 |
|
19 |
PacketGroupHandler receiveHandler = {MAP_REQUEST_GROUP, |
20 |
NULL, NULL, NULL, NULL}; |
21 |
|
22 |
PacketGroupHandler requestHandler = {MAP_RECEIVE_GROUP, |
23 |
NULL, NULL, respond, NULL}; |
24 |
|
25 |
int main(void) |
26 |
{ |
27 |
/* initialize components and join the token ring */
|
28 |
dragonfly_init(ALL_ON); |
29 |
odometry_init(); |
30 |
|
31 |
wl_init(); |
32 |
wl_set_channel(0xE);
|
33 |
wl_register_packet_group(&receiveHandler); |
34 |
wl_register_packet_group(&requestHandler); |
35 |
|
36 |
wl_token_ring_register(); |
37 |
wl_token_ring_join(); |
38 |
|
39 |
char *send; // for transmission |
40 |
|
41 |
while(1) |
42 |
{ |
43 |
wl_do(); |
44 |
} |
45 |
|
46 |
wl_terminate(); |
47 |
return 0; |
48 |
} |
49 |
|
50 |
void respond(char type, int source, unsigned char* packet, int length) { |
51 |
sprintf(buf, "received packet: %d\n", type);
|
52 |
usb_puts(buf); |
53 |
|
54 |
int store[9]; |
55 |
store[0] = 0; |
56 |
store[1] = 0; |
57 |
*((double*)(store + 2)) = 5.0; |
58 |
store[4] = 125; // IR1 range |
59 |
store[5] = 125; // IR2 range |
60 |
store[6] = 125; // IR3 range |
61 |
store[7] = 125; // IR4 range |
62 |
store[8] = 125; // IR5 range |
63 |
|
64 |
wl_send_robot_to_robot_global_packet(MAP_RECEIVE_GROUP, |
65 |
POINT_ODO, &store, 0, source, 0); |
66 |
|
67 |
} |