adding road elevation funcs in map builder and changed double to float
This commit is contained in:
parent
e3987ca546
commit
27f274b9cd
|
@ -14,10 +14,8 @@ namespace carla {
|
|||
namespace opendrive {
|
||||
namespace parser {
|
||||
|
||||
using RoadId = int;
|
||||
|
||||
struct ElevationProfile {
|
||||
RoadId road_id { -1 };
|
||||
carla::road::Road* road { nullptr };
|
||||
float s { 0.0 };
|
||||
float a { 0.0 };
|
||||
float b { 0.0 };
|
||||
|
@ -34,7 +32,7 @@ namespace parser {
|
|||
};
|
||||
|
||||
struct LateralProfile {
|
||||
RoadId road_id { -1 };
|
||||
carla::road::Road* road { nullptr };
|
||||
float s { 0.0 };
|
||||
float a { 0.0 };
|
||||
float b { 0.0 };
|
||||
|
@ -62,7 +60,8 @@ namespace parser {
|
|||
ElevationProfile elev;
|
||||
|
||||
// get road id
|
||||
elev.road_id = node_road.attribute("id").as_int();
|
||||
road::RoadId road_id = node_road.attribute("id").as_int();
|
||||
elev.road = map_builder.GetRoad(road_id);
|
||||
|
||||
// get common properties
|
||||
elev.s = node_elevation.attribute("s").as_float();
|
||||
|
@ -83,7 +82,8 @@ namespace parser {
|
|||
LateralProfile lateral;
|
||||
|
||||
// get road id
|
||||
lateral.road_id = node_road.attribute("id").as_int();
|
||||
road::RoadId road_id = node_road.attribute("id").as_int();
|
||||
lateral.road = map_builder.GetRoad(road_id);
|
||||
|
||||
// get common properties
|
||||
lateral.s = node.attribute("s").as_float();
|
||||
|
@ -108,16 +108,17 @@ namespace parser {
|
|||
|
||||
// map_builder calls
|
||||
for (auto const pro : elevation_profile) {
|
||||
map_builder.AddRoadElevationProfile(pro.road_id, pro.s, pro.a, pro.b, pro.c, pro.d);
|
||||
}
|
||||
for (auto const pro : lateral_profile) {
|
||||
if (pro.type == "superelevation")
|
||||
map_builder.AddRoadLateralSuperelevation(pro.road_id, pro.s, pro.a, pro.b, pro.c, pro.d);
|
||||
else if (pro.type == "crossfall")
|
||||
map_builder.AddRoadLateralCrossfall(pro.road_id, pro.s, pro.a, pro.b, pro.c, pro.d, pro.cross.side);
|
||||
else if (pro.type == "shape")
|
||||
map_builder.AddRoadLateralShape(pro.road_id, pro.s, pro.a, pro.b, pro.c, pro.d, pro.shape.t);
|
||||
map_builder.AddRoadElevationProfile(pro.road, pro.s, pro.a, pro.b, pro.c, pro.d);
|
||||
}
|
||||
/// @todo: RoadInfo classes must be created to fit this information
|
||||
// for (auto const pro : lateral_profile) {
|
||||
// if (pro.type == "superelevation")
|
||||
// map_builder.AddRoadLateralSuperElevation(pro.road, pro.s, pro.a, pro.b, pro.c, pro.d);
|
||||
// else if (pro.type == "crossfall")
|
||||
// map_builder.AddRoadLateralCrossfall(pro.road, pro.s, pro.a, pro.b, pro.c, pro.d, pro.cross.side);
|
||||
// else if (pro.type == "shape")
|
||||
// map_builder.AddRoadLateralShape(pro.road, pro.s, pro.a, pro.b, pro.c, pro.d, pro.shape.t);
|
||||
// }
|
||||
}
|
||||
|
||||
} // namespace parser
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "carla/opendrive/parser/RoadParser.h"
|
||||
#include "carla/opendrive/parser/pugixml/pugixml.hpp"
|
||||
#include "carla/road/MapBuilder.h"
|
||||
#include "carla/road/RoadTypes.h"
|
||||
#include "carla/Logging.h"
|
||||
#include <deque>
|
||||
|
||||
|
@ -14,8 +15,9 @@ namespace carla {
|
|||
namespace opendrive {
|
||||
namespace parser {
|
||||
|
||||
using RoadId = int;
|
||||
using LaneId = int;
|
||||
using RoadId = road::RoadId;
|
||||
using LaneId = road::LaneId;
|
||||
using JuncId = road::JuncId;
|
||||
|
||||
struct Polynomial {
|
||||
float s;
|
||||
|
@ -47,7 +49,7 @@ namespace parser {
|
|||
RoadId id;
|
||||
std::string name;
|
||||
float length;
|
||||
RoadId junction_id;
|
||||
JuncId junction_id;
|
||||
RoadId predecessor;
|
||||
RoadId successor;
|
||||
std::vector<RoadTypeSpeed> speed;
|
||||
|
@ -61,7 +63,7 @@ namespace parser {
|
|||
std::vector<Road> roads;
|
||||
|
||||
for (pugi::xml_node node_road : xml.child("OpenDRIVE").children("road")) {
|
||||
Road road { 0, "", 0.0, -1, -1, -1, {}, {} };
|
||||
Road road { 0, "", 0.0, -1, 0, 0, {}, {} };
|
||||
|
||||
// attributes
|
||||
road.id = node_road.attribute("id").as_int();
|
||||
|
|
|
@ -44,16 +44,35 @@ namespace road {
|
|||
}
|
||||
|
||||
// called from profiles parser
|
||||
void AddRoadElevationProfile(
|
||||
const int32_t /*road_id*/,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d) {
|
||||
auto elevation = std::unique_ptr<RoadInfoElevation>(new RoadInfoElevation(s, a, b, c, d));
|
||||
void MapBuilder::AddRoadElevationProfile(
|
||||
const Road* road,
|
||||
const float s,
|
||||
const float a,
|
||||
const float b,
|
||||
const float c,
|
||||
const float d) {
|
||||
|
||||
auto elevation = std::make_unique<RoadInfoElevation>(s, a, b, c, d);
|
||||
_temp_road_info_container[road].emplace_back(std::move(elevation));
|
||||
}
|
||||
|
||||
// void MapBuilder::AddRoadLateralSuperElevation(
|
||||
// const Road* road,
|
||||
// const float s,
|
||||
// const float a,
|
||||
// const float b,
|
||||
// const float c,
|
||||
// const float d) {}
|
||||
|
||||
// void MapBuilder::AddRoadLateralCrossfall(
|
||||
// const Road* road,
|
||||
// const float s,
|
||||
// const float a,
|
||||
// const float b,
|
||||
// const float c,
|
||||
// const float d,
|
||||
// const std::string side) {}
|
||||
|
||||
// called from lane parser
|
||||
void MapBuilder::CreateLaneAccess(
|
||||
const Lane *lane,
|
||||
|
@ -229,7 +248,7 @@ namespace road {
|
|||
void MapBuilder::AddRoad(
|
||||
const uint32_t road_id,
|
||||
const std::string name,
|
||||
const double length,
|
||||
const float length,
|
||||
const int32_t junction_id,
|
||||
const int32_t predecessor,
|
||||
const int32_t successor) {
|
||||
|
@ -309,11 +328,11 @@ namespace road {
|
|||
|
||||
void MapBuilder::AddRoadGeometryLine(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length) {
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length) {
|
||||
|
||||
auto line_geometry = std::make_unique<GeometryLine>(s,
|
||||
length,
|
||||
|
@ -326,12 +345,12 @@ namespace road {
|
|||
|
||||
void MapBuilder::AddRoadGeometryArc(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length,
|
||||
const double curvature) {
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length,
|
||||
const float curvature) {
|
||||
|
||||
auto arc_geometry = std::make_unique<GeometryArc>(s,
|
||||
length,
|
||||
|
@ -345,41 +364,41 @@ namespace road {
|
|||
|
||||
void MapBuilder::AddRoadGeometrySpiral(
|
||||
carla::road::Road * /*road*/,
|
||||
const double /*s*/,
|
||||
const double /*x*/,
|
||||
const double /*y*/,
|
||||
const double /*hdg*/,
|
||||
const double /*length*/,
|
||||
const double /*curvStart*/,
|
||||
const double /*curvEnd*/) {}
|
||||
const float /*s*/,
|
||||
const float /*x*/,
|
||||
const float /*y*/,
|
||||
const float /*hdg*/,
|
||||
const float /*length*/,
|
||||
const float /*curvStart*/,
|
||||
const float /*curvEnd*/) {}
|
||||
|
||||
void MapBuilder::AddRoadGeometryPoly3(
|
||||
carla::road::Road * /*road*/,
|
||||
const double /*s*/,
|
||||
const double /*x*/,
|
||||
const double /*y*/,
|
||||
const double /*hdg*/,
|
||||
const double /*length*/,
|
||||
const double /*a*/,
|
||||
const double /*b*/,
|
||||
const double /*c*/,
|
||||
const double /*d*/) {}
|
||||
const float /*s*/,
|
||||
const float /*x*/,
|
||||
const float /*y*/,
|
||||
const float /*hdg*/,
|
||||
const float /*length*/,
|
||||
const float /*a*/,
|
||||
const float /*b*/,
|
||||
const float /*c*/,
|
||||
const float /*d*/) {}
|
||||
|
||||
void MapBuilder::AddRoadGeometryParamPoly3(
|
||||
carla::road::Road * /*road*/,
|
||||
const double /*s*/,
|
||||
const double /*x*/,
|
||||
const double /*y*/,
|
||||
const double /*hdg*/,
|
||||
const double /*length*/,
|
||||
const double /*aU*/,
|
||||
const double /*bU*/,
|
||||
const double /*cU*/,
|
||||
const double /*dU*/,
|
||||
const double /*aV*/,
|
||||
const double /*bV*/,
|
||||
const double /*cV*/,
|
||||
const double /*dV*/,
|
||||
const float /*s*/,
|
||||
const float /*x*/,
|
||||
const float /*y*/,
|
||||
const float /*hdg*/,
|
||||
const float /*length*/,
|
||||
const float /*aU*/,
|
||||
const float /*bU*/,
|
||||
const float /*cU*/,
|
||||
const float /*dU*/,
|
||||
const float /*aV*/,
|
||||
const float /*bV*/,
|
||||
const float /*cV*/,
|
||||
const float /*dV*/,
|
||||
const std::string /*p_range*/) {}
|
||||
|
||||
void MapBuilder::AddJunction(const int32_t id, const std::string name) {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace road {
|
|||
void AddRoad(
|
||||
const uint32_t road_id,
|
||||
const std::string name,
|
||||
const double length,
|
||||
const float length,
|
||||
const int32_t junction_id,
|
||||
const int32_t predecessor,
|
||||
const int32_t successor);
|
||||
|
@ -44,102 +44,102 @@ namespace road {
|
|||
|
||||
void SetRoadTypeSpeed(
|
||||
const uint32_t road_id,
|
||||
const double s,
|
||||
const float s,
|
||||
const std::string type,
|
||||
const double max,
|
||||
const float max,
|
||||
const std::string unit);
|
||||
|
||||
// called from geometry parser
|
||||
void AddRoadGeometryLine(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length);
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length);
|
||||
|
||||
void AddRoadGeometryArc(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length,
|
||||
const double curvature);
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length,
|
||||
const float curvature);
|
||||
|
||||
void AddRoadGeometrySpiral(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length,
|
||||
const double curvStart,
|
||||
const double curvEnd);
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length,
|
||||
const float curvStart,
|
||||
const float curvEnd);
|
||||
|
||||
void AddRoadGeometryPoly3(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d);
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length,
|
||||
const float a,
|
||||
const float b,
|
||||
const float c,
|
||||
const float d);
|
||||
|
||||
void AddRoadGeometryParamPoly3(
|
||||
carla::road::Road *road,
|
||||
const double s,
|
||||
const double x,
|
||||
const double y,
|
||||
const double hdg,
|
||||
const double length,
|
||||
const double aU,
|
||||
const double bU,
|
||||
const double cU,
|
||||
const double dU,
|
||||
const double aV,
|
||||
const double bV,
|
||||
const double cV,
|
||||
const double dV,
|
||||
const float s,
|
||||
const float x,
|
||||
const float y,
|
||||
const float hdg,
|
||||
const float length,
|
||||
const float aU,
|
||||
const float bU,
|
||||
const float cU,
|
||||
const float dU,
|
||||
const float aV,
|
||||
const float bV,
|
||||
const float cV,
|
||||
const float dV,
|
||||
const std::string p_range);
|
||||
|
||||
// called from profiles parser
|
||||
void AddRoadElevationProfile(
|
||||
const int32_t road_id,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d);
|
||||
const Road* road,
|
||||
const float s,
|
||||
const float a,
|
||||
const float b,
|
||||
const float c,
|
||||
const float d);
|
||||
|
||||
void AddRoadLateralSuperelevation(
|
||||
const int32_t road_id,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d);
|
||||
// void AddRoadLateralSuperElevation(
|
||||
// const Road* road,
|
||||
// const float s,
|
||||
// const float a,
|
||||
// const float b,
|
||||
// const float c,
|
||||
// const float d);
|
||||
|
||||
void AddRoadLateralCrossfall(
|
||||
const int32_t road_id,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d,
|
||||
const std::string side);
|
||||
// void AddRoadLateralCrossfall(
|
||||
// const Road* road,
|
||||
// const float s,
|
||||
// const float a,
|
||||
// const float b,
|
||||
// const float c,
|
||||
// const float d,
|
||||
// const std::string side);
|
||||
|
||||
void AddRoadLateralShape(
|
||||
const int32_t road_id,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d,
|
||||
const double t);
|
||||
// void AddRoadLateralShape(
|
||||
// const Road* road,
|
||||
// const float s,
|
||||
// const float a,
|
||||
// const float b,
|
||||
// const float c,
|
||||
// const float d,
|
||||
// const float t);
|
||||
|
||||
// Signal methods
|
||||
void AddSignal(
|
||||
|
@ -187,11 +187,11 @@ namespace road {
|
|||
void AddRoadSection(
|
||||
const uint32_t road_id,
|
||||
const uint32_t section_index,
|
||||
const double s,
|
||||
const double a,
|
||||
const double b,
|
||||
const double c,
|
||||
const double d);
|
||||
const float s,
|
||||
const float a,
|
||||
const float b,
|
||||
const float c,
|
||||
const float d);
|
||||
|
||||
void SetRoadLaneLink(
|
||||
const uint32_t road_id,
|
||||
|
|
Loading…
Reference in New Issue