12 std::string location = goal->location;
13 int approach_type = goal->approach_type;
14 unsigned int num_retry = goal->num_retry;
16 double timeout = goal->timeout;
18 yocs_msgs::Waypoint waypoint;
25 ss <<
"failed to find the requested destination : " << location;
37 switch(approach_type) {
38 case yocs_msgs::NavigateToGoal::APPROACH_NEAR:
39 loginfo(
"Approach Type : NEAR");
40 goNear(waypoint, distance, num_retry, timeout);
42 case yocs_msgs::NavigateToGoal::APPROACH_ON:
44 goOn(waypoint, distance, num_retry, timeout);
52 void SemanticNavigator::goOn(
const yocs_msgs::Waypoint waypoint,
const double in_distance,
const int num_retry,
const double timeout)
55 geometry_msgs::PoseStamped target;
56 target.pose = waypoint.pose;
57 target.header = waypoint.header;
65 move_base_msgs::MoveBaseGoal mb_goal;
72 mb_goal.target_pose = target;
79 nextState(retry, final_result, message, navi_result, started_time);
81 if(retry ==
false)
break;
82 else if(attempt > num_retry)
85 message =
"Tried enough... I failed to navigate..";
91 ss <<
"Reattempt to naviate.. " << attempt;
94 double diff = (current_time - started_time).toSec();
95 double remain_time = timeout - diff;
106 geometry_msgs::PoseStamped target;
107 target.pose = waypoint.pose;
108 target.header = waypoint.header;
111 int move_base_result;
116 move_base_msgs::MoveBaseGoal mb_goal;
120 while(attempt < num_retry &&
ros::ok())
123 mb_goal.target_pose = target;
129 nextState(retry, final_result, message, navi_result, started_time);
131 if(retry ==
false)
break;
135 if(attempt > num_retry)
137 final_result =
false;
138 message =
"Tried enough... I failed to navigate..";
149 geometry_msgs::PoseStamped robot_pose = feedback->base_position;
152 double distance =
mtk::distance2D(robot_pose.pose.position.x, robot_pose.pose.position.y, target_pose.pose.position.x, target_pose.pose.position.y);
void processNavigation(yocs_msgs::NavigateToGoal::ConstPtr goal)
void nextState(bool &retry, bool &final_result, std::string &message, const int navi_result, const ros::Time started_time)
void processMoveBaseFeedback(const move_base_msgs::MoveBaseFeedback::ConstPtr &feedback, const geometry_msgs::PoseStamped &target)
bool getGoalLocation(const std::string location, yocs_msgs::Waypoint &waypoint)
std::string global_frame_
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
bool sameFrame(const std::string &frame_a, const std::string &frame_b)
double distance2D(double ax, double ay, double bx, double by)
boost::function< void()> SimpleActiveCallback
actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > ac_move_base_
void goOn(const yocs_msgs::Waypoint waypoint, const double in_distance, const int num_retry, const double timeout)
boost::function< void(const SimpleClientGoalState &state, const ResultConstPtr &result)> SimpleDoneCallback
void feedbackNavigation(const int status, const double distance, const double remain_time, const std::string message)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
void loginfo(const std::string &msg)
void waitForMoveBase(int &move_base_result, const ros::Time &start_time, const double timeout)
void determineNavigationState(int &navi_result, const int move_base_result, const actionlib::SimpleClientGoalState move_base_state)
void goNear(const yocs_msgs::Waypoint waypoint, const double in_distance, const int num_retry, const double timeout)
SimpleClientGoalState getState() const
static const int NAVI_UNKNOWN
void terminateNavigation(bool success, const std::string message)