Expose map generate all waypoints in Python

This commit is contained in:
nsubiron 2018-11-14 18:32:22 +01:00
parent 4eed57fb87
commit e5c4f593d0
4 changed files with 24 additions and 0 deletions

View File

@ -174,6 +174,7 @@
- `get_spawn_points()`
- `get_waypoint(location, project_to_road=True)`
- `get_topology()`
- `generate_waypoints(distance)`
- `to_opendrive()`
- `save_to_disk(path=self.name)`

View File

@ -69,6 +69,16 @@ namespace client {
return result;
}
std::vector<SharedPtr<Waypoint>> Map::GenerateWaypoints(double distance) const {
std::vector<SharedPtr<Waypoint>> result;
const auto waypoints = road::WaypointGenerator::GenerateAll(*_map, distance);
result.reserve(waypoints.size());
for (const auto &waypoint : waypoints) {
result.emplace_back(SharedPtr<Waypoint>(new Waypoint{shared_from_this(), waypoint}));
}
return result;
}
std::vector<road::element::LaneMarking> Map::CalculateCrossedLanes(
const geom::Location &origin,
const geom::Location &destination) const {

View File

@ -48,6 +48,8 @@ namespace client {
TopologyList GetTopology() const;
std::vector<SharedPtr<Waypoint>> GenerateWaypoints(double distance) const;
std::vector<road::element::LaneMarking> CalculateCrossedLanes(
const geom::Location &origin,
const geom::Location &destination) const;

View File

@ -49,6 +49,16 @@ static auto GetTopology(const carla::client::Map &self) {
return result;
}
static auto GenerateWaypoints(const carla::client::Map &self, double distance) {
namespace py = boost::python;
auto waypoints = self.GenerateWaypoints(distance);
py::list result;
for (auto &&waypoint : waypoints) {
result.append(waypoint);
}
return result;
}
void export_map() {
using namespace boost::python;
namespace cc = carla::client;
@ -69,6 +79,7 @@ void export_map() {
.def("get_spawn_points", CALL_RETURNING_COPY(cc::Map, GetRecommendedSpawnPoints))
.def("get_waypoint", &cc::Map::GetWaypoint, (arg("location"), arg("project_to_road")=true))
.def("get_topology", &GetTopology)
.def("generate_waypoints", &GenerateWaypoints)
.def("to_opendrive", CALL_RETURNING_COPY(cc::Map, GetOpenDrive))
.def("save_to_disk", &SaveOpenDriveToDisk, (arg("path")=""))
.def(self_ns::str(self_ns::self))