ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
p_traffic_light_sim.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  * Stephan Lapoehn - initial API and implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
17 #include <ros/ros.h>
19 
20 namespace adore
21 {
22  namespace if_ROS
23  {
24  namespace params
25  {
27  {
28  private:
29  ros::NodeHandle n_;
30  std::string prefix_;
31 
32  template <class T>
33  T get(const std::string & name)const
34  {
35  if (!n_.hasParam(name))
36  {
37  ROS_INFO_STREAM("No parameter named " << name);
38  }
39  T result;
40  n_.getParamCached(name,result);
41  return result;
42  }
43 
44  public:
45 
46  PTrafficLightSim(ros::NodeHandle n,std::string prefix) :n_(n),prefix_(prefix)
47  {
48  prefix_ = prefix + "traffic_light_sim/";
49  }
50  //visibility radius of the map provider
51  virtual int getRedDuration()const override
52  {
53  static const std::string name = prefix_ + "r";
54  return get<int>(name);
55  }
56  virtual int getGreenDuration()const override
57  {
58  static const std::string name = prefix_ + "g";
59  return get<int>(name);
60  }
61  virtual int getRedYellowDuration()const override
62  {
63  static const std::string name = prefix_ + "ry";
64  return get<int>(name);
65  }
66  virtual int getYellowDuration()const override
67  {
68  static const std::string name = prefix_ + "y";
69  return get<int>(name);
70  }
71  virtual std::string getStartState()const override
72  {
73  static const std::string name = prefix_ + "start_state";
74  return get<std::string>(name);
75  }
76  virtual bool getIsProbeMode()const override
77  {
78  static const std::string name = prefix_ + "probe";
79  return get<bool>(name);
80  }
81  };
82  }
83  }
84 }
Definition: p_traffic_light_sim.h:27
T get(const std::string &name) const
Definition: p_traffic_light_sim.h:33
virtual int getGreenDuration() const override
Definition: p_traffic_light_sim.h:56
virtual int getYellowDuration() const override
Definition: p_traffic_light_sim.h:66
ros::NodeHandle n_
Definition: p_traffic_light_sim.h:29
virtual std::string getStartState() const override
Definition: p_traffic_light_sim.h:71
virtual int getRedDuration() const override
Definition: p_traffic_light_sim.h:51
virtual int getRedYellowDuration() const override
Definition: p_traffic_light_sim.h:61
PTrafficLightSim(ros::NodeHandle n, std::string prefix)
Definition: p_traffic_light_sim.h:46
virtual bool getIsProbeMode() const override
Definition: p_traffic_light_sim.h:76
std::string prefix_
Definition: p_traffic_light_sim.h:30
abstract class containing parameters to configure aspects of the map provider
Definition: ap_traffic_light_sim.h:27
Definition: areaofeffectconverter.h:20