root / scout_avr / src / main.cpp @ cf115e3d
History | View | Annotate | Download (1.11 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 |
|
41 |
int main()
|
42 |
{
|
43 |
char time[20];
|
44 |
int data;
|
45 |
unsigned long now, next = 0;
|
46 |
Atmega128rfa1 avr;
|
47 |
avr.init();
|
48 |
while (1)
|
49 |
{
|
50 |
now = avr.time();
|
51 |
if (now > next) {
|
52 |
next = now + 500;
|
53 |
//ultoa(avr.time(), time, 10);
|
54 |
//avr.write((uint8_t*) time, strlen(time));
|
55 |
data = avr.read();
|
56 |
if (data >= 0)
|
57 |
{
|
58 |
uint8_t data8 = data;
|
59 |
avr.write((uint8_t*) "Received ", 9);
|
60 |
avr.write(&data8, 1);
|
61 |
}
|
62 |
else
|
63 |
avr.write((uint8_t*) ".", 1);
|
64 |
avr.write((uint8_t*) "\n\r", 1);
|
65 |
}
|
66 |
}
|
67 |
return 0;
|
68 |
}
|
69 |
*/
|