diff --git a/LibCarla/source/carla/client/Map.cpp b/LibCarla/source/carla/client/Map.cpp index 88dd691b6..4a90d6ede 100644 --- a/LibCarla/source/carla/client/Map.cpp +++ b/LibCarla/source/carla/client/Map.cpp @@ -41,7 +41,7 @@ namespace client { SharedPtr Map::GetWaypoint( const geom::Location &location, bool project_to_road, - uint32_t lane_type) const { + int32_t lane_type) const { boost::optional waypoint; if (project_to_road) { waypoint = _map.GetClosestWaypointOnRoad(location, lane_type); diff --git a/LibCarla/source/carla/client/Map.h b/LibCarla/source/carla/client/Map.h index f1c397088..51ebba70c 100644 --- a/LibCarla/source/carla/client/Map.h +++ b/LibCarla/source/carla/client/Map.h @@ -54,7 +54,7 @@ namespace client { SharedPtr GetWaypoint( const geom::Location &location, bool project_to_road = true, - uint32_t lane_type = static_cast(road::Lane::LaneType::Driving)) const; + int32_t lane_type = static_cast(road::Lane::LaneType::Driving)) const; SharedPtr GetWaypointXODR( carla::road::RoadId road_id, diff --git a/LibCarla/source/carla/road/Lane.h b/LibCarla/source/carla/road/Lane.h index 1dc2b9d25..2b5339d7b 100644 --- a/LibCarla/source/carla/road/Lane.h +++ b/LibCarla/source/carla/road/Lane.h @@ -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: diff --git a/LibCarla/source/carla/road/Map.cpp b/LibCarla/source/carla/road/Map.cpp index 5f5605ee0..cddb05f2e 100644 --- a/LibCarla/source/carla/road/Map.cpp +++ b/LibCarla/source/carla/road/Map.cpp @@ -96,7 +96,7 @@ namespace road { if (lane.GetId() == 0) { continue; } - if ((static_cast(lane.GetType()) & static_cast(lane_type)) > 0) { + if ((static_cast(lane.GetType()) & static_cast(lane_type)) > 0) { std::forward(func)(Waypoint{ road_id, lane_section.GetId(), @@ -155,12 +155,12 @@ namespace road { boost::optional Map::GetClosestWaypointOnRoad( const geom::Location &pos, - uint32_t lane_type) const { + int32_t lane_type) const { std::vector 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(lane.GetType())) > 0; + return (lane_type & static_cast(lane.GetType())) > 0; }); if (query_result.size() == 0) { @@ -202,7 +202,7 @@ namespace road { boost::optional Map::GetWaypoint( const geom::Location &pos, - uint32_t lane_type) const { + int32_t lane_type) const { boost::optional 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(lane.second.GetType()) & static_cast(lane_type)) { + static_cast(lane.second.GetType()) & static_cast(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(lane.second.GetType()) & static_cast(lane_type)) { + static_cast(lane.second.GetType()) & static_cast(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(lane.second.GetType()) & static_cast(lane_type)) { + static_cast(lane.second.GetType()) & static_cast(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(lane.second.GetType()) & static_cast(lane_type)) { + static_cast(lane.second.GetType()) & static_cast(lane_type)) { result.emplace_back( Waypoint{ road.GetId(), lane_section.GetId(), lane.second.GetId(), road_len }); } diff --git a/LibCarla/source/carla/road/Map.h b/LibCarla/source/carla/road/Map.h index a04d32699..680ad731e 100644 --- a/LibCarla/source/carla/road/Map.h +++ b/LibCarla/source/carla/road/Map.h @@ -51,11 +51,11 @@ namespace road { boost::optional GetClosestWaypointOnRoad( const geom::Location &location, - uint32_t lane_type = static_cast(Lane::LaneType::Driving)) const; + int32_t lane_type = static_cast(Lane::LaneType::Driving)) const; boost::optional GetWaypoint( const geom::Location &location, - uint32_t lane_type = static_cast(Lane::LaneType::Driving)) const; + int32_t lane_type = static_cast(Lane::LaneType::Driving)) const; boost::optional GetWaypoint( RoadId road_id, diff --git a/PythonAPI/carla/source/libcarla/Map.cpp b/PythonAPI/carla/source/libcarla/Map.cpp index ad55300cf..a1252493a 100644 --- a/PythonAPI/carla/source/libcarla/Map.cpp +++ b/PythonAPI/carla/source/libcarla/Map.cpp @@ -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 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(lane_type)); -} - void export_map() { using namespace boost::python; namespace cc = carla::client; @@ -169,7 +158,7 @@ void export_map() { .def(init((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(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")))