waitForMessage() is probably the right thing to do here: http://www.ros.org/doc/api/roscpp/html/namespaceros_1_1topic.html#a4d2385f018b4c61577c24ef2e302220a

If you want to use the callback and then return once it's done, you don't want to call ros::spin().  Instead you need to do something like:
while (<you don't have the message>)
{
  ros::spinOnce();
  ros::Duration(0.01).sleep();
}

Since your Subscriber object is scoped to the function you don't need to call shutdown() on it, as it will destruct when you leave the function.

Josh

On Thu, Jun 24, 2010 at 9:05 AM, Blaise Gassend <blaise@willowgarage.com> wrote:
You want to call subscriber.shutdown(), not ros::shutdown().

Another possibility is to use waitForMessage this:
https://code.ros.org/trac/ros/ticket/2084

It gets you a single message from a topic.

On 6/24/10, Prasad Dixit <prasad.dixit@fennecfoxtech.com> wrote:
> Hi,
>
> Thanks for the information.
> Sorry from my side for not giving full information.
> I have a main program which is doing some processes before getting robot
> initial position (amcl_pose) and also some processes are being executed
> after that.
> I tried shutdown() function already but it does not return control to the
> main program.
> So my post processes are not being called.
>
> -Thanks
> Prasad
>
>
>
_______________________________________________
ros-users mailing list
ros-users@code.ros.org
https://code.ros.org/mailman/listinfo/ros-users