Hello,
I'm working with velodyne 32E and I was subscribing a node from "velodyne_driver" to read data from the topic "velodyne_packets" but the code in the callback wasn't executed everytime the topic was published by the LIDAR. (In callback it just had a counter incrementing, only printing the counter out of callback when the bag file ends or if press Ctrl+C)
I thought if I could change my code to use a nodelet instead of a node to direct access to data but i didn't find how to make it.
To subscribe a node it very easy because then is "sends me" to a callback just like an interruption (I think) and I could do whatever I wanted with the data. But with nodelets it is different and I didn't realized yet how could I get the data in real time.
I want to read directly from nodelet, not to transform a node into a nodelet!
Could you help me?
Thank you, Oportoz
CODE:
#includes.........
int i;
void callback(const velodyne_msgs::VelodyneScan::ConstPtr& msg)
{
i++;
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "subscribe_pack");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe<velodyne_msgs::VelodyneScan>("/velodyne_packets", 1, callback);
while(ros::ok())
{
ros::spin(); //
}
std::cout << i << std::endl;
return 0;
}
Originally posted by Oportoz on ROS Answers with karma: 1 on 2014-06-26
Post score: 0