Go to the documentation of this file.
40 #include <ros/console.h>
54 TrajectoryCostFunction* score_function_p = *score_function;
55 if (score_function_p->getScale() == 0) {
58 double cost = score_function_p->scoreTrajectory(traj);
60 ROS_DEBUG(
"Velocity %.3lf, %.3lf, %.3lf discarded by cost function %d with cost: %f", traj.xv_, traj.yv_, traj.thetav_, gen_id, cost);
65 cost *= score_function_p->getScale();
68 if (best_traj_cost > 0) {
70 if (traj_cost > best_traj_cost) {
84 double loop_traj_cost, best_traj_cost = -1;
86 int count, count_valid;
89 if (loop_critic_p->
prepare() ==
false) {
90 ROS_WARN(
"A scoring function failed to prepare");
101 if (gen_success ==
false) {
106 if (all_explored != NULL) {
107 loop_traj.
cost_ = loop_traj_cost;
111 if (loop_traj_cost >= 0) {
113 if (best_traj_cost < 0 || loop_traj_cost < best_traj_cost) {
114 best_traj_cost = loop_traj_cost;
115 best_traj = loop_traj;
123 if (best_traj_cost >= 0) {
127 traj.
cost_ = best_traj_cost;
130 for (
unsigned int i = 0; i < best_traj.
getPointsSize(); i++) {
135 ROS_DEBUG(
"Evaluated %d trajectories, found %d valid", count, count_valid);
136 if (best_traj_cost >= 0) {
141 return best_traj_cost >= 0;
void resetPoints()
Clear the trajectory's points.
Provides an interface for critics of trajectories During each sampling run, a batch of many trajector...
bool findBestTrajectory(Trajectory &traj, std::vector< Trajectory > *all_explored=0)
void addPoint(double x, double y, double th)
Add a point to the end of a trajectory.
virtual bool hasMoreTrajectories()=0
virtual bool nextTrajectory(Trajectory &traj)=0
Provides an interface for navigation trajectory generators.
double cost_
The cost/score of the trajectory.
std::vector< TrajectorySampleGenerator * > gen_list_
void getPoint(unsigned int index, double &x, double &y, double &th) const
Get a point within the trajectory.
unsigned int getPointsSize() const
Return the number of points in the trajectory.
std::vector< TrajectoryCostFunction * > critics_
Holds a trajectory generated by considering an x, y, and theta velocity.
double scoreTrajectory(Trajectory &traj, double best_traj_cost)
double thetav_
The x, y, and theta velocities of the trajectory.
SimpleScoredSamplingPlanner()