Need correct syntax to call an actionlib service from a class member function.
What is the correct syntax to call an actionlib service from a class member function. As it is defined below I believe the var ac goes out of scope. But I am my attempts to move it outside being weak in c++ have failed.
void handelerSimpleGoal(const geometry_msgs::PoseStamped msg)
{
typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;
// find the coke can and use it as goal
ros::ServiceClient client = n.serviceClient<gazebo_msgs::GetModelState>("/gazebo/get_model_state");
gazebo_msgs::GetModelState getmodelstate;
getmodelstate.request.model_name ="coke_can";
client.call(getmodelstate);
// send the new goal
MoveBaseClient ac("move_base", true);
move_base_msgs::MoveBaseGoal goal;
goal.target_pose.header.frame_id = "map";
goal.target_pose.header.stamp = ros::Time::now();
goal.target_pose.pose = getmodelstate.response.pose;
ac.sendGoal(goal);
}