ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
bordercostmap.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  * Daniel Heß - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
17 #include <unordered_map>
20 
21 namespace adore
22 {
23  namespace env
24  {
25  namespace BorderBased
26  {
30  class BorderCostMap : public std::unordered_map<BorderID, adore::env::NavigationCost, adore::env::BorderBased::BorderIDHasher>
31  {
32  public:
33  typedef std::pair<BorderID, adore::env::NavigationCost> TCostPair;
39  {
40  if(this->size()==0)
41  {
42  return false;
43  }
44  int r = std::floor(((double)(std::rand())/((double)RAND_MAX)) * ((double)this->size()));
45  for(auto it = this->begin();it!=this->end();it++)
46  {
47  if(r==0)
48  {
49  result = *it;
50  return true;
51  }
52  r--;
53  }
54  auto it = this->begin();
55  result = *it;
56  return true;
57  }
58  };
59  }
60  }
61 }
Definition: bordercostmap.h:31
std::pair< BorderID, adore::env::NavigationCost > TCostPair
Definition: bordercostmap.h:33
bool getRandomBorderIDCostPair(TCostPair &result)
Definition: bordercostmap.h:38
r
Definition: adore_suppress_lanechanges.py:209
Definition: areaofeffectconverter.h:20