Created
October 8, 2015 17:47
-
-
Save plinioMoreno/b6d0a894c3cf74478a22 to your computer and use it in GitHub Desktop.
YARP code that reads the hello world string from ROS publisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- | |
#include <stdio.h> | |
#include <yarp/os/all.h> | |
using namespace yarp::os; | |
int main(int argc, char *argv[]) { | |
Network yarp; | |
//Node node("/yarp/hello_world_listener"); | |
BufferedPort<Bottle> port; | |
port.setReadOnly(); | |
if (!port.open("/topic_name@/dds")) { | |
fprintf(stderr,"Failed to open port\n"); | |
return 1; | |
} | |
while (true) { | |
Bottle *msg = port.read(); | |
if (msg==NULL) { | |
fprintf(stderr,"Failed to read msg\n"); | |
continue; | |
} | |
printf("Got [%s]\n", msg->get(0).asString().c_str()); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment