root / scout_avr / src / main.cpp @ 31f4a032
History | View | Annotate | Download (1.79 KB)
1 | 807483bf | Tom Mullins | #if 0 ///////////////////////////////////////////////
|
---|---|---|---|
2 | |||
3 | 49090532 | Tom Mullins | #include "ros.h"
|
4 | cf115e3d | Tom Mullins | #include <std_msgs/Int16.h>
|
5 | 88fb3a79 | Tom Mullins | |
6 | 49090532 | Tom Mullins | ros::Publisher *ptest_out;
|
7 | |||
8 | 31f4a032 | Tom Mullins | void debug(const char *str) {
|
9 | }
|
||
10 | |||
11 | cf115e3d | Tom Mullins | void callback(const std_msgs::Int16& msg)
|
12 | 49090532 | Tom Mullins | {
|
13 | ptest_out->publish(&msg);
|
||
14 | }
|
||
15 | |||
16 | int main()
|
||
17 | 88fb3a79 | Tom Mullins | {
|
18 | ros::NodeHandle nh;
|
||
19 | cf115e3d | Tom Mullins | std_msgs::Int16 msg;
|
20 | ros::Subscriber<std_msgs::Int16> test_in("test_in", callback);
|
||
21 | 49090532 | Tom Mullins | ros::Publisher test_out("test_out", &msg);
|
22 | |||
23 | ptest_out = &test_out;
|
||
24 | 88fb3a79 | Tom Mullins | |
25 | 49090532 | Tom Mullins | msg.data = 0;
|
26 | 88fb3a79 | Tom Mullins | nh.initNode();
|
27 | 49090532 | Tom Mullins | nh.subscribe(test_in);
|
28 | nh.advertise(test_out);
|
||
29 | 88fb3a79 | Tom Mullins | |
30 | while (1)
|
||
31 | {
|
||
32 | nh.spinOnce();
|
||
33 | }
|
||
34 | |||
35 | return 0;
|
||
36 | 49090532 | Tom Mullins | }
|
37 | 88fb3a79 | Tom Mullins | |
38 | 807483bf | Tom Mullins | #else ///////////////////////////////////////////////
|
39 | |||
40 | extern "C" |
||
41 | 88fb3a79 | Tom Mullins | { |
42 | #include <stdlib.h> |
||
43 | #include <string.h> |
||
44 | } |
||
45 | |||
46 | 49090532 | Tom Mullins | #include "Atmega128rfa1.h" |
47 | 1c3c96ce | Tom Mullins | #include "range.h" |
48 | f115416e | Tom Mullins | #include "bom.h" |
49 | 49090532 | Tom Mullins | |
50 | 31f4a032 | Tom Mullins | Atmega128rfa1 avr; |
51 | |||
52 | void debug(const char *str) { |
||
53 | avr.puts(str); |
||
54 | } |
||
55 | |||
56 | 88fb3a79 | Tom Mullins | int main()
|
57 | { |
||
58 | 1c3c96ce | Tom Mullins | char buf[20]; |
59 | f115416e | Tom Mullins | int i;
|
60 | 31f4a032 | Tom Mullins | char id = 0; |
61 | cf115e3d | Tom Mullins | unsigned long now, next = 0; |
62 | 88fb3a79 | Tom Mullins | avr.init(); |
63 | 1c3c96ce | Tom Mullins | range_init(); |
64 | f115416e | Tom Mullins | bom_init(); |
65 | 31f4a032 | Tom Mullins | avr.puts("Hello!\r\n");
|
66 | 88fb3a79 | Tom Mullins | while (1) |
67 | { |
||
68 | 49090532 | Tom Mullins | now = avr.time(); |
69 | if (now > next) {
|
||
70 | 1c3c96ce | Tom Mullins | next = now + 100;
|
71 | 31f4a032 | Tom Mullins | id++; |
72 | if (id == 0x40) { |
||
73 | id = 0;
|
||
74 | } |
||
75 | set_robot_id(id); |
||
76 | f115416e | Tom Mullins | /*utoa(range_get(0), buf, 10);
|
77 | avr.puts("Range: ");
|
||
78 | avr.puts(buf);
|
||
79 | avr.puts(", ");
|
||
80 | 807483bf | Tom Mullins | utoa(range_get(1), buf, 10);
|
81 | f115416e | Tom Mullins | avr.puts(buf);*/
|
82 | for (i = 0; i < 4; i++) { |
||
83 | bom_send(i); |
||
84 | int msg = bom_get(i);
|
||
85 | if (msg != BOM_NO_DATA) {
|
||
86 | avr.puts("BOM ");
|
||
87 | itoa(i, buf, 10);
|
||
88 | avr.puts(buf); |
||
89 | avr.puts(": ");
|
||
90 | 31f4a032 | Tom Mullins | itoa(bom_msg_get_robot_id(msg), buf, 10);
|
91 | avr.puts(buf); |
||
92 | avr.puts(" (");
|
||
93 | itoa(bom_msg_get_dir(msg), buf, 10);
|
||
94 | f115416e | Tom Mullins | avr.puts(buf); |
95 | 31f4a032 | Tom Mullins | avr.puts(")\r\n");
|
96 | f115416e | Tom Mullins | } |
97 | cf115e3d | Tom Mullins | } |
98 | 49090532 | Tom Mullins | } |
99 | 88fb3a79 | Tom Mullins | } |
100 | return 0; |
||
101 | cf115e3d | Tom Mullins | } |
102 | 807483bf | Tom Mullins | |
103 | #endif ////////////////////////////////////////////// |