diff --git a/README.md b/README.md index b35aebf..fb65807 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ git clone https://github.com/amslabtech/dwa_planner.git # build cd /path/to/your/catkin_ws -rosdep install --from-paths src --ignore-src -y # Install dependencies -catkin build dwa_planner -DCMAKE_BUILD_TYPE=Release # Release build is recommended +rosdep install -riy --from-paths src --rosdistro noetic # Install dependencies +catkin build dwa_planner -DCMAKE_BUILD_TYPE=Release # Release build is recommended ``` ## How to use @@ -34,7 +34,17 @@ catkin build dwa_planner -DCMAKE_BUILD_TYPE=Release # Release build is recommen roslaunch dwa_planner local_planner.launch ``` -## Running the demo +## Running the demo with docker +``` +git clone https://github.com/amslabtech/dwa_planner.git && cd dwa_planner + +# build an image, create a container and start demo (Ctrl-c: stop a container and exit) +docker compose up +# remove a container +docker compose down +``` + +## Running the demo without docker ### Using simulator ``` # clone repository @@ -45,19 +55,15 @@ git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations. # build cd /path/to/your/catkin_ws -rosdep install --from-paths src --ignore-src -y # Install dependencies -catkin build -DCMAKE_BUILD_TYPE=Release # Release build is recommended +rosdep install -riy --from-paths src --rosdistro noetic +catkin build -DCMAKE_BUILD_TYPE=Release # run demo export TURTLEBOT3_MODEL=burger -roslaunch turtlebot3_navigation turtlebot3_navigation.launch -export TURTLEBOT3_MODEL=burger -roslaunch turtlebot3_gazebo turtlebot3_world.launch -roslaunch dwa_planner local_planner.launch use_scan_as_input:=True v_path_width:=0.02 +roslaunch dwa_planner demo.launch ``` ![demo 2](docs/images/dwa_planner_demo_2.gif) - ## Node I/O ![Node I/O](docs/images/dwa_planner_io.png) diff --git a/docs/Parameters_8md.html b/docs/Parameters_8md.html index 01fda0c..6a4ca8a 100644 --- a/docs/Parameters_8md.html +++ b/docs/Parameters_8md.html @@ -27,7 +27,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/README_8md.html b/docs/README_8md.html index 3056b41..a3e12f4 100644 --- a/docs/README_8md.html +++ b/docs/README_8md.html @@ -27,7 +27,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/Topics_8md.html b/docs/Topics_8md.html index 9953494..ce7243c 100644 --- a/docs/Topics_8md.html +++ b/docs/Topics_8md.html @@ -27,7 +27,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/annotated.html b/docs/annotated.html index 6c3e15a..915ffd6 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -35,7 +35,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner-members.html b/docs/classDWAPlanner-members.html index 578552a..7573cee 100644 --- a/docs/classDWAPlanner-members.html +++ b/docs/classDWAPlanner-members.html @@ -40,6 +40,8 @@ candidate_trajectories_pub_DWAPlannerprotected check_collision(const std::vector< State > &traj)DWAPlanner create_marker_msg(const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())DWAPlanner + create_obs_list(const nav_msgs::OccupancyGrid &map)DWAPlanner + create_obs_list(const sensor_msgs::LaserScan &scan)DWAPlanner current_cmd_vel_DWAPlannerprotected dist_to_goal_th_DWAPlannerprotected dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)DWAPlanner @@ -48,98 +50,93 @@ DWAPlanner(void)DWAPlanner edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)DWAPlanner edge_on_global_path_sub_DWAPlannerprotected - edge_on_global_path_subscribed_DWAPlannerprotected - edge_points_on_path_DWAPlannerprotected - evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)DWAPlanner - finish_flag_pub_DWAPlannerprotected - footprint_DWAPlannerprotected - footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)DWAPlanner - footprint_padding_DWAPlannerprotected - footprint_sub_DWAPlannerprotected - footprint_subscribed_DWAPlannerprotected + edge_points_on_path_DWAPlannerprotected + evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)DWAPlanner + finish_flag_pub_DWAPlannerprotected + footprint_DWAPlannerprotected + footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)DWAPlanner + footprint_padding_DWAPlannerprotected + footprint_sub_DWAPlannerprotected generate_trajectory(const double velocity, const double yawrate)DWAPlanner generate_trajectory(const double yawrate, const Eigen::Vector3d &goal)DWAPlanner global_frame_DWAPlannerprotected goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)DWAPlanner - goal_msg_DWAPlannerprotected + goal_msg_DWAPlannerprotected goal_sub_DWAPlannerprotected - goal_subscribed_DWAPlannerprotected - has_finished_DWAPlannerprotected - has_reached_DWAPlannerprotected - hz_DWAPlannerprotected - is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)DWAPlanner - is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)DWAPlanner - listener_DWAPlannerprotected - load_params(void)DWAPlanner - local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)DWAPlanner - local_map_not_subscribe_count_DWAPlannerprotected - local_map_sub_DWAPlannerprotected - local_map_updated_DWAPlannerprotected - local_nh_DWAPlannerprotected - max_acceleration_DWAPlannerprotected - max_d_yawrate_DWAPlannerprotected - max_deceleration_DWAPlannerprotected - max_in_place_yawrate_DWAPlannerprotected - max_velocity_DWAPlannerprotected - max_yawrate_DWAPlannerprotected - min_in_place_yawrate_DWAPlannerprotected - min_velocity_DWAPlannerprotected - min_yawrate_DWAPlannerprotected - motion(State &state, const double velocity, const double yawrate)DWAPlanner - move_footprint(const State &target_pose)DWAPlanner - nh_DWAPlannerprotected - normalize_costs(std::vector< Cost > &costs)DWAPlanner - obs_cost_gain_DWAPlannerprotected - obs_list_DWAPlannerprotected - obs_range_DWAPlannerprotected - odom_callback(const nav_msgs::OdometryConstPtr &msg)DWAPlanner - odom_not_subscribe_count_DWAPlannerprotected - odom_sub_DWAPlannerprotected - odom_updated_DWAPlannerprotected - path_cost_gain_DWAPlannerprotected - predict_footprints_pub_DWAPlannerprotected - predict_time_DWAPlannerprotected - print_params(void)DWAPlanner - process(void)DWAPlanner - raycast(const nav_msgs::OccupancyGrid &map)DWAPlanner + has_finished_DWAPlannerprotected + has_reached_DWAPlannerprotected + hz_DWAPlannerprotected + is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)DWAPlanner + is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)DWAPlanner + listener_DWAPlannerprotected + load_params(void)DWAPlanner + local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)DWAPlanner + local_map_not_subscribe_count_DWAPlannerprotected + local_map_sub_DWAPlannerprotected + local_map_updated_DWAPlannerprotected + local_nh_DWAPlannerprotected + max_acceleration_DWAPlannerprotected + max_d_yawrate_DWAPlannerprotected + max_deceleration_DWAPlannerprotected + max_in_place_yawrate_DWAPlannerprotected + max_velocity_DWAPlannerprotected + max_yawrate_DWAPlannerprotected + min_in_place_yawrate_DWAPlannerprotected + min_velocity_DWAPlannerprotected + min_yawrate_DWAPlannerprotected + motion(State &state, const double velocity, const double yawrate)DWAPlanner + move_footprint(const State &target_pose)DWAPlanner + nh_DWAPlannerprotected + normalize_costs(std::vector< Cost > &costs)DWAPlanner + obs_cost_gain_DWAPlannerprotected + obs_list_DWAPlannerprotected + obs_range_DWAPlannerprotected + odom_callback(const nav_msgs::OdometryConstPtr &msg)DWAPlanner + odom_not_subscribe_count_DWAPlannerprotected + odom_sub_DWAPlannerprotected + odom_updated_DWAPlannerprotected + path_cost_gain_DWAPlannerprotected + predict_footprints_pub_DWAPlannerprotected + predict_time_DWAPlannerprotected + print_params(void)DWAPlanner + process(void)DWAPlanner robot_frame_DWAPlannerprotected robot_radius_DWAPlannerprotected scan_callback(const sensor_msgs::LaserScanConstPtr &msg)DWAPlanner scan_not_subscribe_count_DWAPlannerprotected scan_sub_DWAPlannerprotected - scan_to_obs(const sensor_msgs::LaserScan &scan)DWAPlanner - scan_updated_DWAPlannerprotected - selected_trajectory_pub_DWAPlannerprotected - sim_direction_DWAPlannerprotected - sim_period_DWAPlannerprotected - sim_time_samples_DWAPlannerprotected - sleep_time_after_finish_DWAPlannerprotected - slow_velocity_th_DWAPlannerprotected - speed_cost_gain_DWAPlannerprotected - subscribe_count_th_DWAPlannerprotected - target_velocity_DWAPlannerprotected - target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)DWAPlanner - target_velocity_sub_DWAPlannerprotected - to_goal_cost_gain_DWAPlannerprotected - turn_direction_th_DWAPlannerprotected - use_footprint_DWAPlannerprotected - use_path_cost_DWAPlannerprotected - use_scan_as_input_DWAPlannerprotected - use_speed_cost_DWAPlannerprotected - v_path_width_DWAPlannerprotected - velocity_pub_DWAPlannerprotected - velocity_samples_DWAPlannerprotected - visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)DWAPlanner - visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)DWAPlanner - visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)DWAPlanner - yawrate_samples_DWAPlannerprotected + scan_updated_DWAPlannerprotected + selected_trajectory_pub_DWAPlannerprotected + sim_direction_DWAPlannerprotected + sim_period_DWAPlannerprotected + sim_time_samples_DWAPlannerprotected + sleep_time_after_finish_DWAPlannerprotected + slow_velocity_th_DWAPlannerprotected + speed_cost_gain_DWAPlannerprotected + subscribe_count_th_DWAPlannerprotected + target_velocity_DWAPlannerprotected + target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)DWAPlanner + target_velocity_sub_DWAPlannerprotected + to_goal_cost_gain_DWAPlannerprotected + turn_direction_th_DWAPlannerprotected + use_footprint_DWAPlannerprotected + use_path_cost_DWAPlannerprotected + use_scan_as_input_DWAPlannerprotected + use_speed_cost_DWAPlannerprotected + v_path_width_DWAPlannerprotected + velocity_pub_DWAPlannerprotected + velocity_samples_DWAPlannerprotected + visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)DWAPlanner + visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)DWAPlanner + visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)DWAPlanner + yawrate_samples_DWAPlannerprotected

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner.html b/docs/classDWAPlanner.html index 98ca142..ba1ef7c 100644 --- a/docs/classDWAPlanner.html +++ b/docs/classDWAPlanner.html @@ -85,6 +85,12 @@ visualization_msgs::Marker create_marker_msg (const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())  Create a marker message. More...
  +void create_obs_list (const nav_msgs::OccupancyGrid &map) + Get obstacle list from local map. More...
+  +void create_obs_list (const sensor_msgs::LaserScan &scan) + Get obstacle list from laser scan. More...
+  void dist_to_goal_th_callback (const std_msgs::Float64ConstPtr &msg)  A callback to handle buffering distance to goal threshold messages. More...
  @@ -142,15 +148,9 @@ void process (void)  Execute local path planning. More...
  -void raycast (const nav_msgs::OccupancyGrid &map) - Get obstacle list from local map. More...
-  void scan_callback (const sensor_msgs::LaserScanConstPtr &msg)  A callback to hanldle buffering scan messages. More...
  -void scan_to_obs (const sensor_msgs::LaserScan &scan) - Get obstacle list from laser scan. More...
-  void target_velocity_callback (const geometry_msgs::TwistConstPtr &msg)  A callback to hanldle buffering target velocity messages. More...
  @@ -180,28 +180,22 @@   ros::Subscriber edge_on_global_path_sub_   -bool edge_on_global_path_subscribed_ -  -std::vector< geometry_msgs::PoseStamped > edge_points_on_path_ -  +std::optional< nav_msgs::Path > edge_points_on_path_ +  ros::Publisher finish_flag_pub_   -geometry_msgs::PolygonStamped footprint_ -  +std::optional< geometry_msgs::PolygonStamped > footprint_ +  double footprint_padding_   ros::Subscriber footprint_sub_   -bool footprint_subscribed_ -  std::string global_frame_   -geometry_msgs::PoseStamped goal_msg_ -  +std::optional< geometry_msgs::PoseStamped > goal_msg_ +  ros::Subscriber goal_sub_   -bool goal_subscribed_ -  std_msgs::Bool has_finished_   bool has_reached_ @@ -354,7 +348,7 @@

Returns
The command velocity
-

Definition at line 364 of file dwa_planner.cpp.

+

Definition at line 358 of file dwa_planner.cpp.

@@ -394,7 +388,7 @@

Returns
The distance from robot footprint to the nearest obstacle
-

Definition at line 605 of file dwa_planner.cpp.

+

Definition at line 599 of file dwa_planner.cpp.

@@ -423,7 +417,7 @@

Returns
The distance of current pose to global path
-

Definition at line 522 of file dwa_planner.cpp.

+

Definition at line 516 of file dwa_planner.cpp.

@@ -446,7 +440,7 @@

Returns
The dynamic window
-

Definition at line 469 of file dwa_planner.cpp.

+

Definition at line 463 of file dwa_planner.cpp.

@@ -493,7 +487,7 @@

Returns
The intersection point of the line and the circle
-

Definition at line 572 of file dwa_planner.cpp.

+

Definition at line 566 of file dwa_planner.cpp.

@@ -522,7 +516,7 @@

Returns
The obstacle cost
-

Definition at line 485 of file dwa_planner.cpp.

+

Definition at line 479 of file dwa_planner.cpp.

@@ -551,7 +545,7 @@

Returns
The path cost
-

Definition at line 514 of file dwa_planner.cpp.

+

Definition at line 508 of file dwa_planner.cpp.

@@ -580,7 +574,7 @@

Returns
The speed cost
-

Definition at line 506 of file dwa_planner.cpp.

+

Definition at line 500 of file dwa_planner.cpp.

@@ -620,7 +614,7 @@

Returns
The distance of current pose to goal pose
-

Definition at line 479 of file dwa_planner.cpp.

+

Definition at line 473 of file dwa_planner.cpp.

@@ -649,7 +643,7 @@

Returns
True if the robot can adjust the direction
-

Definition at line 436 of file dwa_planner.cpp.

+

Definition at line 430 of file dwa_planner.cpp.

@@ -672,7 +666,7 @@

Returns
True if the robot can move
-

Definition at line 334 of file dwa_planner.cpp.

+

Definition at line 328 of file dwa_planner.cpp.

@@ -701,7 +695,7 @@

Returns
True if the robot has collided
-

Definition at line 451 of file dwa_planner.cpp.

+

Definition at line 445 of file dwa_planner.cpp.

@@ -761,7 +755,63 @@

Definition at line 768 of file dwa_planner.cpp.

+

Definition at line 762 of file dwa_planner.cpp.

+ + + + +

◆ create_obs_list() [1/2]

+ +
+
+ + + + + + + + +
void DWAPlanner::create_obs_list (const nav_msgs::OccupancyGrid & map)
+
+ +

Get obstacle list from local map.

+
Parameters
+ + +
mapThe local map
+
+
+ +

Definition at line 736 of file dwa_planner.cpp.

+ +
+
+ +

◆ create_obs_list() [2/2]

+ +
+
+ + + + + + + + +
void DWAPlanner::create_obs_list (const sensor_msgs::LaserScan & scan)
+
+ +

Get obstacle list from laser scan.

+
Parameters
+ + +
scanThe laser scan
+
+
+ +

Definition at line 715 of file dwa_planner.cpp.

@@ -783,7 +833,7 @@

Definition at line 148 of file dwa_planner.cpp.

+

Definition at line 144 of file dwa_planner.cpp.

@@ -823,7 +873,7 @@

Definition at line 173 of file dwa_planner.cpp.

+

Definition at line 167 of file dwa_planner.cpp.

@@ -845,7 +895,7 @@

Definition at line 154 of file dwa_planner.cpp.

+

Definition at line 150 of file dwa_planner.cpp.

@@ -885,7 +935,7 @@

Returns
The cost of trajectory
-

Definition at line 561 of file dwa_planner.cpp.

+

Definition at line 555 of file dwa_planner.cpp.

@@ -907,7 +957,7 @@

Definition at line 137 of file dwa_planner.cpp.

+

Definition at line 134 of file dwa_planner.cpp.

@@ -947,7 +997,7 @@

Returns
The generated trajectory
-

Definition at line 533 of file dwa_planner.cpp.

+

Definition at line 527 of file dwa_planner.cpp.

@@ -987,7 +1037,7 @@

Returns
The generated trajectory
-

Definition at line 546 of file dwa_planner.cpp.

+

Definition at line 540 of file dwa_planner.cpp.

@@ -1009,7 +1059,7 @@

Definition at line 91 of file dwa_planner.cpp.

+

Definition at line 88 of file dwa_planner.cpp.

@@ -1056,7 +1106,7 @@

Returns
True if the obstacle is inside of robot footprint
-

Definition at line 655 of file dwa_planner.cpp.

+

Definition at line 649 of file dwa_planner.cpp.

@@ -1096,7 +1146,7 @@

Returns
True if the target point is inside of triangle
-

Definition at line 680 of file dwa_planner.cpp.

+

Definition at line 674 of file dwa_planner.cpp.

@@ -1140,7 +1190,7 @@

Definition at line 116 of file dwa_planner.cpp.

+

Definition at line 113 of file dwa_planner.cpp.

@@ -1186,7 +1236,7 @@

Definition at line 711 of file dwa_planner.cpp.

+

Definition at line 705 of file dwa_planner.cpp.

@@ -1215,7 +1265,7 @@

Returns
The moved footprint
-

Definition at line 619 of file dwa_planner.cpp.

+

Definition at line 613 of file dwa_planner.cpp.

@@ -1243,7 +1293,7 @@

Definition at line 267 of file dwa_planner.cpp.

+

Definition at line 261 of file dwa_planner.cpp.

@@ -1265,7 +1315,7 @@

Definition at line 124 of file dwa_planner.cpp.

+

Definition at line 121 of file dwa_planner.cpp.

@@ -1309,29 +1359,7 @@

Definition at line 309 of file dwa_planner.cpp.

- - - - -

◆ raycast()

- -
-
- - - - - - - - -
void DWAPlanner::raycast (const nav_msgs::OccupancyGrid & map)
-
- -

Get obstacle list from local map.

- -

Definition at line 742 of file dwa_planner.cpp.

+

Definition at line 303 of file dwa_planner.cpp.

@@ -1353,29 +1381,7 @@

Definition at line 108 of file dwa_planner.cpp.

- - - - -

◆ scan_to_obs()

- -
-
- - - - - - - - -
void DWAPlanner::scan_to_obs (const sensor_msgs::LaserScan & scan)
-
- -

Get obstacle list from laser scan.

- -

Definition at line 721 of file dwa_planner.cpp.

+

Definition at line 105 of file dwa_planner.cpp.

@@ -1397,7 +1403,7 @@

Definition at line 131 of file dwa_planner.cpp.

+

Definition at line 128 of file dwa_planner.cpp.

@@ -1436,7 +1442,7 @@

Definition at line 840 of file dwa_planner.cpp.

+

Definition at line 834 of file dwa_planner.cpp.

@@ -1475,7 +1481,7 @@

Definition at line 818 of file dwa_planner.cpp.

+

Definition at line 812 of file dwa_planner.cpp.

@@ -1514,7 +1520,7 @@

Definition at line 810 of file dwa_planner.cpp.

+

Definition at line 804 of file dwa_planner.cpp.

@@ -1539,7 +1545,7 @@

-

Definition at line 417 of file dwa_planner.h.

+

Definition at line 419 of file dwa_planner.h.

@@ -1563,7 +1569,7 @@

-

Definition at line 426 of file dwa_planner.h.

+

Definition at line 428 of file dwa_planner.h.

@@ -1587,7 +1593,7 @@

-

Definition at line 455 of file dwa_planner.h.

+

Definition at line 454 of file dwa_planner.h.

@@ -1611,7 +1617,7 @@

-

Definition at line 468 of file dwa_planner.h.

+

Definition at line 467 of file dwa_planner.h.

@@ -1635,7 +1641,7 @@

-

Definition at line 424 of file dwa_planner.h.

+

Definition at line 426 of file dwa_planner.h.

@@ -1659,7 +1665,7 @@

-

Definition at line 459 of file dwa_planner.h.

+

Definition at line 458 of file dwa_planner.h.

@@ -1683,36 +1689,12 @@

-

Definition at line 460 of file dwa_planner.h.

- - - - -

◆ edge_on_global_path_subscribed_

- -
-
- - - - - -
- - - - -
bool DWAPlanner::edge_on_global_path_subscribed_
-
-protected
-
- -

Definition at line 439 of file dwa_planner.h.

+

Definition at line 459 of file dwa_planner.h.

- -

◆ edge_points_on_path_

+ +

◆ edge_points_on_path_

@@ -1755,12 +1737,12 @@

-

Definition at line 458 of file dwa_planner.h.

+

Definition at line 457 of file dwa_planner.h.

- -

◆ footprint_

+ +

◆ footprint_

@@ -1803,7 +1785,7 @@

-

Definition at line 431 of file dwa_planner.h.

+

Definition at line 433 of file dwa_planner.h.

@@ -1827,31 +1809,7 @@

-

Definition at line 461 of file dwa_planner.h.

- - - - -

◆ footprint_subscribed_

- -
-
- - - - - -
- - - - -
bool DWAPlanner::footprint_subscribed_
-
-protected
-
- -

Definition at line 437 of file dwa_planner.h.

+

Definition at line 460 of file dwa_planner.h.

@@ -1875,12 +1833,12 @@

-

Definition at line 403 of file dwa_planner.h.

+

Definition at line 405 of file dwa_planner.h.

- -

◆ goal_msg_

+ +

◆ goal_msg_

@@ -1923,31 +1881,7 @@

-

Definition at line 462 of file dwa_planner.h.

- - - - -

◆ goal_subscribed_

- -
-
- - - - - -
- - - - -
bool DWAPlanner::goal_subscribed_
-
-protected
-
- -

Definition at line 438 of file dwa_planner.h.

+

Definition at line 461 of file dwa_planner.h.

@@ -1971,7 +1905,7 @@

-

Definition at line 474 of file dwa_planner.h.

+

Definition at line 473 of file dwa_planner.h.

@@ -1995,7 +1929,7 @@

-

Definition at line 443 of file dwa_planner.h.

+

Definition at line 442 of file dwa_planner.h.

@@ -2019,7 +1953,7 @@

-

Definition at line 405 of file dwa_planner.h.

+

Definition at line 407 of file dwa_planner.h.

@@ -2043,7 +1977,7 @@

-

Definition at line 476 of file dwa_planner.h.

+

Definition at line 475 of file dwa_planner.h.

@@ -2067,7 +2001,7 @@

-

Definition at line 449 of file dwa_planner.h.

+

Definition at line 448 of file dwa_planner.h.

@@ -2091,7 +2025,7 @@

-

Definition at line 463 of file dwa_planner.h.

+

Definition at line 462 of file dwa_planner.h.

@@ -2115,7 +2049,7 @@

-

Definition at line 441 of file dwa_planner.h.

+

Definition at line 440 of file dwa_planner.h.

@@ -2139,7 +2073,7 @@

-

Definition at line 453 of file dwa_planner.h.

+

Definition at line 452 of file dwa_planner.h.

@@ -2163,7 +2097,7 @@

-

Definition at line 413 of file dwa_planner.h.

+

Definition at line 415 of file dwa_planner.h.

@@ -2187,7 +2121,7 @@

-

Definition at line 415 of file dwa_planner.h.

+

Definition at line 417 of file dwa_planner.h.

@@ -2211,7 +2145,7 @@

-

Definition at line 414 of file dwa_planner.h.

+

Definition at line 416 of file dwa_planner.h.

@@ -2235,7 +2169,7 @@

-

Definition at line 411 of file dwa_planner.h.

+

Definition at line 413 of file dwa_planner.h.

@@ -2259,7 +2193,7 @@

-

Definition at line 407 of file dwa_planner.h.

+

Definition at line 409 of file dwa_planner.h.

@@ -2283,7 +2217,7 @@

-

Definition at line 409 of file dwa_planner.h.

+

Definition at line 411 of file dwa_planner.h.

@@ -2307,7 +2241,7 @@

-

Definition at line 412 of file dwa_planner.h.

+

Definition at line 414 of file dwa_planner.h.

@@ -2331,7 +2265,7 @@

-

Definition at line 408 of file dwa_planner.h.

+

Definition at line 410 of file dwa_planner.h.

@@ -2355,7 +2289,7 @@

-

Definition at line 410 of file dwa_planner.h.

+

Definition at line 412 of file dwa_planner.h.

@@ -2379,7 +2313,7 @@

-

Definition at line 452 of file dwa_planner.h.

+

Definition at line 451 of file dwa_planner.h.

@@ -2403,7 +2337,7 @@

-

Definition at line 420 of file dwa_planner.h.

+

Definition at line 422 of file dwa_planner.h.

@@ -2427,7 +2361,7 @@

-

Definition at line 470 of file dwa_planner.h.

+

Definition at line 469 of file dwa_planner.h.

@@ -2451,7 +2385,7 @@

-

Definition at line 429 of file dwa_planner.h.

+

Definition at line 431 of file dwa_planner.h.

@@ -2475,7 +2409,7 @@

-

Definition at line 448 of file dwa_planner.h.

+

Definition at line 447 of file dwa_planner.h.

@@ -2499,7 +2433,7 @@

-

Definition at line 464 of file dwa_planner.h.

+

Definition at line 463 of file dwa_planner.h.

@@ -2523,7 +2457,7 @@

-

Definition at line 440 of file dwa_planner.h.

+

Definition at line 439 of file dwa_planner.h.

@@ -2547,7 +2481,7 @@

-

Definition at line 423 of file dwa_planner.h.

+

Definition at line 425 of file dwa_planner.h.

@@ -2571,7 +2505,7 @@

-

Definition at line 457 of file dwa_planner.h.

+

Definition at line 456 of file dwa_planner.h.

@@ -2595,7 +2529,7 @@

-

Definition at line 418 of file dwa_planner.h.

+

Definition at line 420 of file dwa_planner.h.

@@ -2619,7 +2553,7 @@

-

Definition at line 404 of file dwa_planner.h.

+

Definition at line 406 of file dwa_planner.h.

@@ -2643,7 +2577,7 @@

-

Definition at line 430 of file dwa_planner.h.

+

Definition at line 432 of file dwa_planner.h.

@@ -2667,7 +2601,7 @@

-

Definition at line 450 of file dwa_planner.h.

+

Definition at line 449 of file dwa_planner.h.

@@ -2691,7 +2625,7 @@

-

Definition at line 465 of file dwa_planner.h.

+

Definition at line 464 of file dwa_planner.h.

@@ -2715,7 +2649,7 @@

-

Definition at line 442 of file dwa_planner.h.

+

Definition at line 441 of file dwa_planner.h.

@@ -2739,7 +2673,7 @@

-

Definition at line 456 of file dwa_planner.h.

+

Definition at line 455 of file dwa_planner.h.

@@ -2763,7 +2697,7 @@

-

Definition at line 427 of file dwa_planner.h.

+

Definition at line 429 of file dwa_planner.h.

@@ -2787,7 +2721,7 @@

-

Definition at line 416 of file dwa_planner.h.

+

Definition at line 418 of file dwa_planner.h.

@@ -2811,7 +2745,7 @@

-

Definition at line 446 of file dwa_planner.h.

+

Definition at line 445 of file dwa_planner.h.

@@ -2835,7 +2769,7 @@

-

Definition at line 419 of file dwa_planner.h.

+

Definition at line 421 of file dwa_planner.h.

@@ -2859,7 +2793,7 @@

-

Definition at line 428 of file dwa_planner.h.

+

Definition at line 430 of file dwa_planner.h.

@@ -2883,7 +2817,7 @@

-

Definition at line 422 of file dwa_planner.h.

+

Definition at line 424 of file dwa_planner.h.

@@ -2907,7 +2841,7 @@

-

Definition at line 447 of file dwa_planner.h.

+

Definition at line 446 of file dwa_planner.h.

@@ -2931,7 +2865,7 @@

-

Definition at line 406 of file dwa_planner.h.

+

Definition at line 408 of file dwa_planner.h.

@@ -2955,7 +2889,7 @@

-

Definition at line 466 of file dwa_planner.h.

+

Definition at line 465 of file dwa_planner.h.

@@ -2979,7 +2913,7 @@

-

Definition at line 421 of file dwa_planner.h.

+

Definition at line 423 of file dwa_planner.h.

@@ -3003,7 +2937,7 @@

-

Definition at line 425 of file dwa_planner.h.

+

Definition at line 427 of file dwa_planner.h.

@@ -3027,7 +2961,7 @@

-

Definition at line 433 of file dwa_planner.h.

+

Definition at line 435 of file dwa_planner.h.

@@ -3051,7 +2985,7 @@

-

Definition at line 435 of file dwa_planner.h.

+

Definition at line 437 of file dwa_planner.h.

@@ -3075,7 +3009,7 @@

-

Definition at line 434 of file dwa_planner.h.

+

Definition at line 436 of file dwa_planner.h.

@@ -3099,7 +3033,7 @@

-

Definition at line 436 of file dwa_planner.h.

+

Definition at line 438 of file dwa_planner.h.

@@ -3123,7 +3057,7 @@

-

Definition at line 432 of file dwa_planner.h.

+

Definition at line 434 of file dwa_planner.h.

@@ -3147,7 +3081,7 @@

-

Definition at line 454 of file dwa_planner.h.

+

Definition at line 453 of file dwa_planner.h.

@@ -3171,7 +3105,7 @@

-

Definition at line 444 of file dwa_planner.h.

+

Definition at line 443 of file dwa_planner.h.

@@ -3195,7 +3129,7 @@

-

Definition at line 445 of file dwa_planner.h.

+

Definition at line 444 of file dwa_planner.h.

@@ -3210,7 +3144,7 @@

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1Cost-members.html b/docs/classDWAPlanner_1_1Cost-members.html index ec83c69..fc5e8dd 100644 --- a/docs/classDWAPlanner_1_1Cost-members.html +++ b/docs/classDWAPlanner_1_1Cost-members.html @@ -43,7 +43,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1Cost.html b/docs/classDWAPlanner_1_1Cost.html index 648cff4..0b8e622 100644 --- a/docs/classDWAPlanner_1_1Cost.html +++ b/docs/classDWAPlanner_1_1Cost.html @@ -86,7 +86,7 @@

Definition at line 68 of file dwa_planner.cpp.

+

Definition at line 65 of file dwa_planner.cpp.

@@ -146,7 +146,7 @@

Definition at line 72 of file dwa_planner.cpp.

+

Definition at line 69 of file dwa_planner.cpp.

@@ -169,7 +169,7 @@

Definition at line 89 of file dwa_planner.cpp.

+

Definition at line 86 of file dwa_planner.cpp.

@@ -191,7 +191,7 @@

Definition at line 80 of file dwa_planner.cpp.

+

Definition at line 77 of file dwa_planner.cpp.

@@ -286,7 +286,7 @@

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1State-members.html b/docs/classDWAPlanner_1_1State-members.html index 9d33d26..d0c057c 100644 --- a/docs/classDWAPlanner_1_1State-members.html +++ b/docs/classDWAPlanner_1_1State-members.html @@ -41,7 +41,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1State.html b/docs/classDWAPlanner_1_1State.html index b69bc8c..604d84c 100644 --- a/docs/classDWAPlanner_1_1State.html +++ b/docs/classDWAPlanner_1_1State.html @@ -80,7 +80,7 @@

Definition at line 48 of file dwa_planner.cpp.

+

Definition at line 45 of file dwa_planner.cpp.

@@ -140,7 +140,7 @@

Definition at line 50 of file dwa_planner.cpp.

+

Definition at line 47 of file dwa_planner.cpp.

@@ -235,7 +235,7 @@

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1Window-members.html b/docs/classDWAPlanner_1_1Window-members.html index 291b5cb..03752b9 100644 --- a/docs/classDWAPlanner_1_1Window-members.html +++ b/docs/classDWAPlanner_1_1Window-members.html @@ -40,7 +40,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classDWAPlanner_1_1Window.html b/docs/classDWAPlanner_1_1Window.html index 52f7d8e..0e20e08 100644 --- a/docs/classDWAPlanner_1_1Window.html +++ b/docs/classDWAPlanner_1_1Window.html @@ -78,7 +78,7 @@

Definition at line 55 of file dwa_planner.cpp.

+

Definition at line 52 of file dwa_planner.cpp.

@@ -101,7 +101,7 @@

Definition at line 57 of file dwa_planner.cpp.

+

Definition at line 54 of file dwa_planner.cpp.

@@ -180,7 +180,7 @@

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/classes.html b/docs/classes.html index 25f8531..a9ac8f5 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -47,7 +47,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dir_000000_000001.html b/docs/dir_000000_000001.html index 04f6c31..e3ea5c5 100644 --- a/docs/dir_000000_000001.html +++ b/docs/dir_000000_000001.html @@ -27,7 +27,7 @@

src → include Relation

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dir_49e56c817e5e54854c35e136979f97ca.html b/docs/dir_49e56c817e5e54854c35e136979f97ca.html index df3f62a..ece0801 100644 --- a/docs/dir_49e56c817e5e54854c35e136979f97ca.html +++ b/docs/dir_49e56c817e5e54854c35e136979f97ca.html @@ -31,7 +31,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dir_4d304beff246a0fadde0c304060f6af4.html b/docs/dir_4d304beff246a0fadde0c304060f6af4.html index 531b2bb..d23dddb 100644 --- a/docs/dir_4d304beff246a0fadde0c304060f6af4.html +++ b/docs/dir_4d304beff246a0fadde0c304060f6af4.html @@ -37,7 +37,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 30afbb0..1d401da 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -51,7 +51,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/dir_d44c64559bbebec7f509842c48db8b23.html index 92feffe..3a86f52 100644 --- a/docs/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.html @@ -37,7 +37,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner_8cpp.html b/docs/dwa__planner_8cpp.html index ca7abb7..a2e130e 100644 --- a/docs/dwa__planner_8cpp.html +++ b/docs/dwa__planner_8cpp.html @@ -68,7 +68,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner_8cpp_source.html b/docs/dwa__planner_8cpp_source.html index a3cf6f9..bd0fdcb 100644 --- a/docs/dwa__planner_8cpp_source.html +++ b/docs/dwa__planner_8cpp_source.html @@ -35,987 +35,977 @@
9 
-
11  : local_nh_("~"), footprint_subscribed_(false), goal_subscribed_(false), odom_updated_(false),
-
12  edge_on_global_path_subscribed_(false), local_map_updated_(false), scan_updated_(false), has_reached_(false),
-
13  use_speed_cost_(false), odom_not_subscribe_count_(0), local_map_not_subscribe_count_(0),
-
14  scan_not_subscribe_count_(0)
-
15 {
-
16  load_params();
-
17 
-
18  ROS_INFO("=== DWA Planner ===");
-
19  print_params();
-
20 
-
21  velocity_pub_ = nh_.advertise<geometry_msgs::Twist>("/cmd_vel", 1);
-
22  candidate_trajectories_pub_ = local_nh_.advertise<visualization_msgs::MarkerArray>("candidate_trajectories", 1);
-
23  selected_trajectory_pub_ = local_nh_.advertise<visualization_msgs::Marker>("selected_trajectory", 1);
-
24  predict_footprints_pub_ = local_nh_.advertise<visualization_msgs::MarkerArray>("predict_footprints", 1);
-
25  finish_flag_pub_ = local_nh_.advertise<std_msgs::Bool>("finish_flag", 1);
-
26 
-
27  dist_to_goal_th_sub_ = nh_.subscribe("/dist_to_goal_th", 1, &DWAPlanner::dist_to_goal_th_callback, this);
- -
29  footprint_sub_ = nh_.subscribe("/footprint", 1, &DWAPlanner::footprint_callback, this);
-
30  goal_sub_ = nh_.subscribe("/move_base_simple/goal", 1, &DWAPlanner::goal_callback, this);
-
31  local_map_sub_ = nh_.subscribe("/local_map", 1, &DWAPlanner::local_map_callback, this);
-
32  odom_sub_ = nh_.subscribe("/odom", 1, &DWAPlanner::odom_callback, this);
-
33  scan_sub_ = nh_.subscribe("/scan", 1, &DWAPlanner::scan_callback, this);
-
34  target_velocity_sub_ = nh_.subscribe("/target_velocity", 1, &DWAPlanner::target_velocity_callback, this);
-
35 
-
36  if (!use_footprint_)
-
37  footprint_subscribed_ = true;
-
38  if (!use_path_cost_)
- -
40  if (!use_scan_as_input_)
-
41  scan_updated_ = true;
-
42  else
-
43  local_map_updated_ = true;
+
11  : local_nh_("~"), odom_updated_(false), local_map_updated_(false), scan_updated_(false), has_reached_(false),
+
12  use_speed_cost_(false), odom_not_subscribe_count_(0), local_map_not_subscribe_count_(0),
+
13  scan_not_subscribe_count_(0)
+
14 {
+
15  load_params();
+
16 
+
17  ROS_INFO("=== DWA Planner ===");
+
18  print_params();
+
19 
+
20  velocity_pub_ = nh_.advertise<geometry_msgs::Twist>("/cmd_vel", 1);
+
21  candidate_trajectories_pub_ = local_nh_.advertise<visualization_msgs::MarkerArray>("candidate_trajectories", 1);
+
22  selected_trajectory_pub_ = local_nh_.advertise<visualization_msgs::Marker>("selected_trajectory", 1);
+
23  predict_footprints_pub_ = local_nh_.advertise<visualization_msgs::MarkerArray>("predict_footprints", 1);
+
24  finish_flag_pub_ = local_nh_.advertise<std_msgs::Bool>("finish_flag", 1);
+
25 
+
26  dist_to_goal_th_sub_ = nh_.subscribe("/dist_to_goal_th", 1, &DWAPlanner::dist_to_goal_th_callback, this);
+ +
28  footprint_sub_ = nh_.subscribe("/footprint", 1, &DWAPlanner::footprint_callback, this);
+
29  goal_sub_ = nh_.subscribe("/move_base_simple/goal", 1, &DWAPlanner::goal_callback, this);
+
30  local_map_sub_ = nh_.subscribe("/local_map", 1, &DWAPlanner::local_map_callback, this);
+
31  odom_sub_ = nh_.subscribe("/odom", 1, &DWAPlanner::odom_callback, this);
+
32  scan_sub_ = nh_.subscribe("/scan", 1, &DWAPlanner::scan_callback, this);
+
33  target_velocity_sub_ = nh_.subscribe("/target_velocity", 1, &DWAPlanner::target_velocity_callback, this);
+
34 
+
35  if (!use_footprint_)
+
36  footprint_ = geometry_msgs::PolygonStamped();
+
37  if (!use_path_cost_)
+
38  edge_points_on_path_ = nav_msgs::Path();
+
39  if (!use_scan_as_input_)
+
40  scan_updated_ = true;
+
41  else
+
42  local_map_updated_ = true;
+
43 }
44 
-
45  edge_points_on_path_.resize(2);
-
46 }
-
47 
-
48 DWAPlanner::State::State(void) : x_(0.0), y_(0.0), yaw_(0.0), velocity_(0.0), yawrate_(0.0) {}
-
49 
-
50 DWAPlanner::State::State(const double x, const double y, const double yaw, const double velocity, const double yawrate)
-
51  : x_(x), y_(y), yaw_(yaw), velocity_(velocity), yawrate_(yawrate)
-
52 {
-
53 }
-
54 
- -
56 
- -
58 {
-
59  ROS_INFO_STREAM("Window:");
-
60  ROS_INFO_STREAM("\tVelocity:");
-
61  ROS_INFO_STREAM("\t\tmax: " << max_velocity_);
-
62  ROS_INFO_STREAM("\t\tmin: " << min_velocity_);
-
63  ROS_INFO_STREAM("\tYawrate:");
-
64  ROS_INFO_STREAM("\t\tmax: " << max_yawrate_);
-
65  ROS_INFO_STREAM("\t\tmin: " << min_yawrate_);
-
66 }
-
67 
-
68 DWAPlanner::Cost::Cost(void) : obs_cost_(0.0), to_goal_cost_(0.0), speed_cost_(0.0), path_cost_(0.0), total_cost_(0.0)
-
69 {
-
70 }
-
71 
- -
73  const float obs_cost, const float to_goal_cost, const float speed_cost, const float path_cost,
-
74  const float total_cost)
-
75  : obs_cost_(obs_cost), to_goal_cost_(to_goal_cost), speed_cost_(speed_cost), path_cost_(path_cost),
-
76  total_cost_(total_cost)
-
77 {
-
78 }
-
79 
- -
81 {
-
82  ROS_INFO_STREAM("Cost: " << total_cost_);
-
83  ROS_INFO_STREAM("\tObs cost: " << obs_cost_);
-
84  ROS_INFO_STREAM("\tGoal cost: " << to_goal_cost_);
-
85  ROS_INFO_STREAM("\tSpeed cost: " << speed_cost_);
-
86  ROS_INFO_STREAM("\tPath cost: " << path_cost_);
-
87 }
-
88 
-
89 void DWAPlanner::Cost::calc_total_cost(void) { total_cost_ = obs_cost_ + to_goal_cost_ + speed_cost_ + path_cost_; }
-
90 
-
91 void DWAPlanner::goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
-
92 {
-
93  goal_msg_ = *msg;
-
94  if (goal_msg_.header.frame_id != global_frame_)
-
95  {
-
96  try
-
97  {
-
98  listener_.transformPose(global_frame_, ros::Time(0), goal_msg_, goal_msg_.header.frame_id, goal_msg_);
-
99  }
-
100  catch (tf::TransformException ex)
-
101  {
-
102  ROS_ERROR("%s", ex.what());
-
103  }
-
104  }
-
105  goal_subscribed_ = true;
-
106 }
-
107 
-
108 void DWAPlanner::scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
-
109 {
-
110  if (use_scan_as_input_)
-
111  scan_to_obs(*msg);
- -
113  scan_updated_ = true;
-
114 }
-
115 
-
116 void DWAPlanner::local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
-
117 {
-
118  if (!use_scan_as_input_)
-
119  raycast(*msg);
- -
121  local_map_updated_ = true;
-
122 }
-
123 
-
124 void DWAPlanner::odom_callback(const nav_msgs::OdometryConstPtr &msg)
-
125 {
-
126  current_cmd_vel_ = msg->twist.twist;
- -
128  odom_updated_ = true;
-
129 }
-
130 
-
131 void DWAPlanner::target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
-
132 {
-
133  target_velocity_ = std::min(msg->linear.x, max_velocity_);
-
134  ROS_INFO_STREAM_THROTTLE(1.0, "target velocity was updated to " << target_velocity_ << " [m/s]");
-
135 }
-
136 
-
137 void DWAPlanner::footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
-
138 {
-
139  footprint_ = *msg;
-
140  for (auto &point : footprint_.polygon.points)
-
141  {
-
142  point.x += point.x < 0 ? -footprint_padding_ : footprint_padding_;
-
143  point.y += point.y < 0 ? -footprint_padding_ : footprint_padding_;
-
144  }
-
145  footprint_subscribed_ = true;
-
146 }
-
147 
-
148 void DWAPlanner::dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
-
149 {
-
150  dist_to_goal_th_ = msg->data;
-
151  ROS_INFO_STREAM_THROTTLE(1.0, "distance to goal threshold was updated to " << dist_to_goal_th_ << " [m]");
-
152 }
-
153 
-
154 void DWAPlanner::edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
-
155 {
-
156  edge_points_on_path_.front() = msg->poses.front();
-
157  edge_points_on_path_.back() = msg->poses.back();
-
158  try
-
159  {
-
160  for (auto &pose : edge_points_on_path_)
-
161  {
-
162  listener_.transformPose(robot_frame_, ros::Time(0), pose, msg->header.frame_id, pose);
- -
164  }
-
165  }
-
166  catch (tf::TransformException ex)
-
167  {
-
168  ROS_ERROR("%s", ex.what());
-
169  }
-
170 }
-
171 
-
172 std::vector<DWAPlanner::State>
-
173 DWAPlanner::dwa_planning(const Eigen::Vector3d &goal, std::vector<std::pair<std::vector<State>, bool>> &trajectories)
-
174 {
-
175  Cost min_cost(0.0, 0.0, 0.0, 0.0, 1e6);
-
176  const Window dynamic_window = calc_dynamic_window();
-
177  std::vector<State> best_traj;
-
178  best_traj.resize(sim_time_samples_);
-
179  std::vector<Cost> costs;
-
180  const size_t costs_size = velocity_samples_ * (yawrate_samples_ + 1);
-
181  costs.reserve(costs_size);
-
182 
-
183  const double velocity_resolution =
-
184  std::max((dynamic_window.max_velocity_ - dynamic_window.min_velocity_) / (velocity_samples_ - 1), DBL_EPSILON);
-
185  const double yawrate_resolution =
-
186  std::max((dynamic_window.max_yawrate_ - dynamic_window.min_yawrate_) / (yawrate_samples_ - 1), DBL_EPSILON);
-
187 
-
188  int available_traj_count = 0;
-
189  for (int i = 0; i < velocity_samples_; i++)
-
190  {
-
191  const double v = dynamic_window.min_velocity_ + velocity_resolution * i;
-
192  for (int j = 0; j < yawrate_samples_; j++)
-
193  {
-
194  std::pair<std::vector<State>, bool> traj;
-
195  double y = dynamic_window.min_yawrate_ + yawrate_resolution * j;
-
196  if (v < slow_velocity_th_)
-
197  y = y > 0 ? std::max(y, min_yawrate_) : std::min(y, -min_yawrate_);
-
198  traj.first = generate_trajectory(v, y);
-
199  const Cost cost = evaluate_trajectory(traj.first, goal);
-
200  costs.push_back(cost);
-
201  if (cost.obs_cost_ == 1e6)
-
202  {
-
203  traj.second = false;
-
204  }
-
205  else
-
206  {
-
207  traj.second = true;
-
208  available_traj_count++;
-
209  }
-
210  trajectories.push_back(traj);
-
211  }
-
212 
-
213  if (dynamic_window.min_yawrate_ < 0.0 && 0.0 < dynamic_window.max_yawrate_)
-
214  {
-
215  std::pair<std::vector<State>, bool> traj;
-
216  traj.first = generate_trajectory(v, 0.0);
-
217  const Cost cost = evaluate_trajectory(traj.first, goal);
-
218  costs.push_back(cost);
-
219  if (cost.obs_cost_ == 1e6)
-
220  {
-
221  traj.second = false;
-
222  }
-
223  else
-
224  {
-
225  traj.second = true;
-
226  available_traj_count++;
-
227  }
-
228  trajectories.push_back(traj);
-
229  }
+
45 DWAPlanner::State::State(void) : x_(0.0), y_(0.0), yaw_(0.0), velocity_(0.0), yawrate_(0.0) {}
+
46 
+
47 DWAPlanner::State::State(const double x, const double y, const double yaw, const double velocity, const double yawrate)
+
48  : x_(x), y_(y), yaw_(yaw), velocity_(velocity), yawrate_(yawrate)
+
49 {
+
50 }
+
51 
+ +
53 
+ +
55 {
+
56  ROS_INFO_STREAM("Window:");
+
57  ROS_INFO_STREAM("\tVelocity:");
+
58  ROS_INFO_STREAM("\t\tmax: " << max_velocity_);
+
59  ROS_INFO_STREAM("\t\tmin: " << min_velocity_);
+
60  ROS_INFO_STREAM("\tYawrate:");
+
61  ROS_INFO_STREAM("\t\tmax: " << max_yawrate_);
+
62  ROS_INFO_STREAM("\t\tmin: " << min_yawrate_);
+
63 }
+
64 
+
65 DWAPlanner::Cost::Cost(void) : obs_cost_(0.0), to_goal_cost_(0.0), speed_cost_(0.0), path_cost_(0.0), total_cost_(0.0)
+
66 {
+
67 }
+
68 
+ +
70  const float obs_cost, const float to_goal_cost, const float speed_cost, const float path_cost,
+
71  const float total_cost)
+
72  : obs_cost_(obs_cost), to_goal_cost_(to_goal_cost), speed_cost_(speed_cost), path_cost_(path_cost),
+
73  total_cost_(total_cost)
+
74 {
+
75 }
+
76 
+ +
78 {
+
79  ROS_INFO_STREAM("Cost: " << total_cost_);
+
80  ROS_INFO_STREAM("\tObs cost: " << obs_cost_);
+
81  ROS_INFO_STREAM("\tGoal cost: " << to_goal_cost_);
+
82  ROS_INFO_STREAM("\tSpeed cost: " << speed_cost_);
+
83  ROS_INFO_STREAM("\tPath cost: " << path_cost_);
+
84 }
+
85 
+
86 void DWAPlanner::Cost::calc_total_cost(void) { total_cost_ = obs_cost_ + to_goal_cost_ + speed_cost_ + path_cost_; }
+
87 
+
88 void DWAPlanner::goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
+
89 {
+
90  goal_msg_ = *msg;
+
91  if (goal_msg_.value().header.frame_id != global_frame_)
+
92  {
+
93  try
+
94  {
+
95  listener_.transformPose(
+
96  global_frame_, ros::Time(0), goal_msg_.value(), goal_msg_.value().header.frame_id, goal_msg_.value());
+
97  }
+
98  catch (tf::TransformException ex)
+
99  {
+
100  ROS_ERROR("%s", ex.what());
+
101  }
+
102  }
+
103 }
+
104 
+
105 void DWAPlanner::scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
+
106 {
+
107  if (use_scan_as_input_)
+
108  create_obs_list(*msg);
+ +
110  scan_updated_ = true;
+
111 }
+
112 
+
113 void DWAPlanner::local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
+
114 {
+
115  if (!use_scan_as_input_)
+
116  create_obs_list(*msg);
+ +
118  local_map_updated_ = true;
+
119 }
+
120 
+
121 void DWAPlanner::odom_callback(const nav_msgs::OdometryConstPtr &msg)
+
122 {
+
123  current_cmd_vel_ = msg->twist.twist;
+ +
125  odom_updated_ = true;
+
126 }
+
127 
+
128 void DWAPlanner::target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
+
129 {
+
130  target_velocity_ = std::min(msg->linear.x, max_velocity_);
+
131  ROS_INFO_STREAM_THROTTLE(1.0, "target velocity was updated to " << target_velocity_ << " [m/s]");
+
132 }
+
133 
+
134 void DWAPlanner::footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
+
135 {
+
136  footprint_ = *msg;
+
137  for (auto &point : footprint_.value().polygon.points)
+
138  {
+
139  point.x += point.x < 0 ? -footprint_padding_ : footprint_padding_;
+
140  point.y += point.y < 0 ? -footprint_padding_ : footprint_padding_;
+
141  }
+
142 }
+
143 
+
144 void DWAPlanner::dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
+
145 {
+
146  dist_to_goal_th_ = msg->data;
+
147  ROS_INFO_STREAM_THROTTLE(1.0, "distance to goal threshold was updated to " << dist_to_goal_th_ << " [m]");
+
148 }
+
149 
+
150 void DWAPlanner::edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
+
151 {
+
152  if (!use_path_cost_)
+
153  return;
+
154  edge_points_on_path_ = *msg;
+
155  try
+
156  {
+
157  for (auto &pose : edge_points_on_path_.value().poses)
+
158  listener_.transformPose(robot_frame_, ros::Time(0), pose, msg->header.frame_id, pose);
+
159  }
+
160  catch (tf::TransformException ex)
+
161  {
+
162  ROS_ERROR("%s", ex.what());
+
163  }
+
164 }
+
165 
+
166 std::vector<DWAPlanner::State>
+
167 DWAPlanner::dwa_planning(const Eigen::Vector3d &goal, std::vector<std::pair<std::vector<State>, bool>> &trajectories)
+
168 {
+
169  Cost min_cost(0.0, 0.0, 0.0, 0.0, 1e6);
+
170  const Window dynamic_window = calc_dynamic_window();
+
171  std::vector<State> best_traj;
+
172  best_traj.resize(sim_time_samples_);
+
173  std::vector<Cost> costs;
+
174  const size_t costs_size = velocity_samples_ * (yawrate_samples_ + 1);
+
175  costs.reserve(costs_size);
+
176 
+
177  const double velocity_resolution =
+
178  std::max((dynamic_window.max_velocity_ - dynamic_window.min_velocity_) / (velocity_samples_ - 1), DBL_EPSILON);
+
179  const double yawrate_resolution =
+
180  std::max((dynamic_window.max_yawrate_ - dynamic_window.min_yawrate_) / (yawrate_samples_ - 1), DBL_EPSILON);
+
181 
+
182  int available_traj_count = 0;
+
183  for (int i = 0; i < velocity_samples_; i++)
+
184  {
+
185  const double v = dynamic_window.min_velocity_ + velocity_resolution * i;
+
186  for (int j = 0; j < yawrate_samples_; j++)
+
187  {
+
188  std::pair<std::vector<State>, bool> traj;
+
189  double y = dynamic_window.min_yawrate_ + yawrate_resolution * j;
+
190  if (v < slow_velocity_th_)
+
191  y = y > 0 ? std::max(y, min_yawrate_) : std::min(y, -min_yawrate_);
+
192  traj.first = generate_trajectory(v, y);
+
193  const Cost cost = evaluate_trajectory(traj.first, goal);
+
194  costs.push_back(cost);
+
195  if (cost.obs_cost_ == 1e6)
+
196  {
+
197  traj.second = false;
+
198  }
+
199  else
+
200  {
+
201  traj.second = true;
+
202  available_traj_count++;
+
203  }
+
204  trajectories.push_back(traj);
+
205  }
+
206 
+
207  if (dynamic_window.min_yawrate_ < 0.0 && 0.0 < dynamic_window.max_yawrate_)
+
208  {
+
209  std::pair<std::vector<State>, bool> traj;
+
210  traj.first = generate_trajectory(v, 0.0);
+
211  const Cost cost = evaluate_trajectory(traj.first, goal);
+
212  costs.push_back(cost);
+
213  if (cost.obs_cost_ == 1e6)
+
214  {
+
215  traj.second = false;
+
216  }
+
217  else
+
218  {
+
219  traj.second = true;
+
220  available_traj_count++;
+
221  }
+
222  trajectories.push_back(traj);
+
223  }
+
224  }
+
225 
+
226  if (available_traj_count == 0)
+
227  {
+
228  ROS_ERROR_THROTTLE(1.0, "No available trajectory");
+
229  best_traj = generate_trajectory(0.0, 0.0);
230  }
-
231 
-
232  if (available_traj_count == 0)
-
233  {
-
234  ROS_ERROR_THROTTLE(1.0, "No available trajectory");
-
235  best_traj = generate_trajectory(0.0, 0.0);
-
236  }
-
237  else
-
238  {
-
239  normalize_costs(costs);
-
240  for (int i = 0; i < costs.size(); i++)
-
241  {
-
242  if (costs[i].obs_cost_ != 1e6)
-
243  {
-
244  costs[i].to_goal_cost_ *= to_goal_cost_gain_;
-
245  costs[i].obs_cost_ *= obs_cost_gain_;
-
246  costs[i].speed_cost_ *= speed_cost_gain_;
-
247  costs[i].path_cost_ *= path_cost_gain_;
-
248  costs[i].calc_total_cost();
-
249  if (costs[i].total_cost_ < min_cost.total_cost_)
-
250  {
-
251  min_cost = costs[i];
-
252  best_traj = trajectories[i].first;
-
253  }
-
254  }
-
255  }
-
256  }
+
231  else
+
232  {
+
233  normalize_costs(costs);
+
234  for (int i = 0; i < costs.size(); i++)
+
235  {
+
236  if (costs[i].obs_cost_ != 1e6)
+
237  {
+
238  costs[i].to_goal_cost_ *= to_goal_cost_gain_;
+
239  costs[i].obs_cost_ *= obs_cost_gain_;
+
240  costs[i].speed_cost_ *= speed_cost_gain_;
+
241  costs[i].path_cost_ *= path_cost_gain_;
+
242  costs[i].calc_total_cost();
+
243  if (costs[i].total_cost_ < min_cost.total_cost_)
+
244  {
+
245  min_cost = costs[i];
+
246  best_traj = trajectories[i].first;
+
247  }
+
248  }
+
249  }
+
250  }
+
251 
+
252  ROS_INFO("===");
+
253  ROS_INFO_STREAM("(v, y) = (" << best_traj.front().velocity_ << ", " << best_traj.front().yawrate_ << ")");
+
254  min_cost.show();
+
255  ROS_INFO_STREAM("num of trajectories available: " << available_traj_count << " of " << trajectories.size());
+
256  ROS_INFO(" ");
257 
-
258  ROS_INFO("===");
-
259  ROS_INFO_STREAM("(v, y) = (" << best_traj.front().velocity_ << ", " << best_traj.front().yawrate_ << ")");
-
260  min_cost.show();
-
261  ROS_INFO_STREAM("num of trajectories available: " << available_traj_count << " of " << trajectories.size());
-
262  ROS_INFO(" ");
-
263 
-
264  return best_traj;
-
265 }
-
266 
-
267 void DWAPlanner::normalize_costs(std::vector<DWAPlanner::Cost> &costs)
-
268 {
-
269  Cost min_cost(1e6, 1e6, 1e6, 1e6, 1e6), max_cost;
-
270 
-
271  for (const auto &cost : costs)
-
272  {
-
273  if (cost.obs_cost_ != 1e6)
-
274  {
-
275  min_cost.obs_cost_ = std::min(min_cost.obs_cost_, cost.obs_cost_);
-
276  max_cost.obs_cost_ = std::max(max_cost.obs_cost_, cost.obs_cost_);
-
277  min_cost.to_goal_cost_ = std::min(min_cost.to_goal_cost_, cost.to_goal_cost_);
-
278  max_cost.to_goal_cost_ = std::max(max_cost.to_goal_cost_, cost.to_goal_cost_);
-
279  if (use_speed_cost_)
-
280  {
-
281  min_cost.speed_cost_ = std::min(min_cost.speed_cost_, cost.speed_cost_);
-
282  max_cost.speed_cost_ = std::max(max_cost.speed_cost_, cost.speed_cost_);
-
283  }
-
284  if (use_path_cost_)
-
285  {
-
286  min_cost.path_cost_ = std::min(min_cost.path_cost_, cost.path_cost_);
-
287  max_cost.path_cost_ = std::max(max_cost.path_cost_, cost.path_cost_);
-
288  }
-
289  }
-
290  }
-
291 
-
292  for (auto &cost : costs)
-
293  {
-
294  if (cost.obs_cost_ != 1e6)
-
295  {
-
296  cost.obs_cost_ = (cost.obs_cost_ - min_cost.obs_cost_) / (max_cost.obs_cost_ - min_cost.obs_cost_ + DBL_EPSILON);
-
297  cost.to_goal_cost_ = (cost.to_goal_cost_ - min_cost.to_goal_cost_) /
-
298  (max_cost.to_goal_cost_ - min_cost.to_goal_cost_ + DBL_EPSILON);
-
299  if (use_speed_cost_)
-
300  cost.speed_cost_ =
-
301  (cost.speed_cost_ - min_cost.speed_cost_) / (max_cost.speed_cost_ - min_cost.speed_cost_ + DBL_EPSILON);
-
302  if (use_path_cost_)
-
303  cost.path_cost_ =
-
304  (cost.path_cost_ - min_cost.path_cost_) / (max_cost.path_cost_ - min_cost.path_cost_ + DBL_EPSILON);
-
305  }
-
306  }
-
307 }
-
308 
- -
310 {
-
311  ros::Rate loop_rate(hz_);
-
312  while (ros::ok())
-
313  {
-
314  geometry_msgs::Twist cmd_vel;
-
315  if (can_move())
-
316  cmd_vel = calc_cmd_vel();
-
317  velocity_pub_.publish(cmd_vel);
- -
319  if (has_finished_.data)
-
320  ros::Duration(sleep_time_after_finish_).sleep();
-
321 
-
322  if (use_scan_as_input_)
-
323  scan_updated_ = false;
-
324  else
-
325  local_map_updated_ = false;
-
326  odom_updated_ = false;
-
327  has_finished_.data = false;
-
328 
-
329  ros::spinOnce();
-
330  loop_rate.sleep();
-
331  }
-
332 }
-
333 
- -
335 {
- -
337  ROS_WARN_THROTTLE(1.0, "Robot Footprint has not been updated");
-
338  if (!goal_subscribed_)
-
339  ROS_WARN_THROTTLE(1.0, "Local goal has not been updated");
- -
341  ROS_WARN_THROTTLE(1.0, "Edge on global path has not been updated");
- -
343  ROS_WARN_THROTTLE(1.0, "Odom has not been updated");
- -
345  ROS_WARN_THROTTLE(1.0, "Local map has not been updated");
- -
347  ROS_WARN_THROTTLE(1.0, "Scan has not been updated");
-
348 
-
349  if (!odom_updated_)
- -
351  if (!local_map_updated_)
- -
353  if (!scan_updated_)
- -
355 
- - - -
359  return true;
-
360  else
-
361  return false;
-
362 }
-
363 
-
364 geometry_msgs::Twist DWAPlanner::calc_cmd_vel(void)
-
365 {
-
366  geometry_msgs::Twist cmd_vel;
-
367  std::pair<std::vector<State>, bool> best_traj;
-
368  std::vector<std::pair<std::vector<State>, bool>> trajectories;
-
369  const size_t trajectories_size = velocity_samples_ * (yawrate_samples_ + 1);
-
370  trajectories.reserve(trajectories_size);
-
371 
-
372  geometry_msgs::PoseStamped goal_;
-
373  try
-
374  {
-
375  listener_.transformPose(robot_frame_, ros::Time(0), goal_msg_, goal_msg_.header.frame_id, goal_);
-
376  }
-
377  catch (tf::TransformException ex)
-
378  {
-
379  ROS_ERROR("%s", ex.what());
-
380  }
-
381  const Eigen::Vector3d goal(goal_.pose.position.x, goal_.pose.position.y, tf::getYaw(goal_.pose.orientation));
-
382 
-
383  const double angle_to_goal = atan2(goal.y(), goal.x());
-
384  if (M_PI / 4.0 < fabs(angle_to_goal))
-
385  use_speed_cost_ = true;
-
386 
-
387  if (dist_to_goal_th_ < goal.segment(0, 2).norm() && !has_reached_)
-
388  {
-
389  if (can_adjust_robot_direction(goal))
-
390  {
-
391  cmd_vel.angular.z = angle_to_goal > 0 ? std::min(angle_to_goal, max_in_place_yawrate_)
-
392  : std::max(angle_to_goal, -max_in_place_yawrate_);
-
393  cmd_vel.angular.z = cmd_vel.angular.z > 0 ? std::max(cmd_vel.angular.z, min_in_place_yawrate_)
-
394  : std::min(cmd_vel.angular.z, -min_in_place_yawrate_);
-
395  best_traj.first = generate_trajectory(cmd_vel.angular.z, goal);
-
396  trajectories.push_back(best_traj);
+
258  return best_traj;
+
259 }
+
260 
+
261 void DWAPlanner::normalize_costs(std::vector<DWAPlanner::Cost> &costs)
+
262 {
+
263  Cost min_cost(1e6, 1e6, 1e6, 1e6, 1e6), max_cost;
+
264 
+
265  for (const auto &cost : costs)
+
266  {
+
267  if (cost.obs_cost_ != 1e6)
+
268  {
+
269  min_cost.obs_cost_ = std::min(min_cost.obs_cost_, cost.obs_cost_);
+
270  max_cost.obs_cost_ = std::max(max_cost.obs_cost_, cost.obs_cost_);
+
271  min_cost.to_goal_cost_ = std::min(min_cost.to_goal_cost_, cost.to_goal_cost_);
+
272  max_cost.to_goal_cost_ = std::max(max_cost.to_goal_cost_, cost.to_goal_cost_);
+
273  if (use_speed_cost_)
+
274  {
+
275  min_cost.speed_cost_ = std::min(min_cost.speed_cost_, cost.speed_cost_);
+
276  max_cost.speed_cost_ = std::max(max_cost.speed_cost_, cost.speed_cost_);
+
277  }
+
278  if (use_path_cost_)
+
279  {
+
280  min_cost.path_cost_ = std::min(min_cost.path_cost_, cost.path_cost_);
+
281  max_cost.path_cost_ = std::max(max_cost.path_cost_, cost.path_cost_);
+
282  }
+
283  }
+
284  }
+
285 
+
286  for (auto &cost : costs)
+
287  {
+
288  if (cost.obs_cost_ != 1e6)
+
289  {
+
290  cost.obs_cost_ = (cost.obs_cost_ - min_cost.obs_cost_) / (max_cost.obs_cost_ - min_cost.obs_cost_ + DBL_EPSILON);
+
291  cost.to_goal_cost_ = (cost.to_goal_cost_ - min_cost.to_goal_cost_) /
+
292  (max_cost.to_goal_cost_ - min_cost.to_goal_cost_ + DBL_EPSILON);
+
293  if (use_speed_cost_)
+
294  cost.speed_cost_ =
+
295  (cost.speed_cost_ - min_cost.speed_cost_) / (max_cost.speed_cost_ - min_cost.speed_cost_ + DBL_EPSILON);
+
296  if (use_path_cost_)
+
297  cost.path_cost_ =
+
298  (cost.path_cost_ - min_cost.path_cost_) / (max_cost.path_cost_ - min_cost.path_cost_ + DBL_EPSILON);
+
299  }
+
300  }
+
301 }
+
302 
+ +
304 {
+
305  ros::Rate loop_rate(hz_);
+
306  while (ros::ok())
+
307  {
+
308  geometry_msgs::Twist cmd_vel;
+
309  if (can_move())
+
310  cmd_vel = calc_cmd_vel();
+
311  velocity_pub_.publish(cmd_vel);
+ +
313  if (has_finished_.data)
+
314  ros::Duration(sleep_time_after_finish_).sleep();
+
315 
+
316  if (use_scan_as_input_)
+
317  scan_updated_ = false;
+
318  else
+
319  local_map_updated_ = false;
+
320  odom_updated_ = false;
+
321  has_finished_.data = false;
+
322 
+
323  ros::spinOnce();
+
324  loop_rate.sleep();
+
325  }
+
326 }
+
327 
+ +
329 {
+
330  if (!footprint_.has_value())
+
331  ROS_WARN_THROTTLE(1.0, "Robot Footprint has not been updated");
+
332  if (!goal_msg_.has_value())
+
333  ROS_WARN_THROTTLE(1.0, "Local goal has not been updated");
+
334  if (!edge_points_on_path_.has_value())
+
335  ROS_WARN_THROTTLE(1.0, "Edge on global path has not been updated");
+ +
337  ROS_WARN_THROTTLE(1.0, "Odom has not been updated");
+ +
339  ROS_WARN_THROTTLE(1.0, "Local map has not been updated");
+ +
341  ROS_WARN_THROTTLE(1.0, "Scan has not been updated");
+
342 
+
343  if (!odom_updated_)
+ +
345  if (!local_map_updated_)
+ +
347  if (!scan_updated_)
+ +
349 
+
350  if (footprint_.has_value() && goal_msg_.has_value() && edge_points_on_path_.has_value() &&
+ + +
353  return true;
+
354  else
+
355  return false;
+
356 }
+
357 
+
358 geometry_msgs::Twist DWAPlanner::calc_cmd_vel(void)
+
359 {
+
360  geometry_msgs::Twist cmd_vel;
+
361  std::pair<std::vector<State>, bool> best_traj;
+
362  std::vector<std::pair<std::vector<State>, bool>> trajectories;
+
363  const size_t trajectories_size = velocity_samples_ * (yawrate_samples_ + 1);
+
364  trajectories.reserve(trajectories_size);
+
365 
+
366  geometry_msgs::PoseStamped goal_;
+
367  try
+
368  {
+
369  listener_.transformPose(robot_frame_, ros::Time(0), goal_msg_.value(), goal_msg_.value().header.frame_id, goal_);
+
370  }
+
371  catch (tf::TransformException ex)
+
372  {
+
373  ROS_ERROR("%s", ex.what());
+
374  }
+
375  const Eigen::Vector3d goal(goal_.pose.position.x, goal_.pose.position.y, tf::getYaw(goal_.pose.orientation));
+
376 
+
377  const double angle_to_goal = atan2(goal.y(), goal.x());
+
378  if (M_PI / 4.0 < fabs(angle_to_goal))
+
379  use_speed_cost_ = true;
+
380 
+
381  if (dist_to_goal_th_ < goal.segment(0, 2).norm() && !has_reached_)
+
382  {
+
383  if (can_adjust_robot_direction(goal))
+
384  {
+
385  cmd_vel.angular.z = angle_to_goal > 0 ? std::min(angle_to_goal, max_in_place_yawrate_)
+
386  : std::max(angle_to_goal, -max_in_place_yawrate_);
+
387  cmd_vel.angular.z = cmd_vel.angular.z > 0 ? std::max(cmd_vel.angular.z, min_in_place_yawrate_)
+
388  : std::min(cmd_vel.angular.z, -min_in_place_yawrate_);
+
389  best_traj.first = generate_trajectory(cmd_vel.angular.z, goal);
+
390  trajectories.push_back(best_traj);
+
391  }
+
392  else
+
393  {
+
394  best_traj.first = dwa_planning(goal, trajectories);
+
395  cmd_vel.linear.x = best_traj.first.front().velocity_;
+
396  cmd_vel.angular.z = best_traj.first.front().yawrate_;
397  }
-
398  else
-
399  {
-
400  best_traj.first = dwa_planning(goal, trajectories);
-
401  cmd_vel.linear.x = best_traj.first.front().velocity_;
-
402  cmd_vel.angular.z = best_traj.first.front().yawrate_;
-
403  }
-
404  }
-
405  else
-
406  {
-
407  has_reached_ = true;
-
408  if (turn_direction_th_ < fabs(goal[2]))
-
409  {
-
410  cmd_vel.angular.z =
-
411  goal[2] > 0 ? std::min(goal[2], max_in_place_yawrate_) : std::max(goal[2], -max_in_place_yawrate_);
-
412  cmd_vel.angular.z = cmd_vel.angular.z > 0 ? std::max(cmd_vel.angular.z, min_in_place_yawrate_)
-
413  : std::min(cmd_vel.angular.z, -min_in_place_yawrate_);
-
414  }
-
415  else
-
416  {
-
417  has_finished_.data = true;
-
418  has_reached_ = false;
-
419  }
-
420  best_traj.first = generate_trajectory(cmd_vel.linear.x, cmd_vel.angular.z);
-
421  trajectories.push_back(best_traj);
-
422  }
-
423 
-
424  for (int i = 0; i < trajectories_size; i++)
-
425  trajectories.push_back(trajectories.front());
+
398  }
+
399  else
+
400  {
+
401  has_reached_ = true;
+
402  if (turn_direction_th_ < fabs(goal[2]))
+
403  {
+
404  cmd_vel.angular.z =
+
405  goal[2] > 0 ? std::min(goal[2], max_in_place_yawrate_) : std::max(goal[2], -max_in_place_yawrate_);
+
406  cmd_vel.angular.z = cmd_vel.angular.z > 0 ? std::max(cmd_vel.angular.z, min_in_place_yawrate_)
+
407  : std::min(cmd_vel.angular.z, -min_in_place_yawrate_);
+
408  }
+
409  else
+
410  {
+
411  has_finished_.data = true;
+
412  has_reached_ = false;
+
413  }
+
414  best_traj.first = generate_trajectory(cmd_vel.linear.x, cmd_vel.angular.z);
+
415  trajectories.push_back(best_traj);
+
416  }
+
417 
+
418  for (int i = 0; i < trajectories_size; i++)
+
419  trajectories.push_back(trajectories.front());
+
420 
+ + + +
424 
+
425  use_speed_cost_ = false;
426 
- - - -
430 
-
431  use_speed_cost_ = false;
-
432 
-
433  return cmd_vel;
-
434 }
+
427  return cmd_vel;
+
428 }
+
429 
+
430 bool DWAPlanner::can_adjust_robot_direction(const Eigen::Vector3d &goal)
+
431 {
+
432  const double angle_to_goal = atan2(goal.y(), goal.x());
+
433  if (fabs(angle_to_goal) < angle_to_goal_th_)
+
434  return false;
435 
-
436 bool DWAPlanner::can_adjust_robot_direction(const Eigen::Vector3d &goal)
-
437 {
-
438  const double angle_to_goal = atan2(goal.y(), goal.x());
-
439  if (fabs(angle_to_goal) < angle_to_goal_th_)
-
440  return false;
-
441 
-
442  const double yawrate = std::min(std::max(angle_to_goal, -max_in_place_yawrate_), max_in_place_yawrate_);
-
443  std::vector<State> traj = generate_trajectory(yawrate, goal);
+
436  const double yawrate = std::min(std::max(angle_to_goal, -max_in_place_yawrate_), max_in_place_yawrate_);
+
437  std::vector<State> traj = generate_trajectory(yawrate, goal);
+
438 
+
439  if (!check_collision(traj))
+
440  return true;
+
441  else
+
442  return false;
+
443 }
444 
-
445  if (!check_collision(traj))
-
446  return true;
-
447  else
+
445 bool DWAPlanner::check_collision(const std::vector<State> &traj)
+
446 {
+
447  if (!use_footprint_)
448  return false;
-
449 }
-
450 
-
451 bool DWAPlanner::check_collision(const std::vector<State> &traj)
-
452 {
-
453  if (!use_footprint_)
-
454  return false;
-
455 
-
456  for (const auto &state : traj)
-
457  {
-
458  for (const auto &obs : obs_list_.poses)
-
459  {
-
460  const geometry_msgs::PolygonStamped footprint = move_footprint(state);
-
461  if (is_inside_of_robot(obs.position, footprint, state))
-
462  return true;
-
463  }
-
464  }
-
465 
-
466  return false;
-
467 }
-
468 
- -
470 {
-
471  Window window;
-
472  window.min_velocity_ = std::max((current_cmd_vel_.linear.x - max_deceleration_ * sim_period_), min_velocity_);
- -
474  window.min_yawrate_ = std::max((current_cmd_vel_.angular.z - max_d_yawrate_ * sim_period_), -max_yawrate_);
-
475  window.max_yawrate_ = std::min((current_cmd_vel_.angular.z + max_d_yawrate_ * sim_period_), max_yawrate_);
-
476  return window;
+
449 
+
450  for (const auto &state : traj)
+
451  {
+
452  for (const auto &obs : obs_list_.poses)
+
453  {
+
454  const geometry_msgs::PolygonStamped footprint = move_footprint(state);
+
455  if (is_inside_of_robot(obs.position, footprint, state))
+
456  return true;
+
457  }
+
458  }
+
459 
+
460  return false;
+
461 }
+
462 
+ +
464 {
+
465  Window window;
+
466  window.min_velocity_ = std::max((current_cmd_vel_.linear.x - max_deceleration_ * sim_period_), min_velocity_);
+ +
468  window.min_yawrate_ = std::max((current_cmd_vel_.angular.z - max_d_yawrate_ * sim_period_), -max_yawrate_);
+
469  window.max_yawrate_ = std::min((current_cmd_vel_.angular.z + max_d_yawrate_ * sim_period_), max_yawrate_);
+
470  return window;
+
471 }
+
472 
+
473 float DWAPlanner::calc_to_goal_cost(const std::vector<State> &traj, const Eigen::Vector3d &goal)
+
474 {
+
475  Eigen::Vector3d last_position(traj.back().x_, traj.back().y_, traj.back().yaw_);
+
476  return (last_position.segment(0, 2) - goal.segment(0, 2)).norm();
477 }
478 
-
479 float DWAPlanner::calc_to_goal_cost(const std::vector<State> &traj, const Eigen::Vector3d &goal)
+
479 float DWAPlanner::calc_obs_cost(const std::vector<State> &traj)
480 {
-
481  Eigen::Vector3d last_position(traj.back().x_, traj.back().y_, traj.back().yaw_);
-
482  return (last_position.segment(0, 2) - goal.segment(0, 2)).norm();
-
483 }
-
484 
-
485 float DWAPlanner::calc_obs_cost(const std::vector<State> &traj)
-
486 {
-
487  float min_dist = obs_range_;
-
488  for (const auto &state : traj)
-
489  {
-
490  for (const auto &obs : obs_list_.poses)
-
491  {
-
492  float dist;
-
493  if (use_footprint_)
-
494  dist = calc_dist_from_robot(obs.position, state);
-
495  else
-
496  dist = hypot((state.x_ - obs.position.x), (state.y_ - obs.position.y)) - robot_radius_ - footprint_padding_;
-
497 
-
498  if (dist < DBL_EPSILON)
-
499  return 1e6;
-
500  min_dist = std::min(min_dist, dist);
-
501  }
-
502  }
-
503  return obs_range_ - min_dist;
-
504 }
-
505 
-
506 float DWAPlanner::calc_speed_cost(const std::vector<State> &traj)
-
507 {
-
508  if (!use_speed_cost_)
-
509  return 0.0;
-
510  const Window dynamic_window = calc_dynamic_window();
-
511  return dynamic_window.max_velocity_ - traj.front().velocity_;
-
512 }
-
513 
-
514 float DWAPlanner::calc_path_cost(const std::vector<State> &traj)
-
515 {
-
516  if (!use_path_cost_)
-
517  return 0.0;
-
518  else
-
519  return calc_dist_to_path(traj.back());
-
520 }
-
521 
- -
523 {
-
524  geometry_msgs::Point edge_point1 = edge_points_on_path_.front().pose.position;
-
525  geometry_msgs::Point edge_point2 = edge_points_on_path_.back().pose.position;
-
526  const float a = edge_point2.y - edge_point1.y;
-
527  const float b = -(edge_point2.x - edge_point1.x);
-
528  const float c = -a * edge_point1.x - b * edge_point1.y;
-
529 
-
530  return fabs(a * state.x_ + b * state.y_ + c) / (hypot(a, b) + DBL_EPSILON);
-
531 }
-
532 
-
533 std::vector<DWAPlanner::State> DWAPlanner::generate_trajectory(const double velocity, const double yawrate)
-
534 {
-
535  std::vector<State> trajectory;
-
536  trajectory.resize(sim_time_samples_);
-
537  State state;
-
538  for (int i = 0; i < sim_time_samples_; i++)
-
539  {
-
540  motion(state, velocity, yawrate);
-
541  trajectory[i] = state;
-
542  }
-
543  return trajectory;
-
544 }
-
545 
-
546 std::vector<DWAPlanner::State> DWAPlanner::generate_trajectory(const double yawrate, const Eigen::Vector3d &goal)
-
547 {
-
548  const double target_direction = atan2(goal.y(), goal.x()) > 0 ? sim_direction_ : -sim_direction_;
-
549  const double predict_time = target_direction / (yawrate + DBL_EPSILON);
-
550  std::vector<State> trajectory;
-
551  trajectory.resize(sim_time_samples_);
-
552  State state;
-
553  for (int i = 0; i < sim_time_samples_; i++)
-
554  {
-
555  motion(state, 0.0, yawrate);
-
556  trajectory[i] = state;
-
557  }
-
558  return trajectory;
-
559 }
-
560 
-
561 DWAPlanner::Cost DWAPlanner::evaluate_trajectory(const std::vector<State> &trajectory, const Eigen::Vector3d &goal)
-
562 {
-
563  Cost cost;
-
564  cost.to_goal_cost_ = calc_to_goal_cost(trajectory, goal);
-
565  cost.obs_cost_ = calc_obs_cost(trajectory);
-
566  cost.speed_cost_ = calc_speed_cost(trajectory);
-
567  cost.path_cost_ = calc_path_cost(trajectory);
-
568  cost.calc_total_cost();
-
569  return cost;
-
570 }
-
571 
-
572 geometry_msgs::Point DWAPlanner::calc_intersection(
-
573  const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
-
574 {
-
575  for (int i = 0; i < footprint.polygon.points.size(); i++)
-
576  {
-
577  const Eigen::Vector3d vector_A(obstacle.x, obstacle.y, 0.0);
-
578  const Eigen::Vector3d vector_B(state.x_, state.y_, 0.0);
-
579  const Eigen::Vector3d vector_C(footprint.polygon.points[i].x, footprint.polygon.points[i].y, 0.0);
-
580  Eigen::Vector3d vector_D(0.0, 0.0, 0.0);
-
581  if (i != footprint.polygon.points.size() - 1)
-
582  vector_D << footprint.polygon.points[i + 1].x, footprint.polygon.points[i + 1].y, 0.0;
-
583  else
-
584  vector_D << footprint.polygon.points[0].x, footprint.polygon.points[0].y, 0.0;
-
585 
-
586  const double deno = (vector_B - vector_A).cross(vector_D - vector_C).z();
-
587  const double s = (vector_C - vector_A).cross(vector_D - vector_C).z() / deno;
-
588  const double t = (vector_B - vector_A).cross(vector_A - vector_C).z() / deno;
-
589 
-
590  geometry_msgs::Point point;
-
591  point.x = vector_A.x() + s * (vector_B - vector_A).x();
-
592  point.y = vector_A.y() + s * (vector_B - vector_A).y();
-
593 
-
594  // cross
-
595  if (!(s < 0.0 || 1.0 < s || t < 0.0 || 1.0 < t))
-
596  return point;
-
597  }
+
481  float min_dist = obs_range_;
+
482  for (const auto &state : traj)
+
483  {
+
484  for (const auto &obs : obs_list_.poses)
+
485  {
+
486  float dist;
+
487  if (use_footprint_)
+
488  dist = calc_dist_from_robot(obs.position, state);
+
489  else
+
490  dist = hypot((state.x_ - obs.position.x), (state.y_ - obs.position.y)) - robot_radius_ - footprint_padding_;
+
491 
+
492  if (dist < DBL_EPSILON)
+
493  return 1e6;
+
494  min_dist = std::min(min_dist, dist);
+
495  }
+
496  }
+
497  return obs_range_ - min_dist;
+
498 }
+
499 
+
500 float DWAPlanner::calc_speed_cost(const std::vector<State> &traj)
+
501 {
+
502  if (!use_speed_cost_)
+
503  return 0.0;
+
504  const Window dynamic_window = calc_dynamic_window();
+
505  return dynamic_window.max_velocity_ - traj.front().velocity_;
+
506 }
+
507 
+
508 float DWAPlanner::calc_path_cost(const std::vector<State> &traj)
+
509 {
+
510  if (!use_path_cost_)
+
511  return 0.0;
+
512  else
+
513  return calc_dist_to_path(traj.back());
+
514 }
+
515 
+ +
517 {
+
518  geometry_msgs::Point edge_point1 = edge_points_on_path_.value().poses.front().pose.position;
+
519  geometry_msgs::Point edge_point2 = edge_points_on_path_.value().poses.back().pose.position;
+
520  const float a = edge_point2.y - edge_point1.y;
+
521  const float b = -(edge_point2.x - edge_point1.x);
+
522  const float c = -a * edge_point1.x - b * edge_point1.y;
+
523 
+
524  return fabs(a * state.x_ + b * state.y_ + c) / (hypot(a, b) + DBL_EPSILON);
+
525 }
+
526 
+
527 std::vector<DWAPlanner::State> DWAPlanner::generate_trajectory(const double velocity, const double yawrate)
+
528 {
+
529  std::vector<State> trajectory;
+
530  trajectory.resize(sim_time_samples_);
+
531  State state;
+
532  for (int i = 0; i < sim_time_samples_; i++)
+
533  {
+
534  motion(state, velocity, yawrate);
+
535  trajectory[i] = state;
+
536  }
+
537  return trajectory;
+
538 }
+
539 
+
540 std::vector<DWAPlanner::State> DWAPlanner::generate_trajectory(const double yawrate, const Eigen::Vector3d &goal)
+
541 {
+
542  const double target_direction = atan2(goal.y(), goal.x()) > 0 ? sim_direction_ : -sim_direction_;
+
543  const double predict_time = target_direction / (yawrate + DBL_EPSILON);
+
544  std::vector<State> trajectory;
+
545  trajectory.resize(sim_time_samples_);
+
546  State state;
+
547  for (int i = 0; i < sim_time_samples_; i++)
+
548  {
+
549  motion(state, 0.0, yawrate);
+
550  trajectory[i] = state;
+
551  }
+
552  return trajectory;
+
553 }
+
554 
+
555 DWAPlanner::Cost DWAPlanner::evaluate_trajectory(const std::vector<State> &trajectory, const Eigen::Vector3d &goal)
+
556 {
+
557  Cost cost;
+
558  cost.to_goal_cost_ = calc_to_goal_cost(trajectory, goal);
+
559  cost.obs_cost_ = calc_obs_cost(trajectory);
+
560  cost.speed_cost_ = calc_speed_cost(trajectory);
+
561  cost.path_cost_ = calc_path_cost(trajectory);
+
562  cost.calc_total_cost();
+
563  return cost;
+
564 }
+
565 
+
566 geometry_msgs::Point DWAPlanner::calc_intersection(
+
567  const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
+
568 {
+
569  for (int i = 0; i < footprint.polygon.points.size(); i++)
+
570  {
+
571  const Eigen::Vector3d vector_A(obstacle.x, obstacle.y, 0.0);
+
572  const Eigen::Vector3d vector_B(state.x_, state.y_, 0.0);
+
573  const Eigen::Vector3d vector_C(footprint.polygon.points[i].x, footprint.polygon.points[i].y, 0.0);
+
574  Eigen::Vector3d vector_D(0.0, 0.0, 0.0);
+
575  if (i != footprint.polygon.points.size() - 1)
+
576  vector_D << footprint.polygon.points[i + 1].x, footprint.polygon.points[i + 1].y, 0.0;
+
577  else
+
578  vector_D << footprint.polygon.points[0].x, footprint.polygon.points[0].y, 0.0;
+
579 
+
580  const double deno = (vector_B - vector_A).cross(vector_D - vector_C).z();
+
581  const double s = (vector_C - vector_A).cross(vector_D - vector_C).z() / deno;
+
582  const double t = (vector_B - vector_A).cross(vector_A - vector_C).z() / deno;
+
583 
+
584  geometry_msgs::Point point;
+
585  point.x = vector_A.x() + s * (vector_B - vector_A).x();
+
586  point.y = vector_A.y() + s * (vector_B - vector_A).y();
+
587 
+
588  // cross
+
589  if (!(s < 0.0 || 1.0 < s || t < 0.0 || 1.0 < t))
+
590  return point;
+
591  }
+
592 
+
593  geometry_msgs::Point point;
+
594  point.x = 1e6;
+
595  point.y = 1e6;
+
596  return point;
+
597 }
598 
-
599  geometry_msgs::Point point;
-
600  point.x = 1e6;
-
601  point.y = 1e6;
-
602  return point;
-
603 }
-
604 
-
605 float DWAPlanner::calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
-
606 {
-
607  const geometry_msgs::PolygonStamped footprint = move_footprint(state);
-
608  if (is_inside_of_robot(obstacle, footprint, state))
-
609  {
-
610  return 0.0;
-
611  }
-
612  else
-
613  {
-
614  geometry_msgs::Point intersection = calc_intersection(obstacle, state, footprint);
-
615  return hypot((obstacle.x - intersection.x), (obstacle.y - intersection.y));
-
616  }
-
617 }
-
618 
-
619 geometry_msgs::PolygonStamped DWAPlanner::move_footprint(const State &target_pose)
-
620 {
-
621  geometry_msgs::PolygonStamped footprint;
-
622  if (use_footprint_)
-
623  {
-
624  footprint = footprint_;
-
625  }
-
626  else
-
627  {
-
628  const int plot_num = 20;
-
629  for (int i = 0; i < plot_num; i++)
-
630  {
-
631  geometry_msgs::Point32 point;
-
632  point.x = (robot_radius_ + footprint_padding_) * cos(2 * M_PI * i / plot_num);
-
633  point.y = robot_radius_ * sin(2 * M_PI * i / plot_num);
-
634  footprint.polygon.points.push_back(point);
-
635  }
-
636  }
-
637 
-
638  footprint.header.stamp = ros::Time::now();
-
639 
-
640  for (auto &point : footprint.polygon.points)
-
641  {
-
642  Eigen::VectorXf point_in(2);
-
643  point_in << point.x, point.y;
-
644  Eigen::Matrix2f rot;
-
645  rot = Eigen::Rotation2Df(target_pose.yaw_);
-
646  const Eigen::VectorXf point_out = rot * point_in;
-
647 
-
648  point.x = point_out.x() + target_pose.x_;
-
649  point.y = point_out.y() + target_pose.y_;
-
650  }
-
651 
-
652  return footprint;
-
653 }
-
654 
- -
656  const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
-
657 {
-
658  geometry_msgs::Point32 state_point;
-
659  state_point.x = state.x_;
-
660  state_point.y = state.y_;
+
599 float DWAPlanner::calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
+
600 {
+
601  const geometry_msgs::PolygonStamped footprint = move_footprint(state);
+
602  if (is_inside_of_robot(obstacle, footprint, state))
+
603  {
+
604  return 0.0;
+
605  }
+
606  else
+
607  {
+
608  geometry_msgs::Point intersection = calc_intersection(obstacle, state, footprint);
+
609  return hypot((obstacle.x - intersection.x), (obstacle.y - intersection.y));
+
610  }
+
611 }
+
612 
+
613 geometry_msgs::PolygonStamped DWAPlanner::move_footprint(const State &target_pose)
+
614 {
+
615  geometry_msgs::PolygonStamped footprint;
+
616  if (use_footprint_)
+
617  {
+
618  footprint = footprint_.value();
+
619  }
+
620  else
+
621  {
+
622  const int plot_num = 20;
+
623  for (int i = 0; i < plot_num; i++)
+
624  {
+
625  geometry_msgs::Point32 point;
+
626  point.x = (robot_radius_ + footprint_padding_) * cos(2 * M_PI * i / plot_num);
+
627  point.y = robot_radius_ * sin(2 * M_PI * i / plot_num);
+
628  footprint.polygon.points.push_back(point);
+
629  }
+
630  }
+
631 
+
632  footprint.header.stamp = ros::Time::now();
+
633 
+
634  for (auto &point : footprint.polygon.points)
+
635  {
+
636  Eigen::VectorXf point_in(2);
+
637  point_in << point.x, point.y;
+
638  Eigen::Matrix2f rot;
+
639  rot = Eigen::Rotation2Df(target_pose.yaw_);
+
640  const Eigen::VectorXf point_out = rot * point_in;
+
641 
+
642  point.x = point_out.x() + target_pose.x_;
+
643  point.y = point_out.y() + target_pose.y_;
+
644  }
+
645 
+
646  return footprint;
+
647 }
+
648 
+ +
650  const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
+
651 {
+
652  geometry_msgs::Point32 state_point;
+
653  state_point.x = state.x_;
+
654  state_point.y = state.y_;
+
655 
+
656  for (int i = 0; i < footprint.polygon.points.size(); i++)
+
657  {
+
658  geometry_msgs::Polygon triangle;
+
659  triangle.points.push_back(state_point);
+
660  triangle.points.push_back(footprint.polygon.points[i]);
661 
-
662  for (int i = 0; i < footprint.polygon.points.size(); i++)
-
663  {
-
664  geometry_msgs::Polygon triangle;
-
665  triangle.points.push_back(state_point);
-
666  triangle.points.push_back(footprint.polygon.points[i]);
-
667 
-
668  if (i != footprint.polygon.points.size() - 1)
-
669  triangle.points.push_back(footprint.polygon.points[i + 1]);
-
670  else
-
671  triangle.points.push_back(footprint.polygon.points[0]);
-
672 
-
673  if (is_inside_of_triangle(obstacle, triangle))
-
674  return true;
-
675  }
-
676 
-
677  return false;
-
678 }
-
679 
-
680 bool DWAPlanner::is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
-
681 {
-
682  if (triangle.points.size() != 3)
-
683  {
-
684  ROS_ERROR("Not triangle");
-
685  exit(1);
-
686  }
-
687 
-
688  const Eigen::Vector3d vector_A(triangle.points[0].x, triangle.points[0].y, 0.0);
-
689  const Eigen::Vector3d vector_B(triangle.points[1].x, triangle.points[1].y, 0.0);
-
690  const Eigen::Vector3d vector_C(triangle.points[2].x, triangle.points[2].y, 0.0);
-
691  const Eigen::Vector3d vector_P(target_point.x, target_point.y, 0.0);
-
692 
-
693  const Eigen::Vector3d vector_AB = vector_B - vector_A;
-
694  const Eigen::Vector3d vector_BP = vector_P - vector_B;
-
695  const Eigen::Vector3d cross1 = vector_AB.cross(vector_BP);
-
696 
-
697  const Eigen::Vector3d vector_BC = vector_C - vector_B;
-
698  const Eigen::Vector3d vector_CP = vector_P - vector_C;
-
699  const Eigen::Vector3d cross2 = vector_BC.cross(vector_CP);
-
700 
-
701  const Eigen::Vector3d vector_CA = vector_A - vector_C;
-
702  const Eigen::Vector3d vector_AP = vector_P - vector_A;
-
703  const Eigen::Vector3d cross3 = vector_CA.cross(vector_AP);
+
662  if (i != footprint.polygon.points.size() - 1)
+
663  triangle.points.push_back(footprint.polygon.points[i + 1]);
+
664  else
+
665  triangle.points.push_back(footprint.polygon.points[0]);
+
666 
+
667  if (is_inside_of_triangle(obstacle, triangle))
+
668  return true;
+
669  }
+
670 
+
671  return false;
+
672 }
+
673 
+
674 bool DWAPlanner::is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
+
675 {
+
676  if (triangle.points.size() != 3)
+
677  {
+
678  ROS_ERROR("Not triangle");
+
679  exit(1);
+
680  }
+
681 
+
682  const Eigen::Vector3d vector_A(triangle.points[0].x, triangle.points[0].y, 0.0);
+
683  const Eigen::Vector3d vector_B(triangle.points[1].x, triangle.points[1].y, 0.0);
+
684  const Eigen::Vector3d vector_C(triangle.points[2].x, triangle.points[2].y, 0.0);
+
685  const Eigen::Vector3d vector_P(target_point.x, target_point.y, 0.0);
+
686 
+
687  const Eigen::Vector3d vector_AB = vector_B - vector_A;
+
688  const Eigen::Vector3d vector_BP = vector_P - vector_B;
+
689  const Eigen::Vector3d cross1 = vector_AB.cross(vector_BP);
+
690 
+
691  const Eigen::Vector3d vector_BC = vector_C - vector_B;
+
692  const Eigen::Vector3d vector_CP = vector_P - vector_C;
+
693  const Eigen::Vector3d cross2 = vector_BC.cross(vector_CP);
+
694 
+
695  const Eigen::Vector3d vector_CA = vector_A - vector_C;
+
696  const Eigen::Vector3d vector_AP = vector_P - vector_A;
+
697  const Eigen::Vector3d cross3 = vector_CA.cross(vector_AP);
+
698 
+
699  if ((0 < cross1.z() && 0 < cross2.z() && 0 < cross3.z()) || (cross1.z() < 0 && cross2.z() < 0 && cross3.z() < 0))
+
700  return true;
+
701  else
+
702  return false;
+
703 }
704 
-
705  if ((0 < cross1.z() && 0 < cross2.z() && 0 < cross3.z()) || (cross1.z() < 0 && cross2.z() < 0 && cross3.z() < 0))
-
706  return true;
-
707  else
-
708  return false;
-
709 }
-
710 
-
711 void DWAPlanner::motion(State &state, const double velocity, const double yawrate)
-
712 {
-
713  const double sim_time_step = predict_time_ / static_cast<double>(sim_time_samples_);
-
714  state.yaw_ += yawrate * sim_time_step;
-
715  state.x_ += velocity * std::cos(state.yaw_) * sim_time_step;
-
716  state.y_ += velocity * std::sin(state.yaw_) * sim_time_step;
-
717  state.velocity_ = velocity;
-
718  state.yawrate_ = yawrate;
-
719 }
-
720 
-
721 void DWAPlanner::scan_to_obs(const sensor_msgs::LaserScan &scan)
-
722 {
-
723  obs_list_.poses.clear();
-
724  float angle = scan.angle_min;
-
725  const int angle_index_step = static_cast<int>(angle_resolution_ / scan.angle_increment);
-
726  for (int i = 0; i < scan.ranges.size(); i++)
-
727  {
-
728  const float r = scan.ranges[i];
-
729  if (r < scan.range_min || scan.range_max < r || i % angle_index_step != 0)
-
730  {
-
731  angle += scan.angle_increment;
-
732  continue;
-
733  }
-
734  geometry_msgs::Pose pose;
-
735  pose.position.x = r * cos(angle);
-
736  pose.position.y = r * sin(angle);
-
737  obs_list_.poses.push_back(pose);
-
738  angle += scan.angle_increment;
-
739  }
-
740 }
-
741 
-
742 void DWAPlanner::raycast(const nav_msgs::OccupancyGrid &map)
-
743 {
-
744  obs_list_.poses.clear();
-
745  const double max_search_dist = hypot(map.info.origin.position.x, map.info.origin.position.y);
-
746  for (float angle = -M_PI; angle <= M_PI; angle += angle_resolution_)
-
747  {
-
748  for (float dist = 0.0; dist <= max_search_dist; dist += map.info.resolution)
-
749  {
-
750  geometry_msgs::Pose pose;
-
751  pose.position.x = dist * cos(angle);
-
752  pose.position.y = dist * sin(angle);
-
753  const int index_x = floor((pose.position.x - map.info.origin.position.x) / map.info.resolution);
-
754  const int index_y = floor((pose.position.y - map.info.origin.position.y) / map.info.resolution);
-
755 
-
756  if ((0 <= index_x && index_x < map.info.width) && (0 <= index_y && index_y < map.info.height))
-
757  {
-
758  if (map.data[index_x + index_y * map.info.width] == 100)
-
759  {
-
760  obs_list_.poses.push_back(pose);
-
761  break;
-
762  }
-
763  }
-
764  }
-
765  }
-
766 }
-
767 
-
768 visualization_msgs::Marker DWAPlanner::create_marker_msg(
-
769  const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector<State> &trajectory,
-
770  const geometry_msgs::PolygonStamped &footprint)
-
771 {
-
772  visualization_msgs::Marker marker;
-
773  marker.header.frame_id = robot_frame_;
-
774  marker.header.stamp = ros::Time::now();
-
775  marker.id = id;
-
776  marker.type = visualization_msgs::Marker::LINE_STRIP;
-
777  marker.action = visualization_msgs::Marker::ADD;
-
778  marker.pose.orientation.w = 1;
-
779  marker.scale.x = scale;
-
780  marker.color = color;
-
781  marker.color.a = 0.8;
-
782  marker.lifetime = ros::Duration();
-
783 
-
784  geometry_msgs::Point p;
-
785  if (footprint.polygon.points.empty())
-
786  {
-
787  for (const auto &point : trajectory)
-
788  {
-
789  p.x = point.x_;
-
790  p.y = point.y_;
-
791  marker.points.push_back(p);
-
792  }
-
793  }
-
794  else
-
795  {
-
796  for (const auto &point : footprint.polygon.points)
-
797  {
-
798  p.x = point.x;
-
799  p.y = point.y;
-
800  marker.points.push_back(p);
-
801  }
-
802  p.x = footprint.polygon.points.front().x;
-
803  p.y = footprint.polygon.points.front().y;
-
804  marker.points.push_back(p);
-
805  }
-
806 
-
807  return marker;
-
808 }
-
809 
-
810 void DWAPlanner::visualize_trajectory(const std::vector<State> &trajectory, const ros::Publisher &pub)
-
811 {
-
812  std_msgs::ColorRGBA color;
-
813  color.r = 1.0;
-
814  visualization_msgs::Marker v_trajectory = create_marker_msg(0, v_path_width_, color, trajectory);
-
815  pub.publish(v_trajectory);
-
816 }
-
817 
- -
819  const std::vector<std::pair<std::vector<State>, bool>> &trajectories, const ros::Publisher &pub)
-
820 {
-
821  visualization_msgs::MarkerArray v_trajectories;
-
822  for (int i = 0; i < trajectories.size(); i++)
-
823  {
-
824  std_msgs::ColorRGBA color;
-
825  if (trajectories[i].second)
-
826  {
-
827  color.g = 1.0;
-
828  }
-
829  else
-
830  {
-
831  color.r = 0.5;
-
832  color.b = 0.5;
-
833  }
-
834  visualization_msgs::Marker v_trajectory = create_marker_msg(i, v_path_width_ * 0.4, color, trajectories[i].first);
-
835  v_trajectories.markers.push_back(v_trajectory);
-
836  }
-
837  pub.publish(v_trajectories);
-
838 }
-
839 
-
840 void DWAPlanner::visualize_footprints(const std::vector<State> &trajectory, const ros::Publisher &pub)
-
841 {
-
842  std_msgs::ColorRGBA color;
-
843  color.b = 1.0;
-
844  visualization_msgs::MarkerArray v_footprints;
-
845  for (int i = 0; i < trajectory.size(); i++)
-
846  {
-
847  const geometry_msgs::PolygonStamped footprint = move_footprint(trajectory[i]);
-
848  visualization_msgs::Marker v_footprint = create_marker_msg(i, v_path_width_ * 0.2, color, trajectory, footprint);
-
849  v_footprints.markers.push_back(v_footprint);
-
850  }
-
851  pub.publish(v_footprints);
-
852 }
+
705 void DWAPlanner::motion(State &state, const double velocity, const double yawrate)
+
706 {
+
707  const double sim_time_step = predict_time_ / static_cast<double>(sim_time_samples_);
+
708  state.yaw_ += yawrate * sim_time_step;
+
709  state.x_ += velocity * std::cos(state.yaw_) * sim_time_step;
+
710  state.y_ += velocity * std::sin(state.yaw_) * sim_time_step;
+
711  state.velocity_ = velocity;
+
712  state.yawrate_ = yawrate;
+
713 }
+
714 
+
715 void DWAPlanner::create_obs_list(const sensor_msgs::LaserScan &scan)
+
716 {
+
717  obs_list_.poses.clear();
+
718  float angle = scan.angle_min;
+
719  const int angle_index_step = static_cast<int>(angle_resolution_ / scan.angle_increment);
+
720  for (int i = 0; i < scan.ranges.size(); i++)
+
721  {
+
722  const float r = scan.ranges[i];
+
723  if (r < scan.range_min || scan.range_max < r || i % angle_index_step != 0)
+
724  {
+
725  angle += scan.angle_increment;
+
726  continue;
+
727  }
+
728  geometry_msgs::Pose pose;
+
729  pose.position.x = r * cos(angle);
+
730  pose.position.y = r * sin(angle);
+
731  obs_list_.poses.push_back(pose);
+
732  angle += scan.angle_increment;
+
733  }
+
734 }
+
735 
+
736 void DWAPlanner::create_obs_list(const nav_msgs::OccupancyGrid &map)
+
737 {
+
738  obs_list_.poses.clear();
+
739  const double max_search_dist = hypot(map.info.origin.position.x, map.info.origin.position.y);
+
740  for (float angle = -M_PI; angle <= M_PI; angle += angle_resolution_)
+
741  {
+
742  for (float dist = 0.0; dist <= max_search_dist; dist += map.info.resolution)
+
743  {
+
744  geometry_msgs::Pose pose;
+
745  pose.position.x = dist * cos(angle);
+
746  pose.position.y = dist * sin(angle);
+
747  const int index_x = floor((pose.position.x - map.info.origin.position.x) / map.info.resolution);
+
748  const int index_y = floor((pose.position.y - map.info.origin.position.y) / map.info.resolution);
+
749 
+
750  if ((0 <= index_x && index_x < map.info.width) && (0 <= index_y && index_y < map.info.height))
+
751  {
+
752  if (map.data[index_x + index_y * map.info.width] == 100)
+
753  {
+
754  obs_list_.poses.push_back(pose);
+
755  break;
+
756  }
+
757  }
+
758  }
+
759  }
+
760 }
+
761 
+
762 visualization_msgs::Marker DWAPlanner::create_marker_msg(
+
763  const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector<State> &trajectory,
+
764  const geometry_msgs::PolygonStamped &footprint)
+
765 {
+
766  visualization_msgs::Marker marker;
+
767  marker.header.frame_id = robot_frame_;
+
768  marker.header.stamp = ros::Time::now();
+
769  marker.id = id;
+
770  marker.type = visualization_msgs::Marker::LINE_STRIP;
+
771  marker.action = visualization_msgs::Marker::ADD;
+
772  marker.pose.orientation.w = 1;
+
773  marker.scale.x = scale;
+
774  marker.color = color;
+
775  marker.color.a = 0.8;
+
776  marker.lifetime = ros::Duration();
+
777 
+
778  geometry_msgs::Point p;
+
779  if (footprint.polygon.points.empty())
+
780  {
+
781  for (const auto &point : trajectory)
+
782  {
+
783  p.x = point.x_;
+
784  p.y = point.y_;
+
785  marker.points.push_back(p);
+
786  }
+
787  }
+
788  else
+
789  {
+
790  for (const auto &point : footprint.polygon.points)
+
791  {
+
792  p.x = point.x;
+
793  p.y = point.y;
+
794  marker.points.push_back(p);
+
795  }
+
796  p.x = footprint.polygon.points.front().x;
+
797  p.y = footprint.polygon.points.front().y;
+
798  marker.points.push_back(p);
+
799  }
+
800 
+
801  return marker;
+
802 }
+
803 
+
804 void DWAPlanner::visualize_trajectory(const std::vector<State> &trajectory, const ros::Publisher &pub)
+
805 {
+
806  std_msgs::ColorRGBA color;
+
807  color.r = 1.0;
+
808  visualization_msgs::Marker v_trajectory = create_marker_msg(0, v_path_width_, color, trajectory);
+
809  pub.publish(v_trajectory);
+
810 }
+
811 
+ +
813  const std::vector<std::pair<std::vector<State>, bool>> &trajectories, const ros::Publisher &pub)
+
814 {
+
815  visualization_msgs::MarkerArray v_trajectories;
+
816  for (int i = 0; i < trajectories.size(); i++)
+
817  {
+
818  std_msgs::ColorRGBA color;
+
819  if (trajectories[i].second)
+
820  {
+
821  color.g = 1.0;
+
822  }
+
823  else
+
824  {
+
825  color.r = 0.5;
+
826  color.b = 0.5;
+
827  }
+
828  visualization_msgs::Marker v_trajectory = create_marker_msg(i, v_path_width_ * 0.4, color, trajectories[i].first);
+
829  v_trajectories.markers.push_back(v_trajectory);
+
830  }
+
831  pub.publish(v_trajectories);
+
832 }
+
833 
+
834 void DWAPlanner::visualize_footprints(const std::vector<State> &trajectory, const ros::Publisher &pub)
+
835 {
+
836  std_msgs::ColorRGBA color;
+
837  color.b = 1.0;
+
838  visualization_msgs::MarkerArray v_footprints;
+
839  for (int i = 0; i < trajectory.size(); i++)
+
840  {
+
841  const geometry_msgs::PolygonStamped footprint = move_footprint(trajectory[i]);
+
842  visualization_msgs::Marker v_footprint = create_marker_msg(i, v_path_width_ * 0.2, color, trajectory, footprint);
+
843  v_footprints.markers.push_back(v_footprint);
+
844  }
+
845  pub.publish(v_footprints);
+
846 }
-
ros::Subscriber dist_to_goal_th_sub_
Definition: dwa_planner.h:459
-
ros::Publisher finish_flag_pub_
Definition: dwa_planner.h:458
-
std::vector< geometry_msgs::PoseStamped > edge_points_on_path_
Definition: dwa_planner.h:472
-
bool check_collision(const std::vector< State > &traj)
Check if the robot has collided.
-
double angle_resolution_
Definition: dwa_planner.h:417
+
ros::Subscriber dist_to_goal_th_sub_
Definition: dwa_planner.h:458
+
ros::Publisher finish_flag_pub_
Definition: dwa_planner.h:457
+
bool check_collision(const std::vector< State > &traj)
Check if the robot has collided.
+
double angle_resolution_
Definition: dwa_planner.h:419
-
void scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
A callback to hanldle buffering scan messages.
-
ros::NodeHandle nh_
Definition: dwa_planner.h:452
-
std_msgs::Bool has_finished_
Definition: dwa_planner.h:474
-
int scan_not_subscribe_count_
Definition: dwa_planner.h:450
-
bool use_scan_as_input_
Definition: dwa_planner.h:434
-
ros::Subscriber edge_on_global_path_sub_
Definition: dwa_planner.h:460
-
std::vector< State > generate_trajectory(const double velocity, const double yawrate)
Generate trajectory.
-
float calc_path_cost(const std::vector< State > &traj)
Calculate the path cost.
+
void scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
A callback to hanldle buffering scan messages.
+
ros::NodeHandle nh_
Definition: dwa_planner.h:451
+
std_msgs::Bool has_finished_
Definition: dwa_planner.h:473
+
int scan_not_subscribe_count_
Definition: dwa_planner.h:449
+
bool use_scan_as_input_
Definition: dwa_planner.h:436
+
ros::Subscriber edge_on_global_path_sub_
Definition: dwa_planner.h:459
+
std::vector< State > generate_trajectory(const double velocity, const double yawrate)
Generate trajectory.
+
float calc_path_cost(const std::vector< State > &traj)
Calculate the path cost.
-
void footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
A calllback to handle buffering footprint messages.
-
Window calc_dynamic_window(void)
Calculate dynamic window.
-
double obs_cost_gain_
Definition: dwa_planner.h:420
-
float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
Calculate the distance from robot footprint to the nearest obstacle.
-
double min_yawrate_
Definition: dwa_planner.h:410
-
float calc_dist_to_path(const State state)
Calculate the distance of current pose to global path.
-
int odom_not_subscribe_count_
Definition: dwa_planner.h:448
-
bool footprint_subscribed_
Definition: dwa_planner.h:437
-
int local_map_not_subscribe_count_
Definition: dwa_planner.h:449
-
void raycast(const nav_msgs::OccupancyGrid &map)
Get obstacle list from local map.
-
double predict_time_
Definition: dwa_planner.h:418
-
geometry_msgs::PolygonStamped move_footprint(const State &target_pose)
Move the robot footprint to the target pose.
-
int velocity_samples_
Definition: dwa_planner.h:444
-
ros::Subscriber footprint_sub_
Definition: dwa_planner.h:461
-
geometry_msgs::PoseStamped goal_msg_
Definition: dwa_planner.h:469
-
void goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
A callback to hanldle buffering local goal messages.
Definition: dwa_planner.cpp:91
-
double max_velocity_
Definition: dwa_planner.h:407
-
double to_goal_cost_gain_
Definition: dwa_planner.h:421
-
bool use_path_cost_
Definition: dwa_planner.h:435
+
void footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
A calllback to handle buffering footprint messages.
+
Window calc_dynamic_window(void)
Calculate dynamic window.
+
double obs_cost_gain_
Definition: dwa_planner.h:422
+
float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
Calculate the distance from robot footprint to the nearest obstacle.
+
double min_yawrate_
Definition: dwa_planner.h:412
+
float calc_dist_to_path(const State state)
Calculate the distance of current pose to global path.
+
int odom_not_subscribe_count_
Definition: dwa_planner.h:447
+
int local_map_not_subscribe_count_
Definition: dwa_planner.h:448
+
double predict_time_
Definition: dwa_planner.h:420
+
void create_obs_list(const nav_msgs::OccupancyGrid &map)
Get obstacle list from local map.
+
geometry_msgs::PolygonStamped move_footprint(const State &target_pose)
Move the robot footprint to the target pose.
+
int velocity_samples_
Definition: dwa_planner.h:443
+
ros::Subscriber footprint_sub_
Definition: dwa_planner.h:460
+
void goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
A callback to hanldle buffering local goal messages.
Definition: dwa_planner.cpp:88
+
double max_velocity_
Definition: dwa_planner.h:409
+
double to_goal_cost_gain_
Definition: dwa_planner.h:423
+
bool use_path_cost_
Definition: dwa_planner.h:437
DWAPlanner(void)
Constructor for the DWAPlanner.
Definition: dwa_planner.cpp:10
-
ros::Publisher velocity_pub_
Definition: dwa_planner.h:454
-
void edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
A callback to handle buffering edge on global path messages.
-
void normalize_costs(std::vector< Cost > &costs)
Normalize the costs.
+
ros::Publisher velocity_pub_
Definition: dwa_planner.h:453
+
void edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
A callback to handle buffering edge on global path messages.
+
void normalize_costs(std::vector< Cost > &costs)
Normalize the costs.
-
bool scan_updated_
Definition: dwa_planner.h:442
-
int sim_time_samples_
Definition: dwa_planner.h:446
-
void visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish predicted footprints.
+
bool scan_updated_
Definition: dwa_planner.h:441
+
int sim_time_samples_
Definition: dwa_planner.h:445
+
void visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish predicted footprints.
+
std::optional< geometry_msgs::PoseStamped > goal_msg_
Definition: dwa_planner.h:468
-
geometry_msgs::Point calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
Calculate the intersection point of the line and the circle.
+
geometry_msgs::Point calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
Calculate the intersection point of the line and the circle.
A data class for cost.
Definition: dwa_planner.h:106
-
double min_in_place_yawrate_
Definition: dwa_planner.h:412
+
double min_in_place_yawrate_
Definition: dwa_planner.h:414
A data class for state of robot.
Definition: dwa_planner.h:50
A data class for dynamic window.
Definition: dwa_planner.h:81
-
geometry_msgs::Twist calc_cmd_vel(void)
Calculate the command velocity.
-
double max_yawrate_
Definition: dwa_planner.h:409
-
bool can_move(void)
Check if the robot can move.
-
void show(void)
Show the cost.
Definition: dwa_planner.cpp:80
-
float calc_obs_cost(const std::vector< State > &traj)
Calculate obstacle cost.
-
bool use_footprint_
Definition: dwa_planner.h:433
-
ros::Publisher candidate_trajectories_pub_
Definition: dwa_planner.h:455
-
void scan_to_obs(const sensor_msgs::LaserScan &scan)
Get obstacle list from laser scan.
-
double path_cost_gain_
Definition: dwa_planner.h:423
-
tf::TransformListener listener_
Definition: dwa_planner.h:476
-
void motion(State &state, const double velocity, const double yawrate)
Simulate the robot motion.
-
ros::Subscriber local_map_sub_
Definition: dwa_planner.h:463
-
double hz_
Definition: dwa_planner.h:405
-
void odom_callback(const nav_msgs::OdometryConstPtr &msg)
A callback to hanldle buffering odometry messages.
-
geometry_msgs::PolygonStamped footprint_
Definition: dwa_planner.h:471
-
void visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish selected trajectory.
-
void calc_total_cost(void)
Calculate the total cost.
Definition: dwa_planner.cpp:89
-
void local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
A callback to hanldle buffering local map messages.
-
double sim_direction_
Definition: dwa_planner.h:427
-
float calc_speed_cost(const std::vector< State > &traj)
Calculate the speed cost.
-
ros::Subscriber goal_sub_
Definition: dwa_planner.h:462
-
double max_acceleration_
Definition: dwa_planner.h:413
-
bool goal_subscribed_
Definition: dwa_planner.h:438
-
void dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
A callback to handle buffering distance to goal threshold messages.
-
geometry_msgs::Twist current_cmd_vel_
Definition: dwa_planner.h:468
-
geometry_msgs::PoseArray obs_list_
Definition: dwa_planner.h:470
-
int yawrate_samples_
Definition: dwa_planner.h:445
-
void target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
A callback to hanldle buffering target velocity messages.
-
double angle_to_goal_th_
Definition: dwa_planner.h:426
+
geometry_msgs::Twist calc_cmd_vel(void)
Calculate the command velocity.
+
double max_yawrate_
Definition: dwa_planner.h:411
+
bool can_move(void)
Check if the robot can move.
+
void show(void)
Show the cost.
Definition: dwa_planner.cpp:77
+
float calc_obs_cost(const std::vector< State > &traj)
Calculate obstacle cost.
+
bool use_footprint_
Definition: dwa_planner.h:435
+
ros::Publisher candidate_trajectories_pub_
Definition: dwa_planner.h:454
+
double path_cost_gain_
Definition: dwa_planner.h:425
+
tf::TransformListener listener_
Definition: dwa_planner.h:475
+
void motion(State &state, const double velocity, const double yawrate)
Simulate the robot motion.
+
ros::Subscriber local_map_sub_
Definition: dwa_planner.h:462
+
double hz_
Definition: dwa_planner.h:407
+
void odom_callback(const nav_msgs::OdometryConstPtr &msg)
A callback to hanldle buffering odometry messages.
+
void visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish selected trajectory.
+
void calc_total_cost(void)
Calculate the total cost.
Definition: dwa_planner.cpp:86
+
void local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
A callback to hanldle buffering local map messages.
+
double sim_direction_
Definition: dwa_planner.h:429
+
float calc_speed_cost(const std::vector< State > &traj)
Calculate the speed cost.
+
ros::Subscriber goal_sub_
Definition: dwa_planner.h:461
+
double max_acceleration_
Definition: dwa_planner.h:415
+
void dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
A callback to handle buffering distance to goal threshold messages.
+
std::optional< nav_msgs::Path > edge_points_on_path_
Definition: dwa_planner.h:471
+
geometry_msgs::Twist current_cmd_vel_
Definition: dwa_planner.h:467
+
geometry_msgs::PoseArray obs_list_
Definition: dwa_planner.h:469
+
int yawrate_samples_
Definition: dwa_planner.h:444
+
void target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
A callback to hanldle buffering target velocity messages.
+
double angle_to_goal_th_
Definition: dwa_planner.h:428
-
void visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)
Publish candidate trajectories.
-
Cost(void)
Constructor.
Definition: dwa_planner.cpp:68
-
double sleep_time_after_finish_
Definition: dwa_planner.h:419
+
void visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)
Publish candidate trajectories.
+
Cost(void)
Constructor.
Definition: dwa_planner.cpp:65
+
double sleep_time_after_finish_
Definition: dwa_planner.h:421
-
bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
Check if the target point is inside of triangle.
-
double sim_period_
Definition: dwa_planner.h:416
-
double dist_to_goal_th_
Definition: dwa_planner.h:424
-
double obs_range_
Definition: dwa_planner.h:429
+
bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
Check if the target point is inside of triangle.
+
double sim_period_
Definition: dwa_planner.h:418
+
double dist_to_goal_th_
Definition: dwa_planner.h:426
+
double obs_range_
Definition: dwa_planner.h:431
-
Window(void)
Constructor.
Definition: dwa_planner.cpp:55
+
Window(void)
Constructor.
Definition: dwa_planner.cpp:52
-
ros::Subscriber scan_sub_
Definition: dwa_planner.h:465
-
bool edge_on_global_path_subscribed_
Definition: dwa_planner.h:439
-
void show(void)
Show the dynamic window information.
Definition: dwa_planner.cpp:57
-
double v_path_width_
Definition: dwa_planner.h:432
-
double max_deceleration_
Definition: dwa_planner.h:414
+
ros::Subscriber scan_sub_
Definition: dwa_planner.h:464
+
void show(void)
Show the dynamic window information.
Definition: dwa_planner.cpp:54
+
double v_path_width_
Definition: dwa_planner.h:434
+
double max_deceleration_
Definition: dwa_planner.h:416
-
bool use_speed_cost_
Definition: dwa_planner.h:436
-
bool has_reached_
Definition: dwa_planner.h:443
+
bool use_speed_cost_
Definition: dwa_planner.h:438
+
bool has_reached_
Definition: dwa_planner.h:442
void print_params(void)
Print parameters.
Definition: parameters.cpp:64
-
ros::NodeHandle local_nh_
Definition: dwa_planner.h:453
+
ros::NodeHandle local_nh_
Definition: dwa_planner.h:452
void load_params(void)
Load parameters.
Definition: parameters.cpp:8
-
Cost evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)
Evaluate trajectory.
+
Cost evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)
Evaluate trajectory.
-
bool can_adjust_robot_direction(const Eigen::Vector3d &goal)
Check if the robot can adjust the direction.
-
bool local_map_updated_
Definition: dwa_planner.h:441
-
double slow_velocity_th_
Definition: dwa_planner.h:428
-
visualization_msgs::Marker create_marker_msg(const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())
Create a marker message.
-
std::string robot_frame_
Definition: dwa_planner.h:404
-
ros::Publisher predict_footprints_pub_
Definition: dwa_planner.h:457
-
void process(void)
Execute local path planning.
-
State(void)
Constructor.
Definition: dwa_planner.cpp:48
-
std::vector< State > dwa_planning(const Eigen::Vector3d &goal, std::vector< std::pair< std::vector< State >, bool >> &trajectories)
Execute dwa planning.
-
int subscribe_count_th_
Definition: dwa_planner.h:447
-
ros::Publisher selected_trajectory_pub_
Definition: dwa_planner.h:456
-
ros::Subscriber target_velocity_sub_
Definition: dwa_planner.h:466
-
ros::Subscriber odom_sub_
Definition: dwa_planner.h:464
-
bool is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
Check if the obstacle is inside of robot footprint.
-
double turn_direction_th_
Definition: dwa_planner.h:425
-
double speed_cost_gain_
Definition: dwa_planner.h:422
-
double robot_radius_
Definition: dwa_planner.h:430
-
double max_d_yawrate_
Definition: dwa_planner.h:415
+
bool can_adjust_robot_direction(const Eigen::Vector3d &goal)
Check if the robot can adjust the direction.
+
std::optional< geometry_msgs::PolygonStamped > footprint_
Definition: dwa_planner.h:470
+
bool local_map_updated_
Definition: dwa_planner.h:440
+
double slow_velocity_th_
Definition: dwa_planner.h:430
+
visualization_msgs::Marker create_marker_msg(const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())
Create a marker message.
+
std::string robot_frame_
Definition: dwa_planner.h:406
+
ros::Publisher predict_footprints_pub_
Definition: dwa_planner.h:456
+
void process(void)
Execute local path planning.
+
State(void)
Constructor.
Definition: dwa_planner.cpp:45
+
std::vector< State > dwa_planning(const Eigen::Vector3d &goal, std::vector< std::pair< std::vector< State >, bool >> &trajectories)
Execute dwa planning.
+
int subscribe_count_th_
Definition: dwa_planner.h:446
+
ros::Publisher selected_trajectory_pub_
Definition: dwa_planner.h:455
+
ros::Subscriber target_velocity_sub_
Definition: dwa_planner.h:465
+
ros::Subscriber odom_sub_
Definition: dwa_planner.h:463
+
bool is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
Check if the obstacle is inside of robot footprint.
+
double turn_direction_th_
Definition: dwa_planner.h:427
+
double speed_cost_gain_
Definition: dwa_planner.h:424
+
double robot_radius_
Definition: dwa_planner.h:432
+
double max_d_yawrate_
Definition: dwa_planner.h:417
-
float calc_to_goal_cost(const std::vector< State > &traj, const Eigen::Vector3d &goal)
Calculate the distance of current pose to goal pose.
-
double target_velocity_
Definition: dwa_planner.h:406
-
double footprint_padding_
Definition: dwa_planner.h:431
-
double max_in_place_yawrate_
Definition: dwa_planner.h:411
-
bool odom_updated_
Definition: dwa_planner.h:440
-
std::string global_frame_
Definition: dwa_planner.h:403
-
double min_velocity_
Definition: dwa_planner.h:408
+
float calc_to_goal_cost(const std::vector< State > &traj, const Eigen::Vector3d &goal)
Calculate the distance of current pose to goal pose.
+
double target_velocity_
Definition: dwa_planner.h:408
+
double footprint_padding_
Definition: dwa_planner.h:433
+
double max_in_place_yawrate_
Definition: dwa_planner.h:413
+
bool odom_updated_
Definition: dwa_planner.h:439
+
std::string global_frame_
Definition: dwa_planner.h:405
+
double min_velocity_
Definition: dwa_planner.h:410


dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner_8h.html b/docs/dwa__planner_8h.html index 6a86f5c..16f7852 100644 --- a/docs/dwa__planner_8h.html +++ b/docs/dwa__planner_8h.html @@ -110,7 +110,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner_8h_source.html b/docs/dwa__planner_8h_source.html index 2161db3..f0d6203 100644 --- a/docs/dwa__planner_8h_source.html +++ b/docs/dwa__planner_8h_source.html @@ -146,269 +146,262 @@
241 
248  void motion(State &state, const double velocity, const double yawrate);
249 
-
253  void raycast(const nav_msgs::OccupancyGrid &map);
-
254 
-
258  void scan_to_obs(const sensor_msgs::LaserScan &scan);
-
259 
-
266  float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state);
-
267 
-
273  geometry_msgs::PolygonStamped move_footprint(const State &target_pose);
-
274 
-
282  bool is_inside_of_robot(
-
283  const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state);
-
284 
-
291  bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle);
-
292 
-
300  geometry_msgs::Point
-
301  calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint);
-
302 
-
309  std::vector<State> generate_trajectory(const double velocity, const double yawrate);
-
310 
-
317  std::vector<State> generate_trajectory(const double yawrate, const Eigen::Vector3d &goal);
-
318 
-
325  Cost evaluate_trajectory(const std::vector<State> &trajectory, const Eigen::Vector3d &goal);
-
326 
-
331  bool can_move(void);
-
332 
-
337  geometry_msgs::Twist calc_cmd_vel(void);
-
338 
-
344  bool can_adjust_robot_direction(const Eigen::Vector3d &goal);
-
345 
-
351  bool check_collision(const std::vector<State> &traj);
-
352 
-
357  void normalize_costs(std::vector<Cost> &costs);
-
358 
-
367  visualization_msgs::Marker create_marker_msg(
-
368  const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector<State> &trajectory,
-
369  const geometry_msgs::PolygonStamped &footprint = geometry_msgs::PolygonStamped());
-
370 
-
376  void visualize_trajectory(const std::vector<State> &trajectory, const ros::Publisher &pub);
-
377 
- -
384  const std::vector<std::pair<std::vector<State>, bool>> &trajectories, const ros::Publisher &pub);
-
385 
-
391  void visualize_footprints(const std::vector<State> &trajectory, const ros::Publisher &pub);
-
392 
-
399  std::vector<State>
-
400  dwa_planning(const Eigen::Vector3d &goal, std::vector<std::pair<std::vector<State>, bool>> &trajectories);
-
401 
-
402 protected:
-
403  std::string global_frame_;
-
404  std::string robot_frame_;
-
405  double hz_;
- - - -
409  double max_yawrate_;
-
410  double min_yawrate_;
- - - - - -
416  double sim_period_;
- - - - - - - - - - - - -
429  double obs_range_;
- - - - - - - - - - - - - - - - - - - - - -
451 
-
452  ros::NodeHandle nh_;
-
453  ros::NodeHandle local_nh_;
-
454  ros::Publisher velocity_pub_;
- -
456  ros::Publisher selected_trajectory_pub_;
-
457  ros::Publisher predict_footprints_pub_;
-
458  ros::Publisher finish_flag_pub_;
-
459  ros::Subscriber dist_to_goal_th_sub_;
-
460  ros::Subscriber edge_on_global_path_sub_;
-
461  ros::Subscriber footprint_sub_;
-
462  ros::Subscriber goal_sub_;
-
463  ros::Subscriber local_map_sub_;
-
464  ros::Subscriber odom_sub_;
-
465  ros::Subscriber scan_sub_;
-
466  ros::Subscriber target_velocity_sub_;
-
467 
-
468  geometry_msgs::Twist current_cmd_vel_;
-
469  geometry_msgs::PoseStamped goal_msg_;
-
470  geometry_msgs::PoseArray obs_list_;
-
471  geometry_msgs::PolygonStamped footprint_;
-
472  std::vector<geometry_msgs::PoseStamped> edge_points_on_path_;
-
473 
-
474  std_msgs::Bool has_finished_;
-
475 
-
476  tf::TransformListener listener_;
-
477 };
-
478 
-
479 #endif // DWA_PLANNER_DWA_PLANNER_H
+
254  void create_obs_list(const nav_msgs::OccupancyGrid &map);
+
255 
+
260  void create_obs_list(const sensor_msgs::LaserScan &scan);
+
261 
+
268  float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state);
+
269 
+
275  geometry_msgs::PolygonStamped move_footprint(const State &target_pose);
+
276 
+
284  bool is_inside_of_robot(
+
285  const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state);
+
286 
+
293  bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle);
+
294 
+
302  geometry_msgs::Point
+
303  calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint);
+
304 
+
311  std::vector<State> generate_trajectory(const double velocity, const double yawrate);
+
312 
+
319  std::vector<State> generate_trajectory(const double yawrate, const Eigen::Vector3d &goal);
+
320 
+
327  Cost evaluate_trajectory(const std::vector<State> &trajectory, const Eigen::Vector3d &goal);
+
328 
+
333  bool can_move(void);
+
334 
+
339  geometry_msgs::Twist calc_cmd_vel(void);
+
340 
+
346  bool can_adjust_robot_direction(const Eigen::Vector3d &goal);
+
347 
+
353  bool check_collision(const std::vector<State> &traj);
+
354 
+
359  void normalize_costs(std::vector<Cost> &costs);
+
360 
+
369  visualization_msgs::Marker create_marker_msg(
+
370  const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector<State> &trajectory,
+
371  const geometry_msgs::PolygonStamped &footprint = geometry_msgs::PolygonStamped());
+
372 
+
378  void visualize_trajectory(const std::vector<State> &trajectory, const ros::Publisher &pub);
+
379 
+ +
386  const std::vector<std::pair<std::vector<State>, bool>> &trajectories, const ros::Publisher &pub);
+
387 
+
393  void visualize_footprints(const std::vector<State> &trajectory, const ros::Publisher &pub);
+
394 
+
401  std::vector<State>
+
402  dwa_planning(const Eigen::Vector3d &goal, std::vector<std::pair<std::vector<State>, bool>> &trajectories);
+
403 
+
404 protected:
+
405  std::string global_frame_;
+
406  std::string robot_frame_;
+
407  double hz_;
+ + + +
411  double max_yawrate_;
+
412  double min_yawrate_;
+ + + + + +
418  double sim_period_;
+ + + + + + + + + + + + +
431  double obs_range_;
+ + + + + + + + + + + + + + + + + + +
450 
+
451  ros::NodeHandle nh_;
+
452  ros::NodeHandle local_nh_;
+
453  ros::Publisher velocity_pub_;
+ +
455  ros::Publisher selected_trajectory_pub_;
+
456  ros::Publisher predict_footprints_pub_;
+
457  ros::Publisher finish_flag_pub_;
+
458  ros::Subscriber dist_to_goal_th_sub_;
+
459  ros::Subscriber edge_on_global_path_sub_;
+
460  ros::Subscriber footprint_sub_;
+
461  ros::Subscriber goal_sub_;
+
462  ros::Subscriber local_map_sub_;
+
463  ros::Subscriber odom_sub_;
+
464  ros::Subscriber scan_sub_;
+
465  ros::Subscriber target_velocity_sub_;
+
466 
+
467  geometry_msgs::Twist current_cmd_vel_;
+
468  std::optional<geometry_msgs::PoseStamped> goal_msg_;
+
469  geometry_msgs::PoseArray obs_list_;
+
470  std::optional<geometry_msgs::PolygonStamped> footprint_;
+
471  std::optional<nav_msgs::Path> edge_points_on_path_;
+
472 
+
473  std_msgs::Bool has_finished_;
+
474 
+
475  tf::TransformListener listener_;
+
476 };
+
477 
+
478 #endif // DWA_PLANNER_DWA_PLANNER_H
-
ros::Subscriber dist_to_goal_th_sub_
Definition: dwa_planner.h:459
-
ros::Publisher finish_flag_pub_
Definition: dwa_planner.h:458
-
std::vector< geometry_msgs::PoseStamped > edge_points_on_path_
Definition: dwa_planner.h:472
-
bool check_collision(const std::vector< State > &traj)
Check if the robot has collided.
-
double angle_resolution_
Definition: dwa_planner.h:417
+
ros::Subscriber dist_to_goal_th_sub_
Definition: dwa_planner.h:458
+
ros::Publisher finish_flag_pub_
Definition: dwa_planner.h:457
+
bool check_collision(const std::vector< State > &traj)
Check if the robot has collided.
+
double angle_resolution_
Definition: dwa_planner.h:419
-
void scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
A callback to hanldle buffering scan messages.
-
ros::NodeHandle nh_
Definition: dwa_planner.h:452
-
std_msgs::Bool has_finished_
Definition: dwa_planner.h:474
-
int scan_not_subscribe_count_
Definition: dwa_planner.h:450
-
bool use_scan_as_input_
Definition: dwa_planner.h:434
-
ros::Subscriber edge_on_global_path_sub_
Definition: dwa_planner.h:460
-
std::vector< State > generate_trajectory(const double velocity, const double yawrate)
Generate trajectory.
-
float calc_path_cost(const std::vector< State > &traj)
Calculate the path cost.
+
void scan_callback(const sensor_msgs::LaserScanConstPtr &msg)
A callback to hanldle buffering scan messages.
+
ros::NodeHandle nh_
Definition: dwa_planner.h:451
+
std_msgs::Bool has_finished_
Definition: dwa_planner.h:473
+
int scan_not_subscribe_count_
Definition: dwa_planner.h:449
+
bool use_scan_as_input_
Definition: dwa_planner.h:436
+
ros::Subscriber edge_on_global_path_sub_
Definition: dwa_planner.h:459
+
std::vector< State > generate_trajectory(const double velocity, const double yawrate)
Generate trajectory.
+
float calc_path_cost(const std::vector< State > &traj)
Calculate the path cost.
-
void footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
A calllback to handle buffering footprint messages.
-
Window calc_dynamic_window(void)
Calculate dynamic window.
-
double obs_cost_gain_
Definition: dwa_planner.h:420
-
float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
Calculate the distance from robot footprint to the nearest obstacle.
-
double min_yawrate_
Definition: dwa_planner.h:410
-
float calc_dist_to_path(const State state)
Calculate the distance of current pose to global path.
-
int odom_not_subscribe_count_
Definition: dwa_planner.h:448
-
bool footprint_subscribed_
Definition: dwa_planner.h:437
-
int local_map_not_subscribe_count_
Definition: dwa_planner.h:449
-
void raycast(const nav_msgs::OccupancyGrid &map)
Get obstacle list from local map.
-
double predict_time_
Definition: dwa_planner.h:418
-
geometry_msgs::PolygonStamped move_footprint(const State &target_pose)
Move the robot footprint to the target pose.
-
int velocity_samples_
Definition: dwa_planner.h:444
-
ros::Subscriber footprint_sub_
Definition: dwa_planner.h:461
-
geometry_msgs::PoseStamped goal_msg_
Definition: dwa_planner.h:469
-
void goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
A callback to hanldle buffering local goal messages.
Definition: dwa_planner.cpp:91
-
double max_velocity_
Definition: dwa_planner.h:407
-
double to_goal_cost_gain_
Definition: dwa_planner.h:421
-
bool use_path_cost_
Definition: dwa_planner.h:435
+
void footprint_callback(const geometry_msgs::PolygonStampedPtr &msg)
A calllback to handle buffering footprint messages.
+
Window calc_dynamic_window(void)
Calculate dynamic window.
+
double obs_cost_gain_
Definition: dwa_planner.h:422
+
float calc_dist_from_robot(const geometry_msgs::Point &obstacle, const State &state)
Calculate the distance from robot footprint to the nearest obstacle.
+
double min_yawrate_
Definition: dwa_planner.h:412
+
float calc_dist_to_path(const State state)
Calculate the distance of current pose to global path.
+
int odom_not_subscribe_count_
Definition: dwa_planner.h:447
+
int local_map_not_subscribe_count_
Definition: dwa_planner.h:448
+
double predict_time_
Definition: dwa_planner.h:420
+
void create_obs_list(const nav_msgs::OccupancyGrid &map)
Get obstacle list from local map.
+
geometry_msgs::PolygonStamped move_footprint(const State &target_pose)
Move the robot footprint to the target pose.
+
int velocity_samples_
Definition: dwa_planner.h:443
+
ros::Subscriber footprint_sub_
Definition: dwa_planner.h:460
+
void goal_callback(const geometry_msgs::PoseStampedConstPtr &msg)
A callback to hanldle buffering local goal messages.
Definition: dwa_planner.cpp:88
+
double max_velocity_
Definition: dwa_planner.h:409
+
double to_goal_cost_gain_
Definition: dwa_planner.h:423
+
bool use_path_cost_
Definition: dwa_planner.h:437
DWAPlanner(void)
Constructor for the DWAPlanner.
Definition: dwa_planner.cpp:10
-
ros::Publisher velocity_pub_
Definition: dwa_planner.h:454
-
void edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
A callback to handle buffering edge on global path messages.
-
void normalize_costs(std::vector< Cost > &costs)
Normalize the costs.
+
ros::Publisher velocity_pub_
Definition: dwa_planner.h:453
+
void edge_on_global_path_callback(const nav_msgs::PathConstPtr &msg)
A callback to handle buffering edge on global path messages.
+
void normalize_costs(std::vector< Cost > &costs)
Normalize the costs.
-
bool scan_updated_
Definition: dwa_planner.h:442
-
int sim_time_samples_
Definition: dwa_planner.h:446
-
void visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish predicted footprints.
+
bool scan_updated_
Definition: dwa_planner.h:441
+
int sim_time_samples_
Definition: dwa_planner.h:445
+
void visualize_footprints(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish predicted footprints.
+
std::optional< geometry_msgs::PoseStamped > goal_msg_
Definition: dwa_planner.h:468
-
geometry_msgs::Point calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
Calculate the intersection point of the line and the circle.
+
geometry_msgs::Point calc_intersection(const geometry_msgs::Point &obstacle, const State &state, geometry_msgs::PolygonStamped footprint)
Calculate the intersection point of the line and the circle.
A data class for cost.
Definition: dwa_planner.h:106
-
double min_in_place_yawrate_
Definition: dwa_planner.h:412
+
double min_in_place_yawrate_
Definition: dwa_planner.h:414
A data class for state of robot.
Definition: dwa_planner.h:50
A data class for dynamic window.
Definition: dwa_planner.h:81
-
geometry_msgs::Twist calc_cmd_vel(void)
Calculate the command velocity.
-
double max_yawrate_
Definition: dwa_planner.h:409
-
bool can_move(void)
Check if the robot can move.
-
void show(void)
Show the cost.
Definition: dwa_planner.cpp:80
-
float calc_obs_cost(const std::vector< State > &traj)
Calculate obstacle cost.
-
bool use_footprint_
Definition: dwa_planner.h:433
-
ros::Publisher candidate_trajectories_pub_
Definition: dwa_planner.h:455
-
void scan_to_obs(const sensor_msgs::LaserScan &scan)
Get obstacle list from laser scan.
-
double path_cost_gain_
Definition: dwa_planner.h:423
-
tf::TransformListener listener_
Definition: dwa_planner.h:476
-
void motion(State &state, const double velocity, const double yawrate)
Simulate the robot motion.
-
ros::Subscriber local_map_sub_
Definition: dwa_planner.h:463
-
double hz_
Definition: dwa_planner.h:405
-
void odom_callback(const nav_msgs::OdometryConstPtr &msg)
A callback to hanldle buffering odometry messages.
-
geometry_msgs::PolygonStamped footprint_
Definition: dwa_planner.h:471
-
void visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish selected trajectory.
-
void calc_total_cost(void)
Calculate the total cost.
Definition: dwa_planner.cpp:89
-
void local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
A callback to hanldle buffering local map messages.
-
double sim_direction_
Definition: dwa_planner.h:427
-
float calc_speed_cost(const std::vector< State > &traj)
Calculate the speed cost.
-
ros::Subscriber goal_sub_
Definition: dwa_planner.h:462
-
double max_acceleration_
Definition: dwa_planner.h:413
-
bool goal_subscribed_
Definition: dwa_planner.h:438
-
void dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
A callback to handle buffering distance to goal threshold messages.
-
geometry_msgs::Twist current_cmd_vel_
Definition: dwa_planner.h:468
-
geometry_msgs::PoseArray obs_list_
Definition: dwa_planner.h:470
-
int yawrate_samples_
Definition: dwa_planner.h:445
-
void target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
A callback to hanldle buffering target velocity messages.
-
double angle_to_goal_th_
Definition: dwa_planner.h:426
+
geometry_msgs::Twist calc_cmd_vel(void)
Calculate the command velocity.
+
double max_yawrate_
Definition: dwa_planner.h:411
+
bool can_move(void)
Check if the robot can move.
+
void show(void)
Show the cost.
Definition: dwa_planner.cpp:77
+
float calc_obs_cost(const std::vector< State > &traj)
Calculate obstacle cost.
+
bool use_footprint_
Definition: dwa_planner.h:435
+
ros::Publisher candidate_trajectories_pub_
Definition: dwa_planner.h:454
+
double path_cost_gain_
Definition: dwa_planner.h:425
+
tf::TransformListener listener_
Definition: dwa_planner.h:475
+
void motion(State &state, const double velocity, const double yawrate)
Simulate the robot motion.
+
ros::Subscriber local_map_sub_
Definition: dwa_planner.h:462
+
double hz_
Definition: dwa_planner.h:407
+
void odom_callback(const nav_msgs::OdometryConstPtr &msg)
A callback to hanldle buffering odometry messages.
+
void visualize_trajectory(const std::vector< State > &trajectory, const ros::Publisher &pub)
Publish selected trajectory.
+
void calc_total_cost(void)
Calculate the total cost.
Definition: dwa_planner.cpp:86
+
void local_map_callback(const nav_msgs::OccupancyGridConstPtr &msg)
A callback to hanldle buffering local map messages.
+
double sim_direction_
Definition: dwa_planner.h:429
+
float calc_speed_cost(const std::vector< State > &traj)
Calculate the speed cost.
+
ros::Subscriber goal_sub_
Definition: dwa_planner.h:461
+
double max_acceleration_
Definition: dwa_planner.h:415
+
void dist_to_goal_th_callback(const std_msgs::Float64ConstPtr &msg)
A callback to handle buffering distance to goal threshold messages.
+
std::optional< nav_msgs::Path > edge_points_on_path_
Definition: dwa_planner.h:471
+
geometry_msgs::Twist current_cmd_vel_
Definition: dwa_planner.h:467
+
geometry_msgs::PoseArray obs_list_
Definition: dwa_planner.h:469
+
int yawrate_samples_
Definition: dwa_planner.h:444
+
void target_velocity_callback(const geometry_msgs::TwistConstPtr &msg)
A callback to hanldle buffering target velocity messages.
+
double angle_to_goal_th_
Definition: dwa_planner.h:428
-
void visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)
Publish candidate trajectories.
-
Cost(void)
Constructor.
Definition: dwa_planner.cpp:68
-
double sleep_time_after_finish_
Definition: dwa_planner.h:419
+
void visualize_trajectories(const std::vector< std::pair< std::vector< State >, bool >> &trajectories, const ros::Publisher &pub)
Publish candidate trajectories.
+
Cost(void)
Constructor.
Definition: dwa_planner.cpp:65
+
double sleep_time_after_finish_
Definition: dwa_planner.h:421
-
bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
Check if the target point is inside of triangle.
-
double sim_period_
Definition: dwa_planner.h:416
-
double dist_to_goal_th_
Definition: dwa_planner.h:424
-
double obs_range_
Definition: dwa_planner.h:429
+
bool is_inside_of_triangle(const geometry_msgs::Point &target_point, const geometry_msgs::Polygon &triangle)
Check if the target point is inside of triangle.
+
double sim_period_
Definition: dwa_planner.h:418
+
double dist_to_goal_th_
Definition: dwa_planner.h:426
+
double obs_range_
Definition: dwa_planner.h:431
-
Window(void)
Constructor.
Definition: dwa_planner.cpp:55
+
Window(void)
Constructor.
Definition: dwa_planner.cpp:52
-
ros::Subscriber scan_sub_
Definition: dwa_planner.h:465
-
bool edge_on_global_path_subscribed_
Definition: dwa_planner.h:439
-
void show(void)
Show the dynamic window information.
Definition: dwa_planner.cpp:57
-
double v_path_width_
Definition: dwa_planner.h:432
-
double max_deceleration_
Definition: dwa_planner.h:414
+
ros::Subscriber scan_sub_
Definition: dwa_planner.h:464
+
void show(void)
Show the dynamic window information.
Definition: dwa_planner.cpp:54
+
double v_path_width_
Definition: dwa_planner.h:434
+
double max_deceleration_
Definition: dwa_planner.h:416
-
bool use_speed_cost_
Definition: dwa_planner.h:436
-
bool has_reached_
Definition: dwa_planner.h:443
+
bool use_speed_cost_
Definition: dwa_planner.h:438
+
bool has_reached_
Definition: dwa_planner.h:442
void print_params(void)
Print parameters.
Definition: parameters.cpp:64
-
ros::NodeHandle local_nh_
Definition: dwa_planner.h:453
+
ros::NodeHandle local_nh_
Definition: dwa_planner.h:452
void load_params(void)
Load parameters.
Definition: parameters.cpp:8
-
Cost evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)
Evaluate trajectory.
+
Cost evaluate_trajectory(const std::vector< State > &trajectory, const Eigen::Vector3d &goal)
Evaluate trajectory.
-
bool can_adjust_robot_direction(const Eigen::Vector3d &goal)
Check if the robot can adjust the direction.
-
bool local_map_updated_
Definition: dwa_planner.h:441
-
double slow_velocity_th_
Definition: dwa_planner.h:428
-
visualization_msgs::Marker create_marker_msg(const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())
Create a marker message.
-
std::string robot_frame_
Definition: dwa_planner.h:404
-
ros::Publisher predict_footprints_pub_
Definition: dwa_planner.h:457
-
void process(void)
Execute local path planning.
-
State(void)
Constructor.
Definition: dwa_planner.cpp:48
-
std::vector< State > dwa_planning(const Eigen::Vector3d &goal, std::vector< std::pair< std::vector< State >, bool >> &trajectories)
Execute dwa planning.
-
int subscribe_count_th_
Definition: dwa_planner.h:447
-
ros::Publisher selected_trajectory_pub_
Definition: dwa_planner.h:456
-
ros::Subscriber target_velocity_sub_
Definition: dwa_planner.h:466
-
ros::Subscriber odom_sub_
Definition: dwa_planner.h:464
+
bool can_adjust_robot_direction(const Eigen::Vector3d &goal)
Check if the robot can adjust the direction.
+
std::optional< geometry_msgs::PolygonStamped > footprint_
Definition: dwa_planner.h:470
+
bool local_map_updated_
Definition: dwa_planner.h:440
+
double slow_velocity_th_
Definition: dwa_planner.h:430
+
visualization_msgs::Marker create_marker_msg(const int id, const double scale, const std_msgs::ColorRGBA color, const std::vector< State > &trajectory, const geometry_msgs::PolygonStamped &footprint=geometry_msgs::PolygonStamped())
Create a marker message.
+
std::string robot_frame_
Definition: dwa_planner.h:406
+
ros::Publisher predict_footprints_pub_
Definition: dwa_planner.h:456
+
void process(void)
Execute local path planning.
+
State(void)
Constructor.
Definition: dwa_planner.cpp:45
+
std::vector< State > dwa_planning(const Eigen::Vector3d &goal, std::vector< std::pair< std::vector< State >, bool >> &trajectories)
Execute dwa planning.
+
int subscribe_count_th_
Definition: dwa_planner.h:446
+
ros::Publisher selected_trajectory_pub_
Definition: dwa_planner.h:455
+
ros::Subscriber target_velocity_sub_
Definition: dwa_planner.h:465
+
ros::Subscriber odom_sub_
Definition: dwa_planner.h:463
A class implementing a local planner using the Dynamic Window Approach.
Definition: dwa_planner.h:38
-
bool is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
Check if the obstacle is inside of robot footprint.
-
double turn_direction_th_
Definition: dwa_planner.h:425
-
double speed_cost_gain_
Definition: dwa_planner.h:422
-
double robot_radius_
Definition: dwa_planner.h:430
-
double max_d_yawrate_
Definition: dwa_planner.h:415
+
bool is_inside_of_robot(const geometry_msgs::Point &obstacle, const geometry_msgs::PolygonStamped &footprint, const State &state)
Check if the obstacle is inside of robot footprint.
+
double turn_direction_th_
Definition: dwa_planner.h:427
+
double speed_cost_gain_
Definition: dwa_planner.h:424
+
double robot_radius_
Definition: dwa_planner.h:432
+
double max_d_yawrate_
Definition: dwa_planner.h:417
-
float calc_to_goal_cost(const std::vector< State > &traj, const Eigen::Vector3d &goal)
Calculate the distance of current pose to goal pose.
-
double target_velocity_
Definition: dwa_planner.h:406
-
double footprint_padding_
Definition: dwa_planner.h:431
-
double max_in_place_yawrate_
Definition: dwa_planner.h:411
-
bool odom_updated_
Definition: dwa_planner.h:440
-
std::string global_frame_
Definition: dwa_planner.h:403
-
double min_velocity_
Definition: dwa_planner.h:408
+
float calc_to_goal_cost(const std::vector< State > &traj, const Eigen::Vector3d &goal)
Calculate the distance of current pose to goal pose.
+
double target_velocity_
Definition: dwa_planner.h:408
+
double footprint_padding_
Definition: dwa_planner.h:433
+
double max_in_place_yawrate_
Definition: dwa_planner.h:413
+
bool odom_updated_
Definition: dwa_planner.h:439
+
std::string global_frame_
Definition: dwa_planner.h:405
+
double min_velocity_
Definition: dwa_planner.h:410


dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner__node_8cpp.html b/docs/dwa__planner__node_8cpp.html index fee2f98..7e3c600 100644 --- a/docs/dwa__planner__node_8cpp.html +++ b/docs/dwa__planner__node_8cpp.html @@ -102,7 +102,7 @@

dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/dwa__planner__node_8cpp_source.html b/docs/dwa__planner__node_8cpp_source.html index 34b87b2..5bbe5f5 100644 --- a/docs/dwa__planner__node_8cpp_source.html +++ b/docs/dwa__planner__node_8cpp_source.html @@ -39,14 +39,14 @@
int main(int argc, char **argv)
-
void process(void)
Execute local path planning.
+
void process(void)
Execute local path planning.
A class implementing a local planner using the Dynamic Window Approach.
Definition: dwa_planner.h:38


dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/files.html b/docs/files.html index b06517e..9012c5d 100644 --- a/docs/files.html +++ b/docs/files.html @@ -35,7 +35,7 @@
dwa_planner
Author(s):
-autogenerated on Sun Apr 28 2024 18:44:24 +autogenerated on Thu May 9 2024 01:28:03
diff --git a/docs/functions.html b/docs/functions.html index c37f820..66f045c 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -73,11 +73,14 @@

- c -