Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 1441

ros::Service same class instance in frequent callback

$
0
0
Hello People, I'm currently having issues writing a ros service for setting moveit goals. It looks like this: bool myfunc_callback(mypkg::mysrv::Request &req, mypkg::mysrv::Response &res) { moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP); //other moveit setup stuff //my data handling //my actual usage move_group.setPoseTarget(target_pose); return true; } int main(int argc, char **argv) { //ros init stuff (init and nodehandle) ros::ServiceServer service = mynode.advertiseService("mysrv", myfunc_callback); while (ros::ok()) { ros::spinOnce(); r.sleep(); } return 0; } From another node I'm calling this service several times. The service itself works just as intended. At its current state every single service call goes through the whole moveit setup stuff every time, which takes quite some time. Now I want to implement another function, which also has access to the instance "move_goup". Due to the service callback being defined in some mysterious library i cannot easily add additional values to the callback. Is there a possibility to define move_group in the main and pass it to the service callback function and to all other functions i need it in? This would also increase performance significantly. Thank you in advance Felix

Viewing all articles
Browse latest Browse all 1441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>