trajectory_planner_ros.h
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * Software License Agreement (BSD License)
4 *
5 * Copyright (c) 2008, Willow Garage, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of the Willow Garage nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 * Author: Eitan Marder-Eppstein
36 *********************************************************************/
37 #ifndef TRAJECTORY_ROLLOUT_TRAJECTORY_PLANNER_ROS_H_
38 #define TRAJECTORY_ROLLOUT_TRAJECTORY_PLANNER_ROS_H_
39 
40 #include <ros/ros.h>
41 #include <costmap_2d/costmap_2d.h>
50 
52 
53 #include <nav_msgs/Odometry.h>
54 #include <geometry_msgs/PoseStamped.h>
55 #include <geometry_msgs/Twist.h>
56 #include <geometry_msgs/Point.h>
57 
58 #include <tf2_ros/buffer.h>
59 
60 #include <boost/thread.hpp>
61 
62 #include <string>
63 
64 #include <angles/angles.h>
65 
67 
68 #include <dynamic_reconfigure/server.h>
69 #include <base_local_planner/BaseLocalPlannerConfig.h>
70 
72 
73 namespace base_local_planner {
78  class TrajectoryPlannerROS : public nav_core::BaseLocalPlanner {
79  public:
84 
91  TrajectoryPlannerROS(std::string name,
93  costmap_2d::Costmap2DROS* costmap_ros);
94 
101  void initialize(std::string name, tf2_ros::Buffer* tf,
102  costmap_2d::Costmap2DROS* costmap_ros);
103 
108 
115  bool computeVelocityCommands(geometry_msgs::Twist& cmd_vel);
116 
122  bool setPlan(const std::vector<geometry_msgs::PoseStamped>& orig_global_plan);
123 
128  bool isGoalReached();
129 
141  bool checkTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map = true);
142 
154  double scoreTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map = true);
155 
156  bool isInitialized() {
157  return initialized_;
158  }
159 
161  TrajectoryPlanner* getPlanner() const { return tc_; }
162 
163  private:
167  void reconfigureCB(BaseLocalPlannerConfig &config, uint32_t level);
168 
177  bool rotateToGoal(const geometry_msgs::PoseStamped& global_pose, const geometry_msgs::PoseStamped& robot_vel, double goal_th, geometry_msgs::Twist& cmd_vel);
178 
186  bool stopWithAccLimits(const geometry_msgs::PoseStamped& global_pose, const geometry_msgs::PoseStamped& robot_vel, geometry_msgs::Twist& cmd_vel);
187 
188  std::vector<double> loadYVels(ros::NodeHandle node);
189 
190  double sign(double x){
191  return x < 0.0 ? -1.0 : 1.0;
192  }
193 
196 
201  std::string global_frame_;
202  double max_sensor_range_;
203  nav_msgs::Odometry base_odom_;
204  std::string robot_base_frame_;
207  std::vector<geometry_msgs::PoseStamped> global_plan_;
208  bool prune_plan_;
209  boost::recursive_mutex odom_lock_;
210 
211  double max_vel_th_, min_vel_th_;
213  double sim_period_;
214  bool rotating_to_goal_;
215  bool reached_goal_;
217 
219 
220  dynamic_reconfigure::Server<BaseLocalPlannerConfig> *dsrv_;
221  base_local_planner::BaseLocalPlannerConfig default_config_;
222  bool setup_;
223 
224 
227 
228  std::vector<geometry_msgs::Point> footprint_spec_;
229  };
230 };
231 #endif
base_local_planner::TrajectoryPlannerROS::getPlanner
TrajectoryPlanner * getPlanner() const
Return the inner TrajectoryPlanner object. Only valid after initialize().
Definition: trajectory_planner_ros.h:196
ros::Publisher
base_local_planner::TrajectoryPlannerROS::default_config_
base_local_planner::BaseLocalPlannerConfig default_config_
Definition: trajectory_planner_ros.h:256
base_local_planner::TrajectoryPlannerROS::tc_
TrajectoryPlanner * tc_
The trajectory controller.
Definition: trajectory_planner_ros.h:230
base_local_planner::MapGridVisualizer
Definition: map_grid_visualizer.h:74
ros.h
map_grid_visualizer.h
base_local_planner::TrajectoryPlannerROS::min_vel_th_
double min_vel_th_
Definition: trajectory_planner_ros.h:246
costmap_2d.h
base_local_planner::TrajectoryPlannerROS::checkTrajectory
bool checkTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map=true)
Generate and score a single trajectory.
Definition: trajectory_planner_ros.cpp:590
base_local_planner::TrajectoryPlannerROS::l_plan_pub_
ros::Publisher l_plan_pub_
Definition: trajectory_planner_ros.h:253
base_local_planner::TrajectoryPlannerROS::base_odom_
nav_msgs::Odometry base_odom_
Used to get the velocity of the robot.
Definition: trajectory_planner_ros.h:238
base_local_planner::TrajectoryPlannerROS::odom_helper_
base_local_planner::OdometryHelperRos odom_helper_
Definition: trajectory_planner_ros.h:261
base_local_planner::TrajectoryPlannerROS::computeVelocityCommands
bool computeVelocityCommands(geometry_msgs::Twist &cmd_vel)
Given the current position, orientation, and velocity of the robot, compute velocity commands to send...
Definition: trajectory_planner_ros.cpp:434
buffer.h
costmap_2d::Costmap2D
base_local_planner::TrajectoryPlannerROS::scoreTrajectory
double scoreTrajectory(double vx_samp, double vy_samp, double vtheta_samp, bool update_map=true)
Generate and score a single trajectory.
Definition: trajectory_planner_ros.cpp:619
costmap_2d_ros.h
base_local_planner::TrajectoryPlannerROS::max_vel_th_
double max_vel_th_
Definition: trajectory_planner_ros.h:246
base_local_planner::TrajectoryPlannerROS::~TrajectoryPlannerROS
~TrajectoryPlannerROS()
Destructor for the wrapper.
Definition: trajectory_planner_ros.cpp:334
base_local_planner::TrajectoryPlannerROS::rotating_to_goal_
bool rotating_to_goal_
Definition: trajectory_planner_ros.h:249
base_local_planner::TrajectoryPlannerROS::min_in_place_vel_th_
double min_in_place_vel_th_
Definition: trajectory_planner_ros.h:241
base_local_planner::TrajectoryPlannerROS::reconfigureCB
void reconfigureCB(BaseLocalPlannerConfig &config, uint32_t level)
Callback to update the local planner's parameters based on dynamic reconfigure.
Definition: trajectory_planner_ros.cpp:99
base_local_planner::TrajectoryPlannerROS::world_model_
WorldModel * world_model_
The world model that the controller will use.
Definition: trajectory_planner_ros.h:229
base_local_planner::TrajectoryPlannerROS::global_frame_
std::string global_frame_
The frame in which the controller will run.
Definition: trajectory_planner_ros.h:236
costmap_model.h
base_local_planner::TrajectoryPlannerROS::setup_
bool setup_
Definition: trajectory_planner_ros.h:257
base_local_planner.h
base_local_planner::TrajectoryPlannerROS::initialize
void initialize(std::string name, tf2_ros::Buffer *tf, costmap_2d::Costmap2DROS *costmap_ros)
Constructs the ros wrapper.
Definition: trajectory_planner_ros.cpp:123
base_local_planner::TrajectoryPlannerROS::prune_plan_
bool prune_plan_
Definition: trajectory_planner_ros.h:243
base_local_planner::TrajectoryPlannerROS::odom_lock_
boost::recursive_mutex odom_lock_
Definition: trajectory_planner_ros.h:244
base_local_planner::TrajectoryPlannerROS::rot_stopped_velocity_
double rot_stopped_velocity_
Definition: trajectory_planner_ros.h:240
base_local_planner::TrajectoryPlannerROS::costmap_ros_
costmap_2d::Costmap2DROS * costmap_ros_
The ROS wrapper for the costmap the controller will use.
Definition: trajectory_planner_ros.h:232
odometry_helper_ros.h
base_local_planner::TrajectoryPlannerROS::latch_xy_goal_tolerance_
bool latch_xy_goal_tolerance_
Definition: trajectory_planner_ros.h:251
base_local_planner::TrajectoryPlannerROS::footprint_spec_
std::vector< geometry_msgs::Point > footprint_spec_
Definition: trajectory_planner_ros.h:263
base_local_planner::OdometryHelperRos
Definition: odometry_helper_ros.h:83
tf2_ros::Buffer
base_local_planner::TrajectoryPlannerROS::acc_lim_theta_
double acc_lim_theta_
Definition: trajectory_planner_ros.h:247
base_local_planner::TrajectoryPlannerROS::robot_base_frame_
std::string robot_base_frame_
Used as the base frame id of the robot.
Definition: trajectory_planner_ros.h:239
base_local_planner::TrajectoryPlannerROS::costmap_
costmap_2d::Costmap2D * costmap_
The costmap the controller will use.
Definition: trajectory_planner_ros.h:233
costmap_2d_publisher.h
base_local_planner::TrajectoryPlannerROS::xy_goal_tolerance_
double xy_goal_tolerance_
Definition: trajectory_planner_ros.h:241
base_local_planner::WorldModel
An interface the trajectory controller uses to interact with the world regardless of the underlying w...
Definition: world_model.h:87
base_local_planner::TrajectoryPlannerROS::global_plan_
std::vector< geometry_msgs::PoseStamped > global_plan_
Definition: trajectory_planner_ros.h:242
trajectory_planner.h
base_local_planner::TrajectoryPlannerROS::acc_lim_y_
double acc_lim_y_
Definition: trajectory_planner_ros.h:247
base_local_planner::TrajectoryPlannerROS::xy_tolerance_latch_
bool xy_tolerance_latch_
Definition: trajectory_planner_ros.h:251
voxel_grid_model.h
base_local_planner::TrajectoryPlannerROS::acc_lim_x_
double acc_lim_x_
Definition: trajectory_planner_ros.h:247
base_local_planner::TrajectoryPlannerROS::reached_goal_
bool reached_goal_
Definition: trajectory_planner_ros.h:250
base_local_planner::TrajectoryPlannerROS::setPlan
bool setPlan(const std::vector< geometry_msgs::PoseStamped > &orig_global_plan)
Set the plan that the controller is following.
Definition: trajectory_planner_ros.cpp:417
base_local_planner::TrajectoryPlannerROS::isInitialized
bool isInitialized()
Definition: trajectory_planner_ros.h:191
base_local_planner::TrajectoryPlannerROS::isGoalReached
bool isGoalReached()
Check if the goal pose has been achieved.
Definition: trajectory_planner_ros.cpp:648
base_local_planner::TrajectoryPlannerROS::loadYVels
std::vector< double > loadYVels(ros::NodeHandle node)
Definition: trajectory_planner_ros.cpp:310
base_local_planner::TrajectoryPlanner
Computes control velocities for a robot given a costmap, a plan, and the robot's position in the worl...
Definition: trajectory_planner.h:101
base_local_planner::TrajectoryPlannerROS::max_sensor_range_
double max_sensor_range_
Keep track of the effective maximum range of our sensors.
Definition: trajectory_planner_ros.h:237
tf
base_local_planner::TrajectoryPlannerROS::dsrv_
dynamic_reconfigure::Server< BaseLocalPlannerConfig > * dsrv_
Definition: trajectory_planner_ros.h:255
base_local_planner::TrajectoryPlannerROS::map_viz_
MapGridVisualizer map_viz_
The map grid visualizer for outputting the potential field generated by the cost function.
Definition: trajectory_planner_ros.h:234
base_local_planner::TrajectoryPlannerROS::stopWithAccLimits
bool stopWithAccLimits(const geometry_msgs::PoseStamped &global_pose, const geometry_msgs::PoseStamped &robot_vel, geometry_msgs::Twist &cmd_vel)
Stop the robot taking into account acceleration limits.
Definition: trajectory_planner_ros.cpp:345
base_local_planner::TrajectoryPlannerROS::initialized_
bool initialized_
Definition: trajectory_planner_ros.h:260
base_local_planner
Definition: costmap_model.h:44
base_local_planner::TrajectoryPlannerROS::tf_
tf2_ros::Buffer * tf_
Used for transforming point clouds.
Definition: trajectory_planner_ros.h:235
base_local_planner::TrajectoryPlannerROS::TrajectoryPlannerROS
TrajectoryPlannerROS()
Default constructor for the ros wrapper.
Definition: trajectory_planner_ros.cpp:113
point_grid.h
costmap_2d::Costmap2DROS
base_local_planner::TrajectoryPlannerROS::g_plan_pub_
ros::Publisher g_plan_pub_
Definition: trajectory_planner_ros.h:253
nav_core::BaseLocalPlanner
base_local_planner::TrajectoryPlannerROS::sim_period_
double sim_period_
Definition: trajectory_planner_ros.h:248
planar_laser_scan.h
ros::NodeHandle
angles.h
base_local_planner::TrajectoryPlannerROS::sign
double sign(double x)
Definition: trajectory_planner_ros.h:225
base_local_planner::TrajectoryPlannerROS::rotateToGoal
bool rotateToGoal(const geometry_msgs::PoseStamped &global_pose, const geometry_msgs::PoseStamped &robot_vel, double goal_th, geometry_msgs::Twist &cmd_vel)
Once a goal position is reached... rotate to the goal orientation.
Definition: trajectory_planner_ros.cpp:374
base_local_planner::TrajectoryPlannerROS::yaw_goal_tolerance_
double yaw_goal_tolerance_
Definition: trajectory_planner_ros.h:241
world_model.h
base_local_planner::TrajectoryPlannerROS::trans_stopped_velocity_
double trans_stopped_velocity_
Definition: trajectory_planner_ros.h:240


base_local_planner
Author(s): Eitan Marder-Eppstein, Eric Perko, contradict@gmail.com
autogenerated on Mon Mar 6 2023 03:50:24