root / scout_avr / src / main.cpp @ 49090532
History | View | Annotate | Download (903 Bytes)
1 |
#include "ros.h" |
---|---|
2 |
#include <std_msgs/UInt16.h> |
3 |
|
4 |
ros::Publisher *ptest_out; |
5 |
|
6 |
void callback(const std_msgs::UInt16& msg) |
7 |
{ |
8 |
ptest_out->publish(&msg); |
9 |
} |
10 |
|
11 |
int main()
|
12 |
{ |
13 |
ros::NodeHandle nh; |
14 |
std_msgs::UInt16 msg; |
15 |
ros::Subscriber<std_msgs::UInt16> 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 |
|
41 |
int main()
|
42 |
{
|
43 |
char time[20];
|
44 |
Atmega128rfa1 avr;
|
45 |
avr.init();
|
46 |
unsigned long now, next = 0;
|
47 |
while (1)
|
48 |
{
|
49 |
now = avr.time();
|
50 |
if (now > next) {
|
51 |
next = now + 100;
|
52 |
ultoa(avr.time(), time, 10);
|
53 |
avr.write((uint8_t*) time, strlen(time));
|
54 |
avr.write((uint8_t*) "\n\r", 1);
|
55 |
}
|
56 |
}
|
57 |
return 0;
|
58 |
}*/
|
59 |
|