00001 /* 00002 * Navigating jockey from local map 00003 * 00004 * The local map is centered on the laser scanner but its orientation is fixed. 00005 * 00006 * The role of this jockey is to travel to the next crossing. 00007 * The action is done when the robot reaches the crossing center. 00008 * It is considered to be memory-less because it uses only an internal memory 00009 * (in form of a local map) and do not interact with the large map. 00010 * Implemented actions: 00011 * - TRAVERSE: will start navigating to the next crossing (place with at least 00012 * three frontiers) and will succeed when the crossing center is reached. 00013 * - STOP: will stop 00014 * - INTERRUPT: same as CONTINUE 00015 * - CONTINUE: same as TRAVERSE 00016 * 00017 * Interaction with the map (created by this jockey): 00018 * - none 00019 * 00020 * Interaction with the map (created by other jockeys): 00021 * - none 00022 * 00023 * Subscribers (other than map-related): 00024 * - nav_msgs/OccupancyGrid, "~/local_costmap", local cost map which orientation is global 00025 * 00026 * Publishers (other than map-related): 00027 * - geometry_msgs/Twist, "~/cmd_vel", robot set velocity 00028 * - visualization_msgs/Marker, "~/crossing_marker", a sphere at the crossing center. 00029 * - visualization_msgs/Marker, "~/exits_marker", lines from crossing center towards exits. 00030 * - sensor_msgs/PointCloud, "~/place_profile_cloud", point cloud representing the place profile. 00031 * - lama_msgs/Crossing, "~/abs_crossing", Crossing with absolute frontier angles. 00032 * 00033 * Services used (other than map-related): 00034 * - none 00035 * 00036 * Parameters (read from this jockey): 00037 * - odom_frame, String, "/odom", this is the laser scan frame from which the 00038 * map relative orientation is computed. 00039 * - ~robot_radius, Float, frontier_width/2, robot radius (frontier_width is 00040 * a constructor parameter). 00041 * - ~laser_frame, String, "/base_laser_link", name of the LaserScan frame the 00042 * map is based on. 00043 * - ~range_cutoff, Float, 0, points farther than this are considered to be 00044 * free of obstacle and frontiers may exist. 0 means ignore. 00045 */ 00046 00047 #ifndef NJ_COSTMAP_JOCKEY_H 00048 #define NJ_COSTMAP_JOCKEY_H 00049 00050 #include <tf/tf.h> 00051 #include <tf/transform_listener.h> 00052 #include <tf/transform_datatypes.h> // for getYaw() 00053 #include <sensor_msgs/PointCloud.h> 00054 #include <nav_msgs/OccupancyGrid.h> 00055 00056 #include <goto_crossing/crossing_goer.h> 00057 #include <crossing_detector/costmap_crossing_detector.h> 00058 #include <lama_common/crossing_utils.h> /* lama_common::rotateCrossing() */ 00059 #include <lama_common/crossing_visualization.h> 00060 #include <lama_common/place_profile_conversions.h> 00061 #include <lama_jockeys/navigating_jockey.h> 00062 #include <lama_msgs/Crossing.h> 00063 #include <nj_oa_costmap/twist_handler.h> 00064 00065 namespace nj_costmap 00066 { 00067 00068 class Jockey : public lama_jockeys::NavigatingJockey 00069 { 00070 public: 00071 00072 Jockey(const std::string& name, const double frontier_width); 00073 00074 virtual void onTraverse(); 00075 virtual void onStop(); 00076 virtual void onInterrupt(); 00077 virtual void onContinue(); 00078 00079 void handleCostmap(const nav_msgs::OccupancyGridConstPtr& msg); 00080 00081 private: 00082 00083 void initTwistHandlerParam(); 00084 00085 // Publishers and subscribers. 00086 ros::Publisher pub_crossing_marker_; 00087 ros::Publisher pub_exits_marker_; 00088 ros::Publisher pub_twist_; 00089 ros::Publisher pub_place_profile_; 00090 ros::Publisher pub_crossing_; 00091 00092 ros::Subscriber costmap_handler_; 00093 00094 // ROS parameters. 00095 std::string odom_frame_; 00096 double range_cutoff_; 00097 00098 // Internals. 00099 bool has_crossing_; 00100 bool range_cutoff_set_; 00101 nav_msgs::OccupancyGrid map_; 00102 double last_map_orientation_; 00103 lama_msgs::Crossing abs_crossing_; 00104 lama_msgs::Crossing rel_crossing_; 00105 00106 tf::TransformListener tf_listener_; 00107 crossing_detector::CostmapCrossingDetector crossing_detector_; 00108 goto_crossing::CrossingGoer crossing_goer_; 00109 nj_oa_costmap::TwistHandler obstacle_avoider_; 00110 }; 00111 00112 } // namespace nj_costmap 00113 00114 #endif // NJ_COSTMAP_JOCKEY_H 00115 00116