Re: [ros-users] Callback once

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Lorenz M?senlechner
Date:  
To: ros-users
Subject: Re: [ros-users] Callback once
Hi,

you can call the `shutdown' method on the Subscriber instance in your
message callback.

Lorenz

> 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
>
>


> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users



-- 
Lorenz M?senlechner            | 
Technische Universit?t M?nchen | Boltzmannstr. 3
85748 Garching bei M?nchen     | Germany
http://ias.cs.tum.edu/         | Tel: +49 (89) 289-17750