ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
plot_plan_swath.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 implementation
13  ********************************************************************************/
14 
15 #pragma once
17 #include <adore/fun/afactory.h>
18 #include <plotlablib/afigurestub.h>
19 #include <plotlablib/plcommands.h>
20 #include <string>
21 #include <unordered_map>
22 
23 
24 namespace adore
25 {
26  namespace apps
27  {
33  {
34  private:
36  std::string prefix_;
38  std::unordered_map<std::string,int> tag_to_iteration_;
44 
45 
46  public:
47 
48  PlotPlanSwath(DLR_TS::PlotLab::AFigureStub* figure,std::string prefix)
49  {
50  figure_ = figure;
51  prefix_ = prefix;
52  max_iteration_ = 0;
53  plot_combined_ = true;
54  plot_nominal_ = true;
55  cb_config_.r_.start_ = 1.0;
56  cb_config_.r_.end_ = 0.0;
57  cb_config_.g_.start_ = 0.0;
58  cb_config_.g_.end_ = 1.0;
59  cb_config_.b_.start_ = 0.0;
60  cb_config_.b_.end_ = 0.0;
61  nom_config_.r_.start_ = 1.0;
62  nom_config_.r_.end_ = 0.0;
63  nom_config_.g_.start_ = 0.0;
64  nom_config_.g_.end_ = 0.0;
65  nom_config_.b_.start_ = 1.0;
66  nom_config_.b_.end_ = 1.0;
67 
68 
70  }
71 
72 
73  void run()
74  {
75  std::unordered_set<std::string> plot_tags;
76 
78  {
83  && result.combined_maneuver_swath.getLevel(0).size()>0)
84  {
85  std::stringstream tag;
86  tag << prefix_ << "/PlanningResult/cb/"<<result.id<<"/";
87  std::string tagstr = tag.str();
88  double t0 = result.combined_maneuver_swath.getLevel(0).begin()->second.t0_;
89  double t1 = result.combined_maneuver_swath.getLevel(0).rbegin()->second.t1_;
91  tag_to_iteration_[tagstr] = result.iteration;
92  }
94  && result.nominal_maneuver_swath.getLevel(0).size()>0)
95  {
96  std::stringstream tag;
97  tag << prefix_ << "/PlanningResult/nom/"<<result.id<<"/";
98  std::string tagstr = tag.str();
99  double t0 = result.nominal_maneuver_swath.getLevel(0).begin()->second.t0_;
100  double t1 = result.nominal_maneuver_swath.getLevel(0).rbegin()->second.t1_;
101  PLOT::plotCylinderTree(result.nominal_maneuver_swath,t0,t1,nom_config_,tagstr,figure_,plot_tags);
102  tag_to_iteration_[tagstr] = result.iteration;
103  }
104  }
105  for(auto& it:tag_to_iteration_)
106  {
107  if(it.second<max_iteration_-1)
108  {
109  figure_->erase_similar(it.first);
111  }
112  }
113  }
114  };
115  }
116 }
Definition: afigurestub.h:24
virtual void erase_similar(std::string hashtag)=0
a plot module for plotting the planning result swaths
Definition: plot_plan_swath.h:33
bool plot_nominal_
Definition: plot_plan_swath.h:41
void run()
Definition: plot_plan_swath.h:73
adore::mad::AFeed< adore::fun::PlanningResult > * planning_result_feed_
Definition: plot_plan_swath.h:37
int max_iteration_
Definition: plot_plan_swath.h:39
PLOT::PredictionConfig::prediction_config nom_config_
Definition: plot_plan_swath.h:43
std::string prefix_
Definition: plot_plan_swath.h:36
PLOT::PredictionConfig::prediction_config cb_config_
Definition: plot_plan_swath.h:42
std::unordered_map< std::string, int > tag_to_iteration_
Definition: plot_plan_swath.h:38
DLR_TS::PlotLab::AFigureStub * figure_
Definition: plot_plan_swath.h:35
PlotPlanSwath(DLR_TS::PlotLab::AFigureStub *figure, std::string prefix)
Definition: plot_plan_swath.h:48
bool plot_combined_
Definition: plot_plan_swath.h:40
static adore::fun::AFactory * get()
Definition: afactory.h:170
virtual void getNext(T &value)=0
virtual bool hasNext() const =0
VolumeVector & getLevel(int i)
Definition: vectorbasedvolumetree.h:60
void plotCylinderTree(adore::mad::OccupancyCylinderTree tree, double t, double t_max, PLOT::PredictionConfig::prediction_config config, std::string prefix, DLR_TS::PlotLab::AFigureStub *figure, std::unordered_set< std::string > &plot_tags)
Definition: plot_prediction.h:29
adoreMatrix< T, N, M > max(adoreMatrix< T, N, M > a, const adoreMatrix< T, N, M > &b)
Definition: adoremath.h:686
Definition: areaofeffectconverter.h:20
double start_
Definition: prediction_config.h:30
double end_
Definition: prediction_config.h:31
Definition: prediction_config.h:27
color_range b_
Definition: prediction_config.h:46
color_range g_
Definition: prediction_config.h:46
color_range r_
Definition: prediction_config.h:46
Definition: planning_result.h:29
bool combined_maneuver_valid
Definition: planning_result.h:64
int id
Definition: planning_result.h:30
adore::mad::OccupancyCylinderTree combined_maneuver_swath
Definition: planning_result.h:40
int iteration
Definition: planning_result.h:31
adore::mad::OccupancyCylinderTree nominal_maneuver_swath
Definition: planning_result.h:38