ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
plot_views.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  * Matthias Nichting - initial implementation
13  ********************************************************************************/
14 
15 #pragma once
16 #include <adore/view/alane.h>
19 #include <adore/mad/adoremath.h>
20 #include "viewplotter_config.h"
21 
22 namespace adore
23 {
24  namespace PLOT
25  {
26  inline void plotALane(adore::view::ALane* alane, std::string tag, adore::PLOT::ViewPlotterConfig config, DLR_TS::PlotLab::AFigureStub* figure, std::string viewtype)
27  {
28  // plot lane geometry
29  int n = config.number_of_samples_per_boundary;
30  double z;
31  bool lf = (viewtype == "lf" ? true : false);
32  double X[n * 2 + 1];
33  double Y[n * 2 + 1];
34  double s0 = alane->getSMin();
35  double s1 = alane->getSMax();
36  std::vector<double> offset_left;
37  std::vector<double> offset_right;
38  for (int i = 0; i < n; i++)
39  {
40  double s = s0 + (s1 - s0) / (double)(n - 1) * (double)i;
41  double offset_left = alane->getOffsetOfLeftBorder(s);
42  offset_left = adore::mad::signum(offset_left) * (std::max(0.0, std::abs(offset_left) - 0.5 * (lf ? config.lf_geometry_narrowing : config.lc_geometry_narrowing)));
43  double offset_right = alane->getOffsetOfRightBorder(s);
44  offset_right = adore::mad::signum(offset_right) * (std::max(0.0, std::abs(offset_right) - 0.5 * (lf ? config.lf_geometry_narrowing : config.lc_geometry_narrowing)));
45 
46  alane->toEucledianCoordinates(s, offset_left, X[n * 2 - 1 - i], Y[n * 2 - 1 - i], z);
47  alane->toEucledianCoordinates(s, offset_right, X[i], Y[i], z);
48  }
49  X[n * 2] = X[0];
50  Y[n * 2] = Y[0];
51 
52  figure->plot(tag, X, Y, 0.9, n * 2 + 1, lf ? config.lf_geometry_plotoptions : config.lc_geometry_plotoptions);
53 
54 
55 
56  //plot baseline
57  // if(lf)
58  {
59  for (int i = 0; i < n; i++)
60  {
61  double s = s0 + (s1 - s0) / (double)(n - 1) * (double)i;
62  alane->toEucledianCoordinates(s, 0.0, X[i], Y[i], z);
63  }
64  figure->plot(tag+"/bl", X, Y, 0.9, n, "LineStyle=none;MarkerSize=7;LineColor=1,0,0");
65  }
66  }
67 
69  {
70  // plot target lane
71  adore::PLOT::plotALane(alanechangeview->getTargetLane(), tag, config, figure, "lc");
72  // plot open gate
73  double smin_gate = alanechangeview->getProgressOfGateOpen();
74  double smax_gate = alanechangeview->getProgressOfGateClosed();
75  // todo plot gate NiM
76  double X[4];
77  double Y[4];
78  double Z[4];
79  auto target = alanechangeview->getTargetLane();
80  // target->toEucledianCoordinates(smin_gate,target->getOffsetOfLeftBorder(smin_gate),X[0],Y[0],Z[0]);
81  // target->toEucledianCoordinates(smin_gate,target->getOffsetOfRightBorder(smin_gate),X[1],Y[1],Z[1]);
82  // target->toEucledianCoordinates(smax_gate,target->getOffsetOfLeftBorder(smax_gate),X[2],Y[2],Z[2]);
83  // target->toEucledianCoordinates(smax_gate,target->getOffsetOfRightBorder(smax_gate),X[3],Y[3],Z[3]);
84  target->toEucledianCoordinates(smin_gate,alanechangeview->getOffsetOfStartOuterBorder(smin_gate),X[0],Y[0],Z[0]);
85  target->toEucledianCoordinates(smin_gate,alanechangeview->getOffsetOfDestinationOuterBorder(smin_gate),X[1],Y[1],Z[1]);
86  target->toEucledianCoordinates(smax_gate,alanechangeview->getOffsetOfStartOuterBorder(smax_gate),X[2],Y[2],Z[2]);
87  target->toEucledianCoordinates(smax_gate,alanechangeview->getOffsetOfDestinationOuterBorder(smax_gate),X[3],Y[3],Z[3]);
88  figure->plot(tag+"gate_start",&X[0],&Y[0],1.0,2,"LindWidth=3;LineColor=0,0,0");
89  figure->plot(tag+"gate_end",&X[2],&Y[2],1.0,2,"LindWidth=3;LineColor=0,0,0");
90 
91  // todo colorize areas with sufficient width
92 
93 
94  }
95  } // namespace PLOT
96 } // namespace adore
Definition: afigurestub.h:24
virtual void plot(std::string hashtag, double *X, double *Y, double *Z, int size, std::string options)=0
Definition: viewplotter_config.h:23
double lf_geometry_narrowing
Definition: viewplotter_config.h:30
std::string lf_geometry_plotoptions
Definition: viewplotter_config.h:25
int number_of_samples_per_boundary
Definition: viewplotter_config.h:31
double lc_geometry_narrowing
Definition: viewplotter_config.h:29
std::string lc_geometry_plotoptions
Definition: viewplotter_config.h:26
Definition: alanechangeview.h:27
virtual double getProgressOfGateOpen() const =0
virtual double getOffsetOfDestinationOuterBorder(double s)=0
virtual ALane * getTargetLane()=0
virtual double getProgressOfGateClosed() const =0
virtual double getOffsetOfStartOuterBorder(double s)=0
Definition: alane.h:28
virtual double getSMin() const =0
virtual double getOffsetOfRightBorder(double s)=0
virtual double getSMax() const =0
virtual void toEucledianCoordinates(double s, double n, double &xe, double &ye, double &ze)=0
virtual double getOffsetOfLeftBorder(double s)=0
void plotALane(adore::view::ALane *alane, std::string tag, adore::PLOT::ViewPlotterConfig config, DLR_TS::PlotLab::AFigureStub *figure, std::string viewtype)
Definition: plot_views.h:26
void plotALaneChangeView(adore::view::ALaneChangeView *alanechangeview, std::string tag, adore::PLOT::ViewPlotterConfig config, DLR_TS::PlotLab::AFigureStub *figure)
Definition: plot_views.h:68
int signum(T val)
Definition: adoremath.h:723
adoreMatrix< T, N, M > max(adoreMatrix< T, N, M > a, const adoreMatrix< T, N, M > &b)
Definition: adoremath.h:686
z
Definition: adore_set_goal.py:32
Definition: areaofeffectconverter.h:20