ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
evaluator_nav_cost.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Thomas Lobig - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
18 
19 namespace adore
20 {
21  namespace fun
22  {
27  {
28  private:
29  // TODO there should be a max nav cost at a convenient location in the source code
30  double const MAX_NAV_COST = 40*1000*1000.0; // 40 000 km should suffice for even the wildest real world maps, TODO: unify with Borderbased code
31 
32  public:
36  int evaluateToBest(const PlanningResultMap & planning_results) override
37  {
38  const std::string target_field = "MinimumNavigationCostOnLane";
39  int best_id = -1; // TODO negative value could be implicit error code
40  double best_cost = MAX_NAV_COST;
41  for (auto [id, plan] : planning_results)
42  {
43  try
44  {
45  double plan_cost = plan.objective_values[target_field];
46  if (plan_cost < best_cost)
47  {
48  best_id = id;
49  best_cost = plan_cost;
50  }
51  }
52  catch(const std::exception& e)
53  {
54  std::cerr << e.what() << "PlanningResult without value for "<<target_field<<" \n";
55  }
56 
57  }
58 
59  return best_id;
60  }
61 
63  {
64  }
65  };
66 
67  } // namespace fun
68 } // namespace adore
Definition: atrajectory_evaluator.h:32
Definition: evaluator_nav_cost.h:27
int evaluateToBest(const PlanningResultMap &planning_results) override
Definition: evaluator_nav_cost.h:36
EvaluatorNavCost()
Definition: evaluator_nav_cost.h:62
double const MAX_NAV_COST
Definition: evaluator_nav_cost.h:30
std::unordered_map< int, adore::fun::PlanningResult > PlanningResultMap
Definition: atrajectory_evaluator.h:29
Definition: areaofeffectconverter.h:20