22 idle_status_update_sent_(false),
23 move_base_ac_(
"move_base", true)
70 if (nav_ctrl->control == yocs_msgs::NavigationControl::STOP)
84 ROS_WARN_STREAM(
"Cannot stop way point/trajectory execution, because nothing is being executed.");
87 else if ((nav_ctrl->control == yocs_msgs::NavigationControl::START))
93 bool goal_found =
false;
94 for (
unsigned int wp = 0; wp <
wp_list_.waypoints.size(); ++wp)
96 if (nav_ctrl->goal_name ==
wp_list_.waypoints[wp].name)
98 geometry_msgs::PoseStamped pose;
99 pose.header =
wp_list_.waypoints[wp].header;
100 pose.pose =
wp_list_.waypoints[wp].pose;
104 ROS_INFO_STREAM(
"Prepared to navigate to way point '" << nav_ctrl->goal_name <<
"'.");
110 for (
unsigned int traj = 0; traj <
traj_list_.trajectories.size(); ++traj)
112 if (nav_ctrl->goal_name ==
traj_list_.trajectories[traj].name)
114 for (
unsigned int wp = 0; wp <
traj_list_.trajectories[traj].waypoints.size(); ++wp)
116 geometry_msgs::PoseStamped pose;
117 pose.header =
traj_list_.trajectories[traj].waypoints[wp].header;
118 pose.pose =
traj_list_.trajectories[traj].waypoints[wp].pose;
123 ROS_INFO_STREAM(
"Prepared to navigate along the trajectory '" << nav_ctrl->goal_name <<
"'.");
140 ROS_WARN_STREAM(
"Cannot start way point/trajectory execution, because navigator is currently active. " 141 <<
"Please stop current activity first.");
160 ROS_WARN(
"Cannot cancel move base goal, as it has %s state!", goal_state.
toString().c_str());
165 ROS_INFO(
"Canceling move base goal with %s state...", goal_state.
toString().c_str());
169 ROS_WARN(
"Cancel move base goal didn't finish after %.2f seconds: %s",
170 timeout, goal_state.
toString().c_str());
175 ROS_INFO(
"Cancel move base goal succeed. New state is %s", goal_state.
toString().c_str());
182 ROS_DEBUG(
"Full reset: clear markers, delete waypoints and goal and set state to IDLE");
191 move_base_msgs::MoveBaseGoal mb_goal;
213 mb_goal.target_pose.header.frame_id =
waypoints_it_->header.frame_id;
217 ROS_INFO(
"New goal: %.2f, %.2f, %.2f",
218 mb_goal.target_pose.pose.position.x, mb_goal.target_pose.pose.position.y,
219 tf::getYaw(mb_goal.target_pose.pose.orientation));
262 ROS_WARN(
"Cannot reach goal after %.2f seconds; request a new one (current state is %s)",
314 ROS_INFO(
"Go to goal successfully completed: %.2f, %.2f, %.2f",
315 mb_goal.target_pose.pose.position.x, mb_goal.target_pose.pose.position.y,
316 tf::getYaw(mb_goal.target_pose.pose.orientation));
366 return ((a.pose.position.x == b.pose.position.x) &&
367 (a.pose.position.y == b.pose.position.y) &&
368 (a.pose.position.z == b.pose.position.z));
374 return ((a.x == b.x) && (a.y == b.y) && (a.z == b.z));
379 yocs_msgs::NavigationControlStatus msg;
380 if (status == yocs_msgs::NavigationControlStatus::IDLING)
382 msg.status = yocs_msgs::NavigationControlStatus::IDLING;
383 msg.status_desc =
"Idling";
386 else if (status == yocs_msgs::NavigationControlStatus::RUNNING)
388 msg.status = yocs_msgs::NavigationControlStatus::RUNNING;
389 msg.status_desc =
"Navigating to way point.";
392 else if (status == yocs_msgs::NavigationControlStatus::PAUSED)
394 msg.status = yocs_msgs::NavigationControlStatus::PAUSED;
395 msg.status_desc =
"Navigation on hold.";
398 else if (status == yocs_msgs::NavigationControlStatus::COMPLETED)
400 msg.status = yocs_msgs::NavigationControlStatus::COMPLETED;
401 msg.status_desc =
"Reached final destination.";
404 else if (status == yocs_msgs::NavigationControlStatus::CANCELLED)
406 msg.status = yocs_msgs::NavigationControlStatus::CANCELLED;
407 msg.status_desc =
"Navigation cancelled.";
410 else if (status == yocs_msgs::NavigationControlStatus::ERROR)
412 msg.status = yocs_msgs::NavigationControlStatus::ERROR;
413 msg.status_desc =
"An error occurred.";
void pose2tf(const geometry_msgs::Pose &pose, tf::Transform &tf)
bool equals(const geometry_msgs::PoseStamped &a, const geometry_msgs::PoseStamped &b)
bool cancelAllGoals(double timeout=2.0)
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
#define ROS_WARN_THROTTLE(rate,...)
const geometry_msgs::PoseStamped NOWHERE
void publish(const boost::shared_ptr< M > &message) const
void navCtrlCB(const yocs_msgs::NavigationControl::ConstPtr &nav_ctrl)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
static double getYaw(const Quaternion &bt_q)
yocs_msgs::TrajectoryList traj_list_
ros::Subscriber trajectories_sub_
std::vector< geometry_msgs::PoseStamped >::iterator waypoints_it_
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > move_base_ac_
bool idle_status_update_sent_
yocs_msgs::WaypointList wp_list_
void publishStatusUpdate(const uint8_t &status)
double distance2D(double ax, double ay, double bx, double by)
std::string toString() const
void trajectoriesCB(const yocs_msgs::TrajectoryList::ConstPtr &trajs)
ros::Subscriber nav_ctrl_sub_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
enum yocs::WaypointsGoalNode::@1 state_
void waypointsCB(const yocs_msgs::WaypointList::ConstPtr &wps)
tf::TransformListener tf_listener_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_WARN_STREAM(args)
std::vector< geometry_msgs::PoseStamped > waypoints_
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
#define ROS_INFO_STREAM(args)
geometry_msgs::PoseStamped goal_
enum yocs::WaypointsGoalNode::@0 mode_
ros::Publisher status_pub_
SimpleClientGoalState getState() const
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL void spinOnce()
ros::Subscriber waypoints_sub_