Adding and modifying structs for lane and road parsing

This commit is contained in:
Aidan Clear 2019-03-13 16:06:57 +01:00 committed by nsubiron
parent 575e3886cf
commit bad72db260
5 changed files with 124 additions and 99 deletions

View File

@ -0,0 +1,82 @@
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once
#include "carla/road/element/RoadInfo.h"
namespace carla {
namespace road {
namespace element {
class RoadElevationInfo : public RoadInfo {
public:
void AcceptVisitor(RoadInfoVisitor &v) final {
v.Visit(*this);
}
RoadElevationInfo(
double d,
double start_position,
double elevation, // a
double slope, // b
double vertical_curvature,
double curvature_change)
: RoadInfo(d),
_start_position(start_position),
_elevation(elevation),
_slope(slope),
_vertical_curvature(vertical_curvature),
_curvature_change(curvature_change) {}
double Evaluate(const double dist, double *out_tan) const {
const double t = dist - _start_position;
const double pos = _elevation +
_slope * t +
_vertical_curvature * t * t +
_curvature_change * t * t * t;
if (out_tan) {
*out_tan = _slope + t *
(2 * _vertical_curvature + t * 3 * _curvature_change);
}
return pos;
}
double GetStartPosition() const {
return _start_position;
}
double GetElevation() const {
return _elevation;
}
double GetSlope() const {
return _slope;
}
double GetVerticalCurvature() const {
return _vertical_curvature;
}
double GetCurvatureChange() const {
return _curvature_change;
}
private:
double _start_position; // (S) start position(s - offset)[meters]
double _elevation; // (A) elevation [meters]
double _slope; // (B)
double _vertical_curvature; // (C)
double _curvature_change; // (D)
};
} // namespace element
} // namespace road
} // namespace carla

View File

@ -51,6 +51,7 @@ namespace element {
void SetJunctionId(int junctionId) {
_junction_id = junctionId;
}
int GetJunctionId() const {
return _junction_id;
}
@ -71,84 +72,7 @@ namespace element {
}
};
class RoadElevationInfo : public RoadInfo {
public:
void AcceptVisitor(RoadInfoVisitor &v) final {
v.Visit(*this);
}
RoadElevationInfo(double d,
double start_position,
double elevation,
double slope,
double vertical_curvature,
double curvature_change)
: RoadInfo(d),
_start_position(start_position),
_elevation(elevation),
_slope(slope),
_vertical_curvature(vertical_curvature),
_curvature_change(curvature_change) {}
double Evaluate(const double dist, double *out_tan) const {
const double t = dist - _start_position;
const double pos = _elevation +
_slope * t +
_vertical_curvature * t * t +
_curvature_change * t * t * t;
if (out_tan) {
*out_tan = _slope + t *
(2 * _vertical_curvature + t * 3 * _curvature_change);
}
return pos;
}
double GetStartPosition() const {
return _start_position;
}
double GetElevation() const {
return _elevation;
}
double GetSlope() const {
return _slope;
}
double GetVerticalCurvature() const {
return _vertical_curvature;
}
double GetCurvatureChange() const {
return _curvature_change;
}
private:
double _start_position; // (S) start position(s - offset)[meters]
double _elevation; // (A) elevation [meters]
double _slope; // (B)
double _vertical_curvature; // (C)
double _curvature_change; // (D)
};
class RoadInfoVelocity : public RoadInfo {
public:
void AcceptVisitor(RoadInfoVisitor &v) override final {
v.Visit(*this);
}
RoadInfoVelocity(double vel) : velocity(vel) {}
RoadInfoVelocity(double d, double vel)
: RoadInfo(d),
velocity(vel) {}
double velocity = 0;
};
class LaneInfo {
public:

View File

@ -33,23 +33,14 @@ namespace element {
double c,
double d)
: RoadInfo(s),
_lane_id(lane_id),
_width(a, b, c, d, s) {}
int GetLaneId() const {
return _lane_id;
}
const geom::CubicPolynomial &GetPolynomial() const {
return _width;
}
private:
using signed_id = int;
signed_id _lane_id = 0;
geom::CubicPolynomial _width;
};

View File

@ -34,9 +34,8 @@ namespace element {
Both = 0x03 //11
};
RoadInfoMarkRecord(double d, int lane_id)
RoadInfoMarkRecord(double d)
: RoadInfo(d),
_lane_id(lane_id),
_type(""),
_weight(""),
_color("white"),
@ -47,7 +46,6 @@ namespace element {
RoadInfoMarkRecord(
double d,
int lane_id,
std::string type,
std::string weight,
std::string color,
@ -56,7 +54,6 @@ namespace element {
LaneChange lane_change,
double height)
: RoadInfo(d),
_lane_id(lane_id),
_type(type),
_weight(weight),
_color(color),
@ -65,10 +62,6 @@ namespace element {
_lane_change(lane_change),
_height(height) {}
int GetLaneId() const {
return _lane_id;
}
const std::string &GetType() const {
return _type;
}
@ -99,10 +92,6 @@ namespace element {
private:
using signed_id = int;
signed_id _lane_id = 0;
std::string _type; // Type of the road mark
std::string _weight; // Weight of the road mark
std::string _color; // Color of the road mark
@ -112,7 +101,7 @@ namespace element {
LaneChange _lane_change; // Allow a lane change in the indicated direction
// taking into account that lanes are numbered in
// ascending order from right to left. If the
// attributeis missing, “both” is assumedto be
// attributeis missing, “both” is assumed to be
// valid.
double _height; // Physical distance of top edge of road mark from
// reference plane of the lane

View File

@ -0,0 +1,39 @@
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once
#include "carla/road/element/RoadInfo.h"
namespace carla {
namespace road {
namespace element {
class RoadInfoVelocity : public RoadInfo {
public:
void AcceptVisitor(RoadInfoVisitor &v) override final {
v.Visit(*this);
}
RoadInfoVelocity(double vel) : velocity(vel) {}
RoadInfoVelocity(double d, double vel)
: RoadInfo(d),
velocity(vel) {}
double GetVelocity() {
return velocity;
}
private:
double velocity;
};
} // namespace element
} // namespace road
} // namespace carla