18 #include <unordered_set>
109 const double ds = 2.0 * std::sqrt(
r*
r-b*b);
114 const double k = (int)std::ceil(l/ds);
123 const double s1 = front_end_s_tva.
limitHi() + 0.5*ds;
128 int predictionID =
set.size();
131 center.
getData()(1,0) = pos0(0)-l*0.5*dx;
132 center.
getData()(2,0) = pos0(1)-l*0.5*dy;
133 center.
getData()(3,0) = pos0(2);
135 center.
getData()(1,1) = pos0(0)+l*0.5*dx;
136 center.
getData()(2,1) = pos0(1)+l*0.5*dy;
137 center.
getData()(3,1) = pos0(2);
145 for(
double s = ds*0.5;s<=l-ds*0.5;s+=ds)
147 auto pos = center.
f(s);
156 if(!std::isnan(
r)&&!std::isnan(pos(0))&&!std::isnan(pos(1))&&!std::isnan(t0)&&!std::isnan(t1))
161 set.push_back(prediction);
166 std::unordered_set<adore::env::BorderBased::BorderID,adore::env::BorderBased::BorderIDHasher> closed;
167 std::vector<SearchState> open;
170 itpair.first!=itpair.second;
173 auto it = itpair.first;
174 auto test_participantID = it->first;
175 auto borderID = it->second.first;
176 auto positioning = it->second.second;
177 if(test_participantID==p.
getTrackingID() && positioning.anyInside())
182 double min_tangential_distance, min_normal_distance;
184 if(min_tangential_distance<0.0 || 1.0<min_tangential_distance)
continue;
189 x.s0_participant_ = 0.0;
190 x.predecessorID_ = -1;
191 x.borderID_ = borderID;
199 const double lah = 1.0;
202 const auto p1 = center.
f_bounded(
x.s0_border_+lah);
203 const auto p = center.
f_bounded(
x.s0_border_);
204 double pdx = p1(0)-
p0(0);
205 double pdy = p1(1)-
p0(1);
206 const double lpdxy = std::sqrt(pdx*pdx+pdy*pdy);
209 if(lpdxy<0.01)
continue;
212 const double rpx = (pos0(0)-p(0))*pdx + (pos0(1)-p(1))*pdy;
213 const double rpy = -(pos0(0)-p(0))*pdy + (pos0(1)-p(1))*pdx;
214 const double rpdx = dx*pdx + dy*pdy;
215 const double rpdy = -dx*pdy + dy*pdx;
217 double lateral_width = std::abs(rpdy*l*0.5+rpdx*b);
222 std::cout<<
"pos0=["<<pos0(0)-p(0)<<
","<<pos0(1)-p(1)<<
"]"<<std::endl;
223 std::cout<<
"p0=["<<
p0(0)-p(0)<<
","<<
p0(1)-p(1)<<
"], p1=["<<p1(0)-p(0)<<
","<<p1(1)-p(1)<<
"]"<<std::endl;
224 std::cout<<
"rp=["<<rpx<<
","<<rpy<<
"], rpd=["<<rpdx<<
","<<rpdy<<
"], dxy=["<<dx<<
","<<dy<<
"], v="<<v<<std::endl;
225 std::cout<<
"n0=["<<
x.n0_lb_<<
","<<
x.n0_ub_<<
"], dn0=["<<
x.dn0_lb_<<
","<<
x.dn0_ub_<<
"]"<<std::endl;
226 std::cout<<
"---"<<std::endl;
231 int branch_count = 0;
235 int predictionID =
set.size();
238 if(closed.find(
x.borderID_)!=closed.end())
continue;
239 closed.insert(
x.borderID_);
251 const double sx0 =
x.s0_participant_;
252 const double dsmax = center.
limitHi()-
x.s0_border_;
253 const double sx1 =
std::min(s1,sx0+dsmax);
254 const double s_max_border = center.
limitHi();
255 if(center.
getData().nc()>=2)
for(
double s = sx0;s<=sx1;s+=ds)
263 const double si = s+
x.s0_border_-
x.s0_participant_;
264 const auto pos0 = center.
f(si);
265 double dxi = center.
dfidx(si,0);
266 double dyi = center.
dfidx(si,1);
267 double scaledxyi = 1.0/std::sqrt(dxi*dxi+dyi*dyi);
268 dxi = dxi * scaledxyi;
269 dyi = dyi * scaledxyi;
270 const double widthi = pos0(3);
273 double c_final = 0.0;
278 double n_ub =
adore::mad::bound(-0.5*widthi,
x.n0_ub_ + 0.5*alatmax*dt*dt +
x.dn0_ub_*dt,0.5*widthi);
279 double n_lb =
adore::mad::bound(-0.5*widthi,
x.n0_lb_ - 0.5*alatmax*dt*dt +
x.dn0_lb_*dt,0.5*widthi);
280 std::cout<<
"n("<<dt<<
")=["<<n_lb<<
","<<n_ub<<
"], di=["<<dxi<<
","<<dyi<<
"]"<<std::endl;
281 c_final = (n_ub+n_lb)*0.5;
282 r_final = std::abs(n_ub-n_lb)*0.5;
284 if(!std::isnan(r_final)&&!std::isnan(pos0(0))&&!std::isnan(pos0(1))&&!std::isnan(t0)&&!std::isnan(t1))
287 pos0(0) - dyi * c_final,
288 pos0(1) + dxi * c_final,
293 set.push_back(prediction);
303 auto nextBorder = it.current()->second;
304 if(border->isContinuousPredecessorOf(nextBorder))
315 open.push_back(xnext);
324 return branch_count>0;
adore::mad::LLinearPiecewiseFunctionM< double, 4 > getCenterline(const BorderID &id)
get the linear piecewise description of the centerline:
Definition: borderset.h:647
itCoordinate2Border getSuccessors(Border *b)
get an interator pair for all borders which follow after b
Definition: borderset.h:996
Border * getBorder(const BorderID &id) const
retrieve a border by ID
Definition: borderset.h:628
Definition: occupancycylinderprediction.h:47
Definition: ocroadbasedprediction.h:46
void setAngleErrorMax(double value)
Definition: ocroadbasedprediction.h:78
double time_headway_
Definition: ocroadbasedprediction.h:56
void setVMax(double value)
Definition: ocroadbasedprediction.h:83
void setAMax(double value)
Definition: ocroadbasedprediction.h:84
double lat_error_
Definition: ocroadbasedprediction.h:50
double t_max_utc_
Definition: ocroadbasedprediction.h:48
double v_max_
Definition: ocroadbasedprediction.h:52
void setWidthLB(double value)
Definition: ocroadbasedprediction.h:92
double delay_
Definition: ocroadbasedprediction.h:58
void setAMin(double value)
Definition: ocroadbasedprediction.h:85
void setTimeHeadway(double value)
Definition: ocroadbasedprediction.h:86
OCRoadBasedPrediction(adore::env::traffic::TrafficMap *trafficMap)
Definition: ocroadbasedprediction.h:93
double a_min_
Definition: ocroadbasedprediction.h:54
void setLonError(double value)
Definition: ocroadbasedprediction.h:82
double lat_precision_
Definition: ocroadbasedprediction.h:49
void setLatError(double value)
Definition: ocroadbasedprediction.h:81
void setWidthUB(double value)
Definition: ocroadbasedprediction.h:91
void setLateralPredictions(bool value)
Definition: ocroadbasedprediction.h:90
void setDelay(double value)
Definition: ocroadbasedprediction.h:88
double angle_error_max_
Definition: ocroadbasedprediction.h:55
void setTimeLeeway(double value)
Definition: ocroadbasedprediction.h:87
double a_max_
Definition: ocroadbasedprediction.h:53
double width_lb_
Definition: ocroadbasedprediction.h:62
void setTMaxUTC(double value)
Definition: ocroadbasedprediction.h:79
double time_leeway_
Definition: ocroadbasedprediction.h:57
double lon_error_
Definition: ocroadbasedprediction.h:51
bool lateral_predictions_
Definition: ocroadbasedprediction.h:60
double width_ub_
Definition: ocroadbasedprediction.h:61
void setLatPrecision(double value)
Definition: ocroadbasedprediction.h:80
void setLaneWidthPredictions(bool value)
Definition: ocroadbasedprediction.h:89
adore::env::traffic::TrafficMap * trafficMap_
Definition: ocroadbasedprediction.h:63
virtual bool predict(const traffic::Participant &p, OccupancyCylinderPredictionSet &set) const override
Definition: ocroadbasedprediction.h:104
bool lane_width_predictions_
Definition: ocroadbasedprediction.h:59
Definition: velocityprediction.h:22
void predict_s_tva(double s0, double v0, double a0, double delay, double a1, double vbound, double t0, double dt, double t1, adore::mad::LLinearPiecewiseFunctionM< double, 3 > &result)
Definition: velocityprediction.h:24
Definition: trafficmap.h:36
adore::env::BorderBased::BorderSet * getBorderSet()
Get the border set.
Definition: trafficmap.h:63
const TParticipantToBorder & getParticipantToBorder() const
Get the participant to border map.
Definition: trafficmap.h:81
CT f_bounded(DT x)
Definition: alfunction.h:117
double getPositionOfPoint(T px, T py, int d1, int d2, T &d_tangential_min, T &d_normal_min)
Definition: llinearpiecewisefunction.h:955
virtual CT f(DT x) const override
Definition: llinearpiecewisefunction.h:251
virtual DT limitLo() const override
Definition: llinearpiecewisefunction.h:264
virtual T dfidx(DT x, int row)
Definition: llinearpiecewisefunction.h:400
adoreMatrix< T, n+1, 0 > & getData()
Definition: llinearpiecewisefunction.h:147
virtual DT limitHi() const override
Definition: llinearpiecewisefunction.h:259
void insert(const VolumeType &volume)
Definition: vectorbasedvolumetree.h:90
std::vector< OccupancyCylinderPrediction > OccupancyCylinderPredictionSet
Definition: occupancycylinderprediction.h:40
interval< T > atan2(interval< T > y, interval< T > x)
Definition: intervalarithmetic.h:234
interval< T > cos(interval< T > x)
Definition: intervalarithmetic.h:225
T bound(T lb, T value, T ub)
Definition: adoremath.h:569
T min(T a, T b, T c, T d)
Definition: adoremath.h:663
void set(T *data, T value, int size)
Definition: adoremath.h:39
interval< T > sin(interval< T > x)
Definition: intervalarithmetic.h:204
adoreMatrix< T, N, M > max(adoreMatrix< T, N, M > a, const adoreMatrix< T, N, M > &b)
Definition: adoremath.h:686
x
Definition: adore_set_goal.py:30
p0
Definition: adore_set_pose.py:32
r
Definition: adore_suppress_lanechanges.py:209
Definition: areaofeffectconverter.h:20
This struct identifies a Border by the coordinates of the starting and the end point.
Definition: borderid.h:31
T1 & current()
Definition: borderset.h:50
Definition: ocroadbasedprediction.h:65
double s0_border_
Definition: ocroadbasedprediction.h:67
int predecessorID_
Definition: ocroadbasedprediction.h:70
double n0_ub_
Definition: ocroadbasedprediction.h:72
double s0_participant_
Definition: ocroadbasedprediction.h:68
double n0_lb_
Definition: ocroadbasedprediction.h:71
double dn0_ub_
Definition: ocroadbasedprediction.h:74
double dn0_lb_
Definition: ocroadbasedprediction.h:73
adore::env::BorderBased::BorderID borderID_
Definition: ocroadbasedprediction.h:69
Definition: occupancycylinderprediction.h:27
int branchID_
Definition: occupancycylinderprediction.h:31
int trackingID_
Definition: occupancycylinderprediction.h:30
int v2xStationID_
Definition: occupancycylinderprediction.h:29
adore::mad::OccupancyCylinderTree occupancy_
Definition: occupancycylinderprediction.h:33
float confidence_
Definition: occupancycylinderprediction.h:34
int predecessorID_
Definition: occupancycylinderprediction.h:32
Struct for representing a participant in traffic.
Definition: participant.h:30
double getLength() const
Definition: participant.h:155
TTrackingID getTrackingID() const
Definition: participant.h:109
adoreMatrix< double, 3, 1 > center_
Definition: participant.h:98
double getObservationTime() const
Definition: participant.h:112
const adoreMatrix< double, 3, 1 > & getCenter() const
Definition: participant.h:124
double getYaw() const
Definition: participant.h:154
TV2XStationID getStationID() const
Definition: participant.h:110
double getWidth() const
Definition: participant.h:156
double getVy() const
Definition: participant.h:158
double getVx() const
Definition: participant.h:157
Definition: occupancycylinder.h:25