root / scout_avr / src / main.cpp @ ec9e417d
History | View | Annotate | Download (1.14 KB)
1 |
#include "ros.h" |
---|---|
2 |
#include <std_msgs/Int16.h> |
3 |
|
4 |
ros::Publisher *ptest_out; |
5 |
|
6 |
void callback(const std_msgs::Int16& msg) |
7 |
{ |
8 |
ptest_out->publish(&msg); |
9 |
} |
10 |
|
11 |
int main()
|
12 |
{ |
13 |
ros::NodeHandle nh; |
14 |
std_msgs::Int16 msg; |
15 |
ros::Subscriber<std_msgs::Int16> test_in("test_in", callback);
|
16 |
ros::Publisher test_out("test_out", &msg);
|
17 |
|
18 |
ptest_out = &test_out; |
19 |
|
20 |
msg.data = 0;
|
21 |
nh.initNode(); |
22 |
nh.subscribe(test_in); |
23 |
nh.advertise(test_out); |
24 |
|
25 |
while (1) |
26 |
{ |
27 |
nh.spinOnce(); |
28 |
} |
29 |
|
30 |
return 0; |
31 |
} |
32 |
|
33 |
/*extern "C"
|
34 |
{
|
35 |
#include <stdlib.h>
|
36 |
#include <string.h>
|
37 |
}
|
38 |
|
39 |
#include "Atmega128rfa1.h"
|
40 |
#include "range.h"
|
41 |
|
42 |
int main()
|
43 |
{
|
44 |
char buf[20];
|
45 |
int data;
|
46 |
unsigned long now, next = 0;
|
47 |
Atmega128rfa1 avr;
|
48 |
avr.init();
|
49 |
range_init();
|
50 |
while (1)
|
51 |
{
|
52 |
now = avr.time();
|
53 |
if (now > next) {
|
54 |
next = now + 100;
|
55 |
utoa(range_get(0), buf, 10);
|
56 |
avr.write((uint8_t*) buf, strlen(buf));
|
57 |
/*data = avr.read();
|
58 |
if (data >= 0)
|
59 |
{
|
60 |
uint8_t data8 = data;
|
61 |
avr.write((uint8_t*) "Received ", 9);
|
62 |
avr.write(&data8, 1);
|
63 |
}
|
64 |
else
|
65 |
avr.write((uint8_t*) ".", 1);*//* |
66 |
avr.write((uint8_t*) "\r\n", 2);
|
67 |
}
|
68 |
}
|
69 |
return 0;
|
70 |
}
|
71 |
*/
|