[ros-users] Callback once

Prasad Dixit prasad.dixit at fennecfoxtech.com
Thu Jun 24 08:15:16 UTC 2010


Hello all,
I am subscribing a node for amcl_pose.

void* fn_get_robot_init_pos(void *obj){

   ros::init(argc, argv, "robot_AMCL_Position");
   ros::NodeHandle l_node;

    ros::Subscriber l_amcl_pose  = l_node.subscribe("amcl_pose", 1, 
fn_amclinitpose);
   ros::spin();

   return(NULL);
}

void fn_amclinitpose(const 
geometry_msgs::PoseWithCovarianceStampedConstPtr& msg)
{
  ROS_INFO("Received X:[%f] :: Y:[%f] :: Z:[%f] ", 
msg->pose.pose.position.x, msg->pose.pose.position.y, 
msg->pose.pose.position.z);

}

I want handle to be called only for one time. Since i want only initial 
position of the Robot in my code when the Robot starts.
In above code spin(); callbacks again and again. (I tried spinonce also).

Any solution to rid of this issue? Can we call function only one time?

- Prasad


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20100624/533f5153/attachment-0002.html>


More information about the ros-users mailing list