-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcl_receiver_LCM.cpp
39 lines (31 loc) · 1.11 KB
/
pcl_receiver_LCM.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Run code with the following command
// g++ -o pcl_receiver_LCM pcl_receiver_LCM.cpp -llcm
#include <stdio.h>
#include <lcm/lcm-cpp.hpp>
#include "pcl_type.hpp"
#include <unistd.h>
class Handler {
public:
~Handler() {}
void handleMessage(const lcm::ReceiveBuffer *rbuf, const std::string &chan,
const pcl_type *msg)
{
printf("Received message on channel \"%s\":\n", chan.c_str());
printf(" xarray = %f %f %f %f \n", (float) msg->xarray[0],(float) msg->xarray[1],(float) msg->xarray[2],(float) msg->xarray[3]);
printf(" yarray = %f %f %f %f \n", (float) msg->yarray[0],(float) msg->yarray[1],(float) msg->yarray[2],(float) msg->yarray[3]);
printf(" zarray = %f %f %f %f \n", (float) msg->zarray[0],(float) msg->zarray[1],(float) msg->zarray[2],(float) msg->zarray[3]);
}
};
int main(int argc, char **argv)
{
lcm::LCM lcm;
if (!lcm.good())
return 1;
Handler handlerObject;
lcm.subscribe("pcl_topic", &Handler::handleMessage, &handlerObject);
while (0 == lcm.handle()) {
printf("test!\n");
// Do nothing
}
return 0;
}