Add save OpenDrive to disk
This commit is contained in:
parent
58150a65fe
commit
89f30ee49c
|
@ -159,6 +159,7 @@
|
|||
- `get_spawn_points()`
|
||||
- `get_waypoint(location, project_to_road=True)`
|
||||
- `to_opendrive()`
|
||||
- `save_to_disk(path=self.name)`
|
||||
|
||||
## `carla.Waypoint`
|
||||
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include <carla/FileSystem.h>
|
||||
#include <carla/PythonUtil.h>
|
||||
#include <carla/client/Map.h>
|
||||
#include <carla/client/Waypoint.h>
|
||||
|
||||
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace carla {
|
||||
namespace client {
|
||||
|
||||
|
@ -26,6 +29,16 @@ namespace client {
|
|||
} // namespace client
|
||||
} // namespace carla
|
||||
|
||||
static void SaveOpenDriveToDisk(const carla::client::Map &self, std::string path) {
|
||||
carla::PythonUtil::ReleaseGIL unlock;
|
||||
if (path.empty()) {
|
||||
path = self.GetName();
|
||||
}
|
||||
carla::FileSystem::ValidateFilePath(path, ".xodr");
|
||||
std::ofstream out(path);
|
||||
out << self.GetOpenDrive() << std::endl;
|
||||
}
|
||||
|
||||
void export_map() {
|
||||
using namespace boost::python;
|
||||
namespace cc = carla::client;
|
||||
|
@ -46,6 +59,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("to_opendrive", CALL_RETURNING_COPY(cc::Map, GetOpenDrive))
|
||||
.def("save_to_disk", &SaveOpenDriveToDisk, (arg("path")=""))
|
||||
.def(self_ns::str(self_ns::self))
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in New Issue