56 initialize(cfg, obstacles, robot_model, visual, via_points);
121 g2o::Factory* factory = g2o::Factory::instance();
122 factory->registerType(
"VERTEX_POSE",
new g2o::HyperGraphElementCreator<VertexPose>);
123 factory->registerType(
"VERTEX_TIMEDIFF",
new g2o::HyperGraphElementCreator<VertexTimeDiff>);
125 factory->registerType(
"EDGE_TIME_OPTIMAL",
new g2o::HyperGraphElementCreator<EdgeTimeOptimal>);
126 factory->registerType(
"EDGE_VELOCITY",
new g2o::HyperGraphElementCreator<EdgeVelocity>);
127 factory->registerType(
"EDGE_VELOCITY_HOLONOMIC",
new g2o::HyperGraphElementCreator<EdgeVelocityHolonomic>);
128 factory->registerType(
"EDGE_ACCELERATION",
new g2o::HyperGraphElementCreator<EdgeAcceleration>);
129 factory->registerType(
"EDGE_ACCELERATION_START",
new g2o::HyperGraphElementCreator<EdgeAccelerationStart>);
130 factory->registerType(
"EDGE_ACCELERATION_GOAL",
new g2o::HyperGraphElementCreator<EdgeAccelerationGoal>);
131 factory->registerType(
"EDGE_ACCELERATION_HOLONOMIC",
new g2o::HyperGraphElementCreator<EdgeAccelerationHolonomic>);
132 factory->registerType(
"EDGE_ACCELERATION_HOLONOMIC_START",
new g2o::HyperGraphElementCreator<EdgeAccelerationHolonomicStart>);
133 factory->registerType(
"EDGE_ACCELERATION_HOLONOMIC_GOAL",
new g2o::HyperGraphElementCreator<EdgeAccelerationHolonomicGoal>);
134 factory->registerType(
"EDGE_KINEMATICS_DIFF_DRIVE",
new g2o::HyperGraphElementCreator<EdgeKinematicsDiffDrive>);
135 factory->registerType(
"EDGE_KINEMATICS_CARLIKE",
new g2o::HyperGraphElementCreator<EdgeKinematicsCarlike>);
136 factory->registerType(
"EDGE_OBSTACLE",
new g2o::HyperGraphElementCreator<EdgeObstacle>);
137 factory->registerType(
"EDGE_INFLATED_OBSTACLE",
new g2o::HyperGraphElementCreator<EdgeInflatedObstacle>);
138 factory->registerType(
"EDGE_DYNAMIC_OBSTACLE",
new g2o::HyperGraphElementCreator<EdgeDynamicObstacle>);
139 factory->registerType(
"EDGE_VIA_POINT",
new g2o::HyperGraphElementCreator<EdgeViaPoint>);
140 factory->registerType(
"EDGE_PREFER_ROTDIR",
new g2o::HyperGraphElementCreator<EdgePreferRotDir>);
151 static boost::once_flag flag = BOOST_ONCE_INIT;
157 linearSolver->setBlockOrdering(
true);
159 g2o::OptimizationAlgorithmLevenberg* solver =
new g2o::OptimizationAlgorithmLevenberg(blockSolver);
161 optimizer->setAlgorithm(solver);
163 optimizer->initMultiThreading();
170 double obst_cost_scale,
double viapoint_cost_scale,
bool alternative_time_cost)
175 bool success =
false;
178 double weight_multiplier = 1.0;
186 for(
int i=0; i<iterations_outerloop; ++i)
209 if (compute_cost_afterwards && i==iterations_outerloop-1)
223 vel_start_.second.linear.x = vel_start.linear.x;
224 vel_start_.second.linear.y = vel_start.linear.y;
225 vel_start_.second.angular.z = vel_start.angular.z;
244 PoseSE2 start_(initial_plan.front().pose);
245 PoseSE2 goal_(initial_plan.back().pose);
250 ROS_DEBUG(
"New goal: distance to existing goal is higher than the specified threshold. Reinitalizing trajectories.");
271 return plan(start_, goal_, start_vel);
288 ROS_DEBUG(
"New goal: distance to existing goal is higher than the specified threshold. Reinitalizing trajectories.");
309 ROS_WARN(
"Cannot build graph, because it is not empty. Call graphClear()!");
348 ROS_WARN(
"optimizeGraph(): Robot Max Velocity is smaller than 0.01m/s. Optimizing aborted...");
355 ROS_WARN(
"optimizeGraph(): TEB is empty or has too less elements. Skipping optimization.");
363 int iter =
optimizer_->optimize(no_iterations);
371 ROS_ERROR(
"optimizeGraph(): Optimization failed! iter=%i", iter);
394 unsigned int id_counter = 0;
416 Eigen::Matrix<double,1,1> information;
419 Eigen::Matrix<double,2,2> information_inflated;
422 information_inflated(0,1) = information_inflated(1,0) = 0;
427 double left_min_dist = std::numeric_limits<double>::max();
428 double right_min_dist = std::numeric_limits<double>::max();
432 std::vector<Obstacle*> relevant_obstacles;
450 relevant_obstacles.push_back(obst.get());
458 if (
cross2d(pose_orient, obst->getCentroid()) > 0)
460 if (dist < left_min_dist)
462 left_min_dist = dist;
463 left_obstacle = obst.get();
468 if (dist < right_min_dist)
470 right_min_dist = dist;
471 right_obstacle = obst.get();
483 dist_bandpt_obst->setInformation(information_inflated);
491 dist_bandpt_obst->setInformation(information);
503 dist_bandpt_obst->setInformation(information_inflated);
511 dist_bandpt_obst->setInformation(information);
517 for (
const Obstacle* obst : relevant_obstacles)
523 dist_bandpt_obst->setInformation(information_inflated);
531 dist_bandpt_obst->setInformation(information);
546 Eigen::Matrix<double,1,1> information;
549 Eigen::Matrix<double,2,2> information_inflated;
552 information_inflated(0,1) = information_inflated(1,0) = 0;
556 for (ObstContainer::const_iterator obst =
obstacles_->begin(); obst !=
obstacles_->end(); ++obst)
577 dist_bandpt_obst->setInformation(information_inflated);
585 dist_bandpt_obst->setInformation(information);
597 dist_bandpt_obst_n_r->setVertex(0,
teb_.
PoseVertex(index+neighbourIdx));
598 dist_bandpt_obst_n_r->setInformation(information_inflated);
605 dist_bandpt_obst_n_r->setVertex(0,
teb_.
PoseVertex(index+neighbourIdx));
606 dist_bandpt_obst_n_r->setInformation(information);
611 if ( index - neighbourIdx >= 0)
616 dist_bandpt_obst_n_l->setVertex(0,
teb_.
PoseVertex(index-neighbourIdx));
617 dist_bandpt_obst_n_l->setInformation(information_inflated);
624 dist_bandpt_obst_n_l->setVertex(0,
teb_.
PoseVertex(index-neighbourIdx));
625 dist_bandpt_obst_n_l->setInformation(information);
641 Eigen::Matrix<double,2,2> information;
644 information(0,1) = information(1,0) = 0;
646 for (ObstContainer::const_iterator obst =
obstacles_->begin(); obst !=
obstacles_->end(); ++obst)
648 if (!(*obst)->isDynamic())
657 dynobst_edge->setInformation(information);
670 int start_pose_idx = 0;
676 for (ViaPointContainer::const_iterator vp_it =
via_points_->begin(); vp_it !=
via_points_->end(); ++vp_it)
681 start_pose_idx = index+2;
695 ROS_DEBUG(
"TebOptimalPlanner::AddEdgesViaPoints(): skipping a via-point that is close or behind the current robot pose.");
699 Eigen::Matrix<double,1,1> information;
704 edge_viapoint->setInformation(information);
718 Eigen::Matrix<double,2,2> information;
721 information(0,1) = 0.0;
722 information(1,0) = 0.0;
724 for (
int i=0; i < n - 1; ++i)
730 velocity_edge->setInformation(information);
741 Eigen::Matrix<double,3,3> information;
747 for (
int i=0; i < n - 1; ++i)
753 velocity_edge->setInformation(information);
770 Eigen::Matrix<double,2,2> information;
783 acceleration_edge->setInformation(information);
789 for (
int i=0; i < n - 2; ++i)
797 acceleration_edge->setInformation(information);
810 acceleration_edge->setInformation(information);
817 Eigen::Matrix<double,3,3> information;
831 acceleration_edge->setInformation(information);
837 for (
int i=0; i < n - 2; ++i)
845 acceleration_edge->setInformation(information);
858 acceleration_edge->setInformation(information);
872 Eigen::Matrix<double,1,1> information;
879 timeoptimal_edge->setInformation(information);
893 Eigen::Matrix<double,2,2> information_kinematics;
894 information_kinematics.fill(0.0);
903 kinematics_edge->setInformation(information_kinematics);
915 Eigen::Matrix<double,2,2> information_kinematics;
916 information_kinematics.fill(0.0);
925 kinematics_edge->setInformation(information_kinematics);
946 ROS_WARN(
"TebOptimalPlanner::AddEdgesPreferRotDir(): unsupported RotType selected. Skipping edge creation.");
951 Eigen::Matrix<double,1,1> information_rotdir;
959 rotdir_edge->setInformation(information_rotdir);
973 bool graph_exist_flag(
false);
983 graph_exist_flag =
true;
990 if (alternative_time_cost)
999 for (std::vector<g2o::OptimizableGraph::Edge*>::const_iterator it =
optimizer_->activeEdges().begin(); it!=
optimizer_->activeEdges().end(); it++)
1002 if (edge_time_optimal!=NULL && !alternative_time_cost)
1009 if (edge_kinematics_dd!=NULL)
1016 if (edge_kinematics_cl!=NULL)
1023 if (edge_velocity!=NULL)
1030 if (edge_acceleration!=NULL)
1037 if (edge_obstacle!=NULL)
1039 cost_ += edge_obstacle->
getError().squaredNorm() * obst_cost_scale;
1044 if (edge_inflated_obstacle!=NULL)
1046 cost_ += std::sqrt(std::pow(edge_inflated_obstacle->
getError()[0],2) * obst_cost_scale
1047 + std::pow(edge_inflated_obstacle->
getError()[1],2));
1052 if (edge_dyn_obstacle!=NULL)
1054 cost_ += edge_dyn_obstacle->
getError().squaredNorm() * obst_cost_scale;
1059 if (edge_viapoint!=NULL)
1061 cost_ += edge_viapoint->
getError().squaredNorm() * viapoint_cost_scale;
1067 if (!graph_exist_flag)
1088 double dir = deltaS.dot(conf1dir);
1089 vx = (double)
g2o::sign(dir) * deltaS.norm()/dt;
1097 double cos_theta1 = std::cos(pose1.
theta());
1098 double sin_theta1 = std::sin(pose1.
theta());
1099 double p1_dx = cos_theta1*deltaS.x() + sin_theta1*deltaS.y();
1100 double p1_dy = -sin_theta1*deltaS.x() + cos_theta1*deltaS.y();
1106 double orientdiff = g2o::normalize_theta(pose2.
theta() - pose1.
theta());
1107 omega = orientdiff/dt;
1114 ROS_ERROR(
"TebOptimalPlanner::getVelocityCommand(): The trajectory contains less than 2 poses. Make sure to init and optimize/plan the trajectory fist.");
1124 ROS_ERROR(
"TebOptimalPlanner::getVelocityCommand() - timediff<=0 is invalid!");
1139 velocity_profile.resize( n+1 );
1142 velocity_profile.front().linear.z = 0;
1143 velocity_profile.front().angular.x = velocity_profile.front().angular.y = 0;
1144 velocity_profile.front().linear.x =
vel_start_.second.linear.x;
1145 velocity_profile.front().linear.y =
vel_start_.second.linear.y;
1146 velocity_profile.front().angular.z =
vel_start_.second.angular.z;
1148 for (
int i=1; i<n; ++i)
1150 velocity_profile[i].linear.z = 0;
1151 velocity_profile[i].angular.x = velocity_profile[i].angular.y = 0;
1156 velocity_profile.back().linear.z = 0;
1157 velocity_profile.back().angular.x = velocity_profile.back().angular.y = 0;
1158 velocity_profile.back().linear.x =
vel_goal_.second.linear.x;
1159 velocity_profile.back().linear.y =
vel_goal_.second.linear.y;
1160 velocity_profile.back().angular.z =
vel_goal_.second.angular.z;
1167 trajectory.resize(n);
1172 double curr_time = 0;
1175 TrajectoryPointMsg& start = trajectory.front();
1177 start.velocity.linear.z = 0;
1178 start.velocity.angular.x = start.velocity.angular.y = 0;
1179 start.velocity.linear.x =
vel_start_.second.linear.x;
1180 start.velocity.linear.y =
vel_start_.second.linear.y;
1181 start.velocity.angular.z =
vel_start_.second.angular.z;
1182 start.time_from_start.fromSec(curr_time);
1187 for (
int i=1; i < n-1; ++i)
1189 TrajectoryPointMsg&
point = trajectory[i];
1191 point.velocity.linear.z = 0;
1192 point.velocity.angular.x = point.velocity.angular.y = 0;
1193 double vel1_x, vel1_y, vel2_x, vel2_y, omega1, omega2;
1196 point.velocity.linear.x = 0.5*(vel1_x+vel2_x);
1197 point.velocity.linear.y = 0.5*(vel1_y+vel2_y);
1198 point.velocity.angular.z = 0.5*(omega1+omega2);
1199 point.time_from_start.fromSec(curr_time);
1205 TrajectoryPointMsg& goal = trajectory.back();
1207 goal.velocity.linear.z = 0;
1208 goal.velocity.angular.x = goal.velocity.angular.y = 0;
1209 goal.velocity.linear.x =
vel_goal_.second.linear.x;
1210 goal.velocity.linear.y =
vel_goal_.second.linear.y;
1211 goal.velocity.angular.z =
vel_goal_.second.angular.z;
1212 goal.time_from_start.fromSec(curr_time);
1217 double inscribed_radius,
double circumscribed_radius,
int look_ahead_idx)
1219 if (look_ahead_idx < 0 || look_ahead_idx >=
teb().sizePoses())
1222 for (
int i=0; i <= look_ahead_idx; ++i)
1229 if (i<look_ahead_idx)
1231 if ( (
teb().
Pose(i+1).position()-
teb().
Pose(i).position()).norm() > inscribed_radius)
1235 if ( costmap_model->
footprintCost(center.
x(), center.
y(), center.
theta(), footprint_spec, inscribed_radius, circumscribed_radius) < 0 )
1268 ROS_DEBUG(
"TebOptimalPlanner::isHorizonReductionAppropriate(): Goal orientation - start orientation > 90° ");
1275 ROS_DEBUG(
"TebOptimalPlanner::isHorizonReductionAppropriate(): Goal heading - start orientation > 90° ");
1281 for (; idx < (int)initial_plan.size(); ++idx)
1283 if ( std::sqrt(std::pow(initial_plan[idx].pose.position.x-
teb_.
Pose(0).
x(), 2) + std::pow(initial_plan[idx].pose.position.y-
teb_.
Pose(0).
y(), 2)) )
1287 double ref_path_length = 0;
1288 for (; idx < int(initial_plan.size())-1; ++idx)
1290 ref_path_length += std::sqrt(std::pow(initial_plan[idx+1].pose.position.x-initial_plan[idx].pose.position.x, 2)
1291 + std::pow(initial_plan[idx+1].pose.position.y-initial_plan[idx].pose.position.y, 2) );
1295 double teb_length = 0;
1301 ROS_DEBUG(
"TebOptimalPlanner::isHorizonReductionAppropriate(): Distance between consecutive poses > 0.9*min_obstacle_dist");
1304 ref_path_length += dist;
1306 if (ref_path_length>0 && teb_length/ref_path_length < 0.7)
1308 ROS_DEBUG(
"TebOptimalPlanner::isHorizonReductionAppropriate(): Planned trajectory is at least 30° shorter than the initial plan");
static void registerG2OTypes()
Register the vertices and edges defined for the TEB to the g2o::Factory.
Edge defining the cost function for limiting the translational and rotational acceleration at the end...
void setVelocityStart(const geometry_msgs::Twist &vel_start)
Set the initial velocity at the trajectory's start pose (e.g. the robot's velocity) [twist overload]...
bool optimizeGraph(int no_iterations, bool clear_after=true)
Optimize the previously constructed hyper-graph to deform / optimize the TEB.
void setVelocityGoalFree()
Set the desired final velocity at the trajectory's goal pose to be the maximum velocity limit...
Edge defining the cost function for keeping a distance from dynamic (moving) obstacles.
std::pair< bool, geometry_msgs::Twist > vel_start_
Store the initial velocity at the start pose.
double max_vel_y
Maximum strafing velocity of the robot (should be zero for non-holonomic robots!) ...
TimedElasticBand & teb()
Access the internal TimedElasticBand trajectory.
int max_samples
Maximum number of samples; Warning: if too small the discretization/resolution might not be sufficien...
void clearGraph()
Clear an existing internal hyper-graph.
virtual bool isTrajectoryFeasible(base_local_planner::CostmapModel *costmap_model, const std::vector< geometry_msgs::Point > &footprint_spec, double inscribed_radius=0.0, double circumscribed_radius=0.0, int look_ahead_idx=-1)
Check whether the planned trajectory is feasible or not.
double weight_adapt_factor
Some special weights (currently 'weight_obstacle') are repeatedly scaled by this factor in each outer...
bool allow_init_with_backwards_motion
If true, the underlying trajectories might be initialized with backwards motions in case the goal is ...
void setVisualization(TebVisualizationPtr visualization)
Register a TebVisualization class to enable visiualization routines (e.g. publish the local plan and ...
std::pair< bool, geometry_msgs::Twist > vel_goal_
Store the final velocity at the goal pose.
double min_obstacle_dist
Minimum desired separation from obstacles.
virtual void visualize()
Publish the local plan and pose sequence via ros topics (e.g. subscribe with rviz).
double weight_prefer_rotdir
Optimization weight for preferring a specific turning direction (-> currently only activated if an os...
Edge defining the cost function for limiting the translational and rotational acceleration at the end...
Edge defining the cost function for penalzing a specified turning direction, in particular left resp...
Eigen::Vector2d & position()
Access the 2D position part.
double cross2d(const V1 &v1, const V2 &v2)
Calculate the 2d cross product (returns length of the resulting vector along the z-axis in 3d) ...
void setTebConfig(const TebConfig &cfg)
Assign the TebConfig class for parameters.
Edge defining the cost function for minimizing transition time of the trajectory. ...
ErrorVector & getError()
Compute and return error / cost value.
double getSumOfAllTimeDiffs() const
Calculate the total transition time (sum over all time intervals of the timediff sequence) ...
void AddEdgesTimeOptimal()
Add all edges (local cost functions) for minimizing the transition time (resp. minimize time differen...
double dt_hysteresis
Hysteresis for automatic resizing depending on the current temporal resolution (dt): usually 10% of d...
Config class for the teb_local_planner and its components.
void AddEdgesAcceleration()
Add all edges (local cost functions) for limiting the translational and angular acceleration.
double weight_max_vel_theta
Optimization weight for satisfying the maximum allowed angular velocity.
static PoseSE2 average(const PoseSE2 &pose1, const PoseSE2 &pose2)
Get the mean / average of two poses and return the result (static) For the position part: 0...
boost::shared_ptr< g2o::SparseOptimizer > optimizer()
Access the internal g2o optimizer.
void setInitialVelocity(const geometry_msgs::Twist &vel_start)
Set the initial velocity that is taken into account for calculating the acceleration.
Edge defining the cost function for limiting the translational and rotational acceleration.
Edge defining the cost function for limiting the translational and rotational acceleration at the beg...
bool initTrajectoryToGoal(const PoseSE2 &start, const PoseSE2 &goal, double diststep=0, double max_vel_x=0.5, int min_samples=3, bool guess_backwards_motion=false)
Initialize a trajectory between a given start and goal pose.
void setVelocityGoal(const geometry_msgs::Twist &vel_goal)
Set the desired final velocity at the trajectory's goal pose.
struct teb_local_planner::TebConfig::Robot robot
Robot related parameters.
void setTebConfig(const TebConfig &cfg)
Assign the TebConfig class for parameters.
double min_turning_radius
Minimum turning radius of a carlike robot (diff-drive robot: zero);.
double & x()
Access the x-coordinate the pose.
Edge defining the cost function for limiting the translational and rotational velocity.
void setParameters(const TebConfig &cfg, const BaseRobotFootprintModel *robot_model, const Obstacle *obstacle)
Set all parameters at once.
struct teb_local_planner::TebConfig::Trajectory trajectory
Trajectory related parameters.
PoseSE2 & BackPose()
Access the last PoseSE2 in the pose sequence.
TebVisualizationPtr visual
double weight_max_vel_y
Optimization weight for satisfying the maximum allowed strafing velocity (in use only for holonomic r...
TFSIMD_FORCE_INLINE const tfScalar & y() const
void AddEdgesVelocity()
Add all edges (local cost functions) for limiting the translational and angular velocity.
void updateAndPruneTEB(boost::optional< const PoseSE2 & > new_start, boost::optional< const PoseSE2 & > new_goal, int min_samples=3)
Hot-Start from an existing trajectory with updated start and goal poses.
double weight_kinematics_turning_radius
Optimization weight for enforcing a minimum turning radius (carlike robots)
bool legacy_obstacle_association
If true, the old association strategy is used (for each obstacle, find the nearest TEB pose)...
double weight_acc_lim_x
Optimization weight for satisfying the maximum allowed translational acceleration.
void computeCurrentCost(double obst_cost_scale=1.0, double viapoint_cost_scale=1.0, bool alternative_time_cost=false)
Compute the cost vector of a given optimization problen (hyper-graph must exist). ...
int findClosestTrajectoryPose(const Eigen::Ref< const Eigen::Vector2d > &ref_point, double *distance=NULL, int begin_idx=0) const
Find the closest point on the trajectory w.r.t. to a provided reference point.
Eigen::Vector2d orientationUnitVec() const
Return the unit vector of the current orientation.
void setInitialVelocity(const geometry_msgs::Twist &vel_start)
Set the initial velocity that is taken into account for calculating the acceleration.
Edge defining the cost function for limiting the translational and rotational acceleration.
void AddEdgesPreferRotDir()
Add all edges (local cost functions) for prefering a specifiy turning direction (by penalizing the ot...
double weight_acc_lim_y
Optimization weight for satisfying the maximum allowed strafing acceleration (in use only for holonom...
virtual ~TebOptimalPlanner()
Destruct the optimal planner.
virtual bool getVelocityCommand(double &vx, double &vy, double &omega) const
Get the velocity command from a previously optimized plan to control the robot at the current samplin...
bool optimization_activate
Activate the optimization.
virtual bool plan(const std::vector< geometry_msgs::PoseStamped > &initial_plan, const geometry_msgs::Twist *start_vel=NULL, bool free_goal_vel=false)
Plan a trajectory based on an initial reference plan.
bool buildGraph(double weight_multiplier=1.0)
Build the hyper-graph representing the TEB optimization problem.
void AddTEBVertices()
Add all relevant vertices to the hyper-graph as optimizable variables.
ObstContainer * obstacles_
Store obstacles that are relevant for planning.
TebVisualizationPtr visualization_
Instance of the visualization class.
g2o::BlockSolver< g2o::BlockSolverTraits<-1,-1 > > TEBBlockSolver
Typedef for the block solver utilized for optimization.
double teb_autosize
Enable automatic resizing of the trajectory w.r.t to the temporal resolution (recommended) ...
Edge defining the cost function for keeping a minimum distance from obstacles.
bool via_points_ordered
If true, the planner adheres to the order of via-points in the storage container. ...
double obstacle_association_force_inclusion_factor
The non-legacy obstacle association technique tries to connect only relevant obstacles with the discr...
double weight_max_vel_x
Optimization weight for satisfying the maximum allowed translational velocity.
double force_reinit_new_goal_dist
Reinitialize the trajectory if a previous goal is updated with a seperation of more than the specifie...
double dt_ref
Desired temporal resolution of the trajectory (should be in the magniture of the underlying control r...
void setTebConfig(const TebConfig &cfg)
Assign the TebConfig class for parameters.
void setGoalVelocity(const geometry_msgs::Twist &vel_goal)
Set the goal / final velocity that is taken into account for calculating the acceleration.
Edge defining the cost function for limiting the translational and rotational velocity according to x...
RotType
Symbols for left/none/right rotations.
void AddEdgesViaPoints()
Add all edges (local cost functions) related to minimizing the distance to via-points.
int sizeTimeDiffs() const
Get the length of the internal timediff sequence.
Edge defining the cost function for keeping a minimum distance from inflated obstacles.
ErrorVector & getError()
Compute and return error / cost value.
bool initialized_
Keeps track about the correct initialization of this class.
void AddEdgesDynamicObstacles(double weight_multiplier=1.0)
Add all edges (local cost functions) related to keeping a distance from dynamic (moving) obstacles...
#define ROS_ASSERT_MSG(cond,...)
double weight_inflation
Optimization weight for the inflation penalty (should be small)
double & TimeDiff(int index)
Access the time difference at pos index of the time sequence.
std::vector< ObstaclePtr > ObstContainer
Abbrev. for containers storing multiple obstacles.
double weight_obstacle
Optimization weight for satisfying a minimum separation from obstacles.
bool optimized_
This variable is true as long as the last optimization has been completed successful.
TFSIMD_FORCE_INLINE const tfScalar & x() const
void setParameters(const TebConfig &cfg, const BaseRobotFootprintModel *robot_model, const Obstacle *obstacle)
Set all parameters at once.
TebOptimalPlanner()
Default constructor.
void getFullTrajectory(std::vector< TrajectoryPointMsg > &trajectory) const
Return the complete trajectory including poses, velocity profiles and temporal information.
ErrorVector & getError()
Compute and return error / cost value.
Edge defining the cost function for limiting the translational and rotational acceleration at the beg...
void toPoseMsg(geometry_msgs::Pose &pose) const
Convert PoseSE2 to a geometry_msgs::Pose.
void clearTimedElasticBand()
clear all poses and timediffs from the trajectory. The pose and timediff sequences will be empty and ...
PoseSE2 & Pose(int index)
Access the pose at pos index of the pose sequence.
VertexTimeDiff * TimeDiffVertex(int index)
Access the vertex of a time difference at pos index for optimization purposes.
RobotFootprintModelPtr robot_model_
Robot model.
#define ROS_DEBUG_COND(cond,...)
double & y()
Access the y-coordinate the pose.
This class implements a pose in the domain SE2: The pose consist of the position x and y and an orie...
double & theta()
Access the orientation part (yaw angle) of the pose.
double obstacle_association_cutoff_factor
See obstacle_association_force_inclusion_factor, but beyond a multiple of [value]*min_obstacle_dist a...
void initialize(const TebConfig &cfg, ObstContainer *obstacles=NULL, RobotFootprintModelPtr robot_model=boost::make_shared< PointRobotFootprint >(), TebVisualizationPtr visual=TebVisualizationPtr(), const ViaPointContainer *via_points=NULL)
Initializes the optimal planner.
int no_inner_iterations
Number of solver iterations called in each outerloop iteration.
void getVelocityProfile(std::vector< geometry_msgs::Twist > &velocity_profile) const
Compute the velocity profile of the trajectory.
double weight_acc_lim_theta
Optimization weight for satisfying the maximum allowed angular acceleration.
double weight_dynamic_obstacle_inflation
Optimization weight for the inflation penalty of dynamic obstacles (should be small) ...
int obstacle_poses_affected
The obstacle position is attached to the closest pose on the trajectory to reduce computational effor...
void setParameters(const TebConfig &cfg, const Eigen::Vector2d *via_point)
Set all parameters at once.
double weight_dynamic_obstacle
Optimization weight for satisfying a minimum separation from dynamic obstacles.
void setParameters(const TebConfig &cfg, const BaseRobotFootprintModel *robot_model, const Obstacle *obstacle)
Set all parameters at once.
double weight_optimaltime
Optimization weight for contracting the trajectory w.r.t transition time.
VertexPose * PoseVertex(int index)
Access the vertex of a pose at pos index for optimization purposes.
virtual double footprintCost(const geometry_msgs::Point &position, const std::vector< geometry_msgs::Point > &footprint, double inscribed_radius, double circumscribed_radius)
bool global_plan_overwrite_orientation
Overwrite orientation of local subgoals provided by the global planner.
double weight_kinematics_nh
Optimization weight for satisfying the non-holonomic kinematics.
void setGoalVelocity(const geometry_msgs::Twist &vel_goal)
Set the goal / final velocity that is taken into account for calculating the acceleration.
Edge defining the cost function for satisfying the non-holonomic kinematics of a carlike mobile robot...
Edge defining the cost function for pushing a configuration towards a via point.
double cost_
Store cost value of the current hyper-graph.
bool include_dynamic_obstacles
Specify whether the movement of dynamic obstacles should be predicted by a constant velocity model (t...
void AddEdgesKinematicsCarlike()
Add all edges (local cost functions) for satisfying kinematic constraints of a carlike robot...
void extractVelocity(const PoseSE2 &pose1, const PoseSE2 &pose2, double dt, double &vx, double &vy, double &omega) const
Extract the velocity from consecutive poses and a time difference (including strafing velocity for ho...
double weight_viapoint
Optimization weight for minimizing the distance to via-points.
ViaPointContainer via_points
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
int no_outer_iterations
Each outerloop iteration automatically resizes the trajectory and invokes the internal optimizer with...
struct teb_local_planner::TebConfig::Optimization optim
Optimization related parameters.
const ViaPointContainer * via_points_
Store via points for planning.
TimedElasticBand teb_
Actual trajectory object.
void autoResize(double dt_ref, double dt_hysteresis, int min_samples=3, int max_samples=1000, bool fast_mode=false)
Resize the trajectory by removing or inserting a (pose,dt) pair depending on a reference temporal res...
int sizePoses() const
Get the length of the internal pose sequence.
bool publish_feedback
Publish planner feedback containing the full trajectory and a list of active obstacles (should be ena...
boost::shared_ptr< g2o::SparseOptimizer > initOptimizer()
Initialize and configure the g2o sparse optimizer.
double acc_lim_y
Maximum strafing acceleration of the robot.
g2o::LinearSolverCSparse< TEBBlockSolver::PoseMatrixType > TEBLinearSolver
Typedef for the linear solver utilized for optimization.
void AddEdgesObstacles(double weight_multiplier=1.0)
Add all edges (local cost functions) related to keeping a distance from static obstacles.
bool isInit() const
Check whether the trajectory is initialized (nonzero pose and timediff sequences) ...
virtual bool isHorizonReductionAppropriate(const std::vector< geometry_msgs::PoseStamped > &initial_plan) const
Check if the planner suggests a shorter horizon (e.g. to resolve problems)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
const TebConfig * cfg_
Config class that stores and manages all related parameters.
double inflation_dist
buffer zone around obstacles with non-zero penalty costs (should be larger than min_obstacle_dist in ...
struct teb_local_planner::TebConfig::Obstacles obstacles
Obstacle related parameters.
double weight_kinematics_forward_drive
Optimization weight for forcing the robot to choose only forward directions (positive transl...
void AddEdgesKinematicsDiffDrive()
Add all edges (local cost functions) for satisfying kinematic constraints of a differential drive rob...
int min_samples
Minimum number of samples (should be always greater than 2)
std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > ViaPointContainer
Typedef for a container storing via-points.
bool optimizeTEB(int iterations_innerloop, int iterations_outerloop, bool compute_cost_afterwards=false, double obst_cost_scale=1.0, double viapoint_cost_scale=1.0, bool alternative_time_cost=false)
Optimize a previously initialized trajectory (actual TEB optimization loop).
Abstract class that defines the interface for modelling obstacles.
double max_vel_x
Maximum translational velocity of the robot.
bool optimization_verbose
Print verbose information.
boost::shared_ptr< g2o::SparseOptimizer > optimizer_
g2o optimizer for trajectory optimization
void AddEdgesObstaclesLegacy(double weight_multiplier=1.0)
Add all edges (local cost functions) related to keeping a distance from static obstacles (legacy asso...
RotType prefer_rotdir_
Store whether to prefer a specific initial rotation in optimization (might be activated in case the r...
Edge defining the cost function for satisfying the non-holonomic kinematics of a differential drive m...