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