trick/trick_sims/ROS/models/ros_comm/ros_subscribe.cpp
Alex Lin 4c471eb32d Introduce Trick ROS publish/subscribe examples.
Introducing a pubish and subscribe example sim.  The publisher includes
a ROS msg file that is processed by ROS into a header file.

refs #190
2016-02-26 09:39:42 -06:00

22 lines
387 B
C++

#include "std_msgs/String.h"
#include "ros_subscribe.hh"
#include "Num.h"
void numchatterCallback(const trick_msgs::Num::ConstPtr& msg) {
std::cout << *msg << std::endl ;
}
RosSubscribe::RosSubscribe() {}
int RosSubscribe::init() {
sub = n.subscribe("num_chatter", 1000, numchatterCallback) ;
return 0 ;
}
int RosSubscribe::process() {
ros::spin() ;
return 0 ;
}