55 return road->UpperBound(s) - s;
60 const auto width_info = GetInfo<element::RoadInfoLaneWidth>(s);
61 if(width_info !=
nullptr){
62 return width_info->GetPolynomial().Evaluate(s);
72 auto geometry_type = geometry->GetGeometry().GetType();
78 geometry->GetDistance() + geometry->GetGeometry().GetLength()) {
81 auto lane_offsets = GetInfos<element::RoadInfoLaneOffset>();
82 for (
auto *lane_offset : lane_offsets) {
83 if (std::abs(lane_offset->GetPolynomial().GetC()) > 0 ||
84 std::abs(lane_offset->GetPolynomial().GetD()) > 0) {
90 if (std::abs(
elevation->GetPolynomial().GetC()) > 0 ||
91 std::abs(
elevation->GetPolynomial().GetD()) > 0) {
100 template <
typename T>
109 const bool negative_lane_id = lane_id < 0;
111 double tangent = 0.0;
112 for (
const auto &lane : container) {
113 auto info = lane.second.template GetInfo<element::RoadInfoLaneWidth>(s);
115 const auto current_polynomial = info->GetPolynomial();
116 auto current_dist = current_polynomial.Evaluate(s);
117 auto current_tang = current_polynomial.Tangent(s);
118 if (lane.first != lane_id) {
119 dist += negative_lane_id ? current_dist : -current_dist;
120 tangent += negative_lane_id ? current_tang : -current_tang;
123 dist += negative_lane_id ? current_dist : -current_dist;
124 tangent += (negative_lane_id ? current_tang : -current_tang) * 0.5;
128 return std::make_pair(dist, tangent);
141 const std::map<LaneId, Lane> &lanes = lane_section->GetLanes();
151 float lane_t_offset = 0.0f;
152 float lane_tangent = 0.0f;
156 const auto side_lanes = MakeListView(
157 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
158 const auto computed_width =
160 lane_t_offset =
static_cast<float>(computed_width.first);
161 lane_tangent =
static_cast<float>(computed_width.second);
162 }
else if (
GetId() > 0) {
164 const auto side_lanes = MakeListView(lanes.lower_bound(1), lanes.end());
165 const auto computed_width =
167 lane_t_offset =
static_cast<float>(computed_width.first);
168 lane_tangent =
static_cast<float>(computed_width.second);
173 const auto lane_offset_tangent =
174 static_cast<float>(lane_offset_info->GetPolynomial().Tangent(s));
177 lane_tangent -= lane_offset_tangent;
190 const double shape_t0 = (shape_lane_offset !=
nullptr)
193 road->GetLateralShapeZ(s, shape_t0 - lane_t_offset));
217 const double parameter_s,
const float extra_width)
const {
223 const std::map<LaneId, Lane> &lanes = lane_section->GetLanes();
231 float lane_t_offset = 0.0f;
235 const auto side_lanes = MakeListView(
236 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
237 const auto computed_width =
239 lane_t_offset =
static_cast<float>(computed_width.first);
240 }
else if (
GetId() > 0) {
242 const auto side_lanes = MakeListView(lanes.lower_bound(1), lanes.end());
243 const auto computed_width =
245 lane_t_offset =
static_cast<float>(computed_width.first);
248 float lane_width =
static_cast<float>(
GetWidth(s)) / 2.0f;
250 lane_width += extra_width;
255 dp_r = dp_l =
road->GetDirectedPointIn(s);
267 const double corner_t0 = (corner_lane_offset !=
nullptr)
270 road->GetLateralShapeZ(s, corner_t0 - (lane_t_offset + lane_width)));
272 road->GetLateralShapeZ(s, corner_t0 - (lane_t_offset - lane_width)));
296 }
else if (!
road->IsRHT() &&
GetId() >= 0){
#define DEBUG_ASSERT(predicate)
#define RELEASE_ASSERT(pred)
std::map< std::string, unsigned int > road
value_type Evaluate(const value_type &x) const
Evaluates f(x) = a + bx + cx^2 + dx^3.
static constexpr T ToDegrees(T rad)
static constexpr T Clamp(T a, T min=T(0), T max=T(1))
Euler angles of a rotation in CARLA's / Unreal's left-handed frame: x forward, y right,...
double GetDistance() const
bool IsStraight() const
Checks whether the geometry is straight or not.
double GetWidth(const double s) const
Returns the total lane width given a s.
geom::Transform ComputeTransform(const double s) const
const LaneSection * GetLaneSection() const
LaneType
Can be used as flags.
LaneSection * _lane_section
double GetDistance() const
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
Computes the location of the edges given a s.
bool IsPositiveDirection() const
The lane offset record defines a lateral shift of the lane reference line(which is usually identical ...
const geom::CubicPolynomial & GetPolynomial() const
static std::pair< double, double > ComputeTotalLaneWidth(const T container, const double s, const LaneId lane_id)
Returns a pair containing first = width, second = tangent, for an specific Lane given an s and a iter...
This file contains definitions of common data structures used in traffic manager.
void ApplyLateralOffset(float lateral_offset)