53 for(std::vector<TrajectoryCostFunction*>::iterator score_function =
critics_.begin(); score_function !=
critics_.end(); ++score_function) {
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;
87 for (std::vector<TrajectoryCostFunction*>::iterator loop_critic =
critics_.begin(); loop_critic !=
critics_.end(); ++loop_critic) {
89 if (loop_critic_p->
prepare() ==
false) {
90 ROS_WARN(
"A scoring function failed to prepare");
95 for (std::vector<TrajectorySampleGenerator*>::iterator loop_gen =
gen_list_.begin(); loop_gen !=
gen_list_.end(); ++loop_gen) {
101 if (gen_success ==
false) {
106 if (all_explored != NULL) {
107 loop_traj.
cost_ = loop_traj_cost;
108 all_explored->push_back(loop_traj);
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;