Changed LaneType enum from unsigned to signed type
This commit is contained in:
parent
59e171a285
commit
530f56e78b
|
@ -41,7 +41,7 @@ namespace client {
|
|||
SharedPtr<Waypoint> Map::GetWaypoint(
|
||||
const geom::Location &location,
|
||||
bool project_to_road,
|
||||
uint32_t lane_type) const {
|
||||
int32_t lane_type) const {
|
||||
boost::optional<road::element::Waypoint> waypoint;
|
||||
if (project_to_road) {
|
||||
waypoint = _map.GetClosestWaypointOnRoad(location, lane_type);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace client {
|
|||
SharedPtr<Waypoint> GetWaypoint(
|
||||
const geom::Location &location,
|
||||
bool project_to_road = true,
|
||||
uint32_t lane_type = static_cast<uint32_t>(road::Lane::LaneType::Driving)) const;
|
||||
int32_t lane_type = static_cast<uint32_t>(road::Lane::LaneType::Driving)) const;
|
||||
|
||||
SharedPtr<Waypoint> GetWaypointXODR(
|
||||
carla::road::RoadId road_id,
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace road {
|
|||
public:
|
||||
|
||||
/// Can be used as flags
|
||||
enum class LaneType : uint32_t {
|
||||
enum class LaneType : int32_t {
|
||||
None = 0x1,
|
||||
Driving = 0x1 << 1,
|
||||
Stop = 0x1 << 2,
|
||||
|
@ -48,7 +48,7 @@ namespace road {
|
|||
Exit = 0x1 << 18,
|
||||
OffRamp = 0x1 << 19,
|
||||
OnRamp = 0x1 << 20,
|
||||
Any = 0xFFFFFFFE
|
||||
Any = -2 // 0xFFFFFFFE
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace road {
|
|||
if (lane.GetId() == 0) {
|
||||
continue;
|
||||
}
|
||||
if ((static_cast<uint32_t>(lane.GetType()) & static_cast<uint32_t>(lane_type)) > 0) {
|
||||
if ((static_cast<int32_t>(lane.GetType()) & static_cast<int32_t>(lane_type)) > 0) {
|
||||
std::forward<FuncT>(func)(Waypoint{
|
||||
road_id,
|
||||
lane_section.GetId(),
|
||||
|
@ -155,12 +155,12 @@ namespace road {
|
|||
|
||||
boost::optional<Waypoint> Map::GetClosestWaypointOnRoad(
|
||||
const geom::Location &pos,
|
||||
uint32_t lane_type) const {
|
||||
int32_t lane_type) const {
|
||||
std::vector<Rtree::TreeElement> query_result =
|
||||
_rtree.GetNearestNeighboursWithFilter(Rtree::BPoint(pos.x, pos.y, pos.z),
|
||||
[&](Rtree::TreeElement const &element) {
|
||||
const Lane &lane = GetLane(element.second.first);
|
||||
return (lane_type & static_cast<uint32_t>(lane.GetType())) > 0;
|
||||
return (lane_type & static_cast<int32_t>(lane.GetType())) > 0;
|
||||
});
|
||||
|
||||
if (query_result.size() == 0) {
|
||||
|
@ -202,7 +202,7 @@ namespace road {
|
|||
|
||||
boost::optional<Waypoint> Map::GetWaypoint(
|
||||
const geom::Location &pos,
|
||||
uint32_t lane_type) const {
|
||||
int32_t lane_type) const {
|
||||
boost::optional<Waypoint> w = GetClosestWaypointOnRoad(pos, lane_type);
|
||||
|
||||
if (!w.has_value()) {
|
||||
|
@ -609,7 +609,7 @@ namespace road {
|
|||
for (const auto &lane : lane_section.GetLanes()) {
|
||||
// add only the right (negative) lanes
|
||||
if (lane.first < 0 &&
|
||||
static_cast<uint32_t>(lane.second.GetType()) & static_cast<uint32_t>(lane_type)) {
|
||||
static_cast<int32_t>(lane.second.GetType()) & static_cast<int32_t>(lane_type)) {
|
||||
result.emplace_back(Waypoint{ road.GetId(), lane_section.GetId(), lane.second.GetId(), 0.0 });
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ namespace road {
|
|||
for (const auto &lane : lane_section.GetLanes()) {
|
||||
// add only the left (positive) lanes
|
||||
if (lane.first > 0 &&
|
||||
static_cast<uint32_t>(lane.second.GetType()) & static_cast<uint32_t>(lane_type)) {
|
||||
static_cast<int32_t>(lane.second.GetType()) & static_cast<int32_t>(lane_type)) {
|
||||
result.emplace_back(
|
||||
Waypoint{ road.GetId(), lane_section.GetId(), lane.second.GetId(), road_len });
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ namespace road {
|
|||
for (const auto &lane : lane_section.GetLanes()) {
|
||||
// add only the right (negative) lanes
|
||||
if (lane.first < 0 &&
|
||||
static_cast<uint32_t>(lane.second.GetType()) & static_cast<uint32_t>(lane_type)) {
|
||||
static_cast<int32_t>(lane.second.GetType()) & static_cast<int32_t>(lane_type)) {
|
||||
result.emplace_back(Waypoint{ road.GetId(), lane_section.GetId(), lane.second.GetId(), 0.0 });
|
||||
}
|
||||
}
|
||||
|
@ -652,7 +652,7 @@ namespace road {
|
|||
for (const auto &lane : lane_section.GetLanes()) {
|
||||
// add only the left (positive) lanes
|
||||
if (lane.first > 0 &&
|
||||
static_cast<uint32_t>(lane.second.GetType()) & static_cast<uint32_t>(lane_type)) {
|
||||
static_cast<int32_t>(lane.second.GetType()) & static_cast<int32_t>(lane_type)) {
|
||||
result.emplace_back(
|
||||
Waypoint{ road.GetId(), lane_section.GetId(), lane.second.GetId(), road_len });
|
||||
}
|
||||
|
|
|
@ -51,11 +51,11 @@ namespace road {
|
|||
|
||||
boost::optional<element::Waypoint> GetClosestWaypointOnRoad(
|
||||
const geom::Location &location,
|
||||
uint32_t lane_type = static_cast<uint32_t>(Lane::LaneType::Driving)) const;
|
||||
int32_t lane_type = static_cast<int32_t>(Lane::LaneType::Driving)) const;
|
||||
|
||||
boost::optional<element::Waypoint> GetWaypoint(
|
||||
const geom::Location &location,
|
||||
uint32_t lane_type = static_cast<uint32_t>(Lane::LaneType::Driving)) const;
|
||||
int32_t lane_type = static_cast<int32_t>(Lane::LaneType::Driving)) const;
|
||||
|
||||
boost::optional<element::Waypoint> GetWaypoint(
|
||||
RoadId road_id,
|
||||
|
|
|
@ -78,17 +78,6 @@ static carla::geom::GeoLocation ToGeolocation(
|
|||
return self.GetGeoReference().Transform(location);
|
||||
}
|
||||
|
||||
// interface with carla::client::Map::GetWaypoint
|
||||
// windows compiler requires the explicit conversion from int32_t to uint32_t
|
||||
// which is not possible in python side
|
||||
static carla::SharedPtr<carla::client::Waypoint> GetWaypoint(
|
||||
const carla::client::Map &self,
|
||||
const carla::geom::Location &location,
|
||||
bool project_to_road,
|
||||
int32_t lane_type) {
|
||||
return self.GetWaypoint(location, project_to_road, static_cast<uint32_t>(lane_type));
|
||||
}
|
||||
|
||||
void export_map() {
|
||||
using namespace boost::python;
|
||||
namespace cc = carla::client;
|
||||
|
@ -169,7 +158,7 @@ void export_map() {
|
|||
.def(init<std::string, std::string>((arg("name"), arg("xodr_content"))))
|
||||
.add_property("name", CALL_RETURNING_COPY(cc::Map, GetName))
|
||||
.def("get_spawn_points", CALL_RETURNING_LIST(cc::Map, GetRecommendedSpawnPoints))
|
||||
.def("get_waypoint", &GetWaypoint, (arg("location"), arg("project_to_road")=true, arg("lane_type")=static_cast<int32_t>(cr::Lane::LaneType::Driving)))
|
||||
.def("get_waypoint", &cc::Map::GetWaypoint, (arg("location"), arg("project_to_road")=true, arg("lane_type")=cr::Lane::LaneType::Driving))
|
||||
.def("get_waypoint_xodr", &cc::Map::GetWaypointXODR, (arg("road_id"), arg("lane_id"), arg("s")))
|
||||
.def("get_topology", &GetTopology)
|
||||
.def("generate_waypoints", CALL_RETURNING_LIST_1(cc::Map, GenerateWaypoints, double), (args("distance")))
|
||||
|
|
Loading…
Reference in New Issue