ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
2013-12-12 17:07:24 -0500 | received badge | ● Famous Question (source) |
2013-07-21 00:16:13 -0500 | received badge | ● Notable Question (source) |
2013-07-18 17:53:33 -0500 | received badge | ● Popular Question (source) |
2013-07-18 08:43:08 -0500 | received badge | ● Editor (source) |
2013-07-18 08:42:30 -0500 | asked a question | 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); |