Can I have both a subscriber and a service in a single node?
Hi, I have a node which serves primarily as a service, but I would like it to be able to subscribe to a publisher so that I can import an array before the service is called. I tried adding the subscriber to the same nodehandle that has the service, and tried creating a second nodehandle. Either way it seems unable to receive data. Can I not have multiple services/subscribers in a node? If not, what is the best way to do this?
Here is my code in the main function, for reference
ros::NodeHandle servNode;
ros::NodeHandle subNode;
SteeringCaller steerCall;
steerCall.haveX = false; steerCall.haveBoth = false;
ros::Subscriber sub = subNode.subscribe<std_msgs::float64multiarray>("path", 5000, &SteeringCaller::savePath, &steerCall);
ros::ServiceServer service = servNode.advertiseService("steering_control", &SteeringCaller::calcSteering, &steerCall);
This is too few information. Actually you can have multple publishers, subscribers and services in the same node. If you look at nodes like camera1394, you will see that they do this a lot. Actually, since the source code for ROS is available you can just have a look at it and learn from it!