diff --git a/conanfile.py b/conanfile.py index 36a3f213..7f2b5587 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,10 +1,12 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from lanelet2_python.src.lanelet2 import __version__ + class Lanelet2Conan(ConanFile): name = "lanelet2x" - version = "1.2.1" + version = __version__ # Optional metadata license = "BSD" @@ -19,7 +21,7 @@ class Lanelet2Conan(ConanFile): default_options = { "shared": False, "fPIC": True, - # "boost/*:shared": True, + "boost/*:shared": True, "boost/*:without_python": False, } diff --git a/lanelet2_core/CMakeLists.txt b/lanelet2_core/CMakeLists.txt index 86c4ea46..54f155f5 100644 --- a/lanelet2_core/CMakeLists.txt +++ b/lanelet2_core/CMakeLists.txt @@ -30,14 +30,16 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers Eigen3::Eigen) ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") -install(DIRECTORY scripts/ DESTINATION "scripts/") +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") + install(DIRECTORY scripts/ DESTINATION "scripts/") +endif () ############# ## Testing ## diff --git a/lanelet2_io/CMakeLists.txt b/lanelet2_io/CMakeLists.txt index 5e975e53..f23708cd 100644 --- a/lanelet2_io/CMakeLists.txt +++ b/lanelet2_io/CMakeLists.txt @@ -30,12 +30,14 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core Boost::filesystem Boo ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif () ############# ## Testing ## diff --git a/lanelet2_maps/CMakeLists.txt b/lanelet2_maps/CMakeLists.txt index c43623e2..435c20af 100644 --- a/lanelet2_maps/CMakeLists.txt +++ b/lanelet2_maps/CMakeLists.txt @@ -15,5 +15,7 @@ add_custom_command( ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). # This command also exports libraries and config files for dependent packages and this supersedes catkin_package. -install(DIRECTORY res/ DESTINATION "res/") -install(DIRECTORY josm/ DESTINATION "res/" PATTERN ".gitignore" EXCLUDE) +if (NOT DEFINED SKBUILD) + install(DIRECTORY res/ DESTINATION "res/") + install(DIRECTORY josm/ DESTINATION "res/" PATTERN ".gitignore" EXCLUDE) +endif () \ No newline at end of file diff --git a/lanelet2_matching/CMakeLists.txt b/lanelet2_matching/CMakeLists.txt index d58b695e..898d2a64 100644 --- a/lanelet2_matching/CMakeLists.txt +++ b/lanelet2_matching/CMakeLists.txt @@ -29,12 +29,14 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_io lanelet2_ ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif () ############# ## Testing ## diff --git a/lanelet2_projection/CMakeLists.txt b/lanelet2_projection/CMakeLists.txt index a0498407..eadd1005 100644 --- a/lanelet2_projection/CMakeLists.txt +++ b/lanelet2_projection/CMakeLists.txt @@ -29,13 +29,15 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_io Geographi ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") +endif () ############# ## Testing ## diff --git a/lanelet2_python/CMakeLists.txt b/lanelet2_python/CMakeLists.txt index f10f6ef9..8275cea7 100644 --- a/lanelet2_python/CMakeLists.txt +++ b/lanelet2_python/CMakeLists.txt @@ -14,7 +14,8 @@ set(PROJECT_PYTHON_TARGETS) file(GLOB PROJECT_PYTHON_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/python_api/*.cpp") foreach (PROJECT_PYTHON_SOURCE_FILE ${PROJECT_PYTHON_SOURCE_FILES_SRC}) get_filename_component(PYTHON_MODULE_NAME ${PROJECT_PYTHON_SOURCE_FILE} NAME_WE) - Python_add_library(${PYTHON_MODULE_NAME} MODULE ${PROJECT_PYTHON_SOURCE_FILE} WITH_SOABI) + python_add_library(${PYTHON_MODULE_NAME} MODULE ${PROJECT_PYTHON_SOURCE_FILE} WITH_SOABI) + target_compile_definitions(${PYTHON_MODULE_NAME} PRIVATE -DPYTHON_API_MODULE_NAME=${PYTHON_MODULE_NAME}) target_include_directories(${PYTHON_MODULE_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") target_include_directories(${PYTHON_MODULE_NAME} PRIVATE ${Python3_INCLUDE_DIRS}) target_link_libraries(${PYTHON_MODULE_NAME} PUBLIC Boost::python lanelet2_core lanelet2_io lanelet2_projection lanelet2_traffic_rules lanelet2_routing lanelet2_matching) @@ -24,8 +25,16 @@ endforeach () ############# ## Install ## ############# -# Install all targets, headers by default and scripts and other files if specified (folders or files). -install(TARGETS ${PROJECT_PYTHON_TARGETS} DESTINATION lanelet2) +# Install all python modules into /lanelet2 if CMake is running inside scikit-build-core +if (DEFINED SKBUILD) + install(TARGETS ${PROJECT_PYTHON_TARGETS} DESTINATION "lanelet2") + if (WIN32) + # Bundle runtime dlls with the wheel on windows + foreach (PROJECT_PYTHON_TARGET ${PROJECT_PYTHON_TARGETS}) + install(FILES "$" DESTINATION "lanelet2/bin") + endforeach () + endif () +endif () ############# ## Testing ## diff --git a/lanelet2_python/package.xml b/lanelet2_python/package.xml deleted file mode 100644 index 57d6d3ed..00000000 --- a/lanelet2_python/package.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - lanelet2_python - 1.2.1 - Python bindings for lanelet2 - - BSD - Fabian Immel - Fabian Poggenhans - https://github.com/fzi-forschungszentrum-informatik/lanelet2.git - - catkin - ament_cmake_core - mrt_cmake_modules - mrt_cmake_modules - gtest - lanelet2_core - lanelet2_io - lanelet2_routing - lanelet2_traffic_rules - lanelet2_projection - lanelet2_matching - libboost-python-dev - - catkin - ament_cmake - - diff --git a/lanelet2_python/scripts/create_debug_routing_graph.py b/lanelet2_python/scripts/create_debug_routing_graph.py index bda01db7..112e5a96 100755 --- a/lanelet2_python/scripts/create_debug_routing_graph.py +++ b/lanelet2_python/scripts/create_debug_routing_graph.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -import lanelet2 -import sys import argparse +import lanelet2 + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("filename", help="Path to the input osm file") @@ -13,21 +13,23 @@ help="traffic participant type (one of vehicle, bicycle, pedestrian, train", type=str, required=True, - default="vehicle") + default="vehicle", + ) parser.add_argument("--lat", help="Lateral position of origin", type=float, default=49) parser.add_argument("--lon", help="Longitudinal position of origin", type=float, default=8) args = parser.parse_args() - rules_map = {"vehicle": lanelet2.traffic_rules.Participants.Vehicle, - "bicycle": lanelet2.traffic_rules.Participants.Bicycle, - "pedestrian": lanelet2.traffic_rules.Participants.Pedestrian, - "train": lanelet2.traffic_rules.Participants.Train} + rules_map = { + "vehicle": lanelet2.traffic_rules.Participants.Vehicle, + "bicycle": lanelet2.traffic_rules.Participants.Bicycle, + "pedestrian": lanelet2.traffic_rules.Participants.Pedestrian, + "train": lanelet2.traffic_rules.Participants.Train, + } proj = lanelet2.projection.UtmProjector(lanelet2.io.Origin(args.lat, args.lon)) laneletmap = lanelet2.io.load(args.filename, proj) - routing_cost = lanelet2.routing.RoutingCostDistance(0.) # zero cost for lane changes - traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, - rules_map[args.participant]) + routing_cost = lanelet2.routing.RoutingCostDistance(0.0) # zero cost for lane changes + traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, rules_map[args.participant]) graph = lanelet2.routing.RoutingGraph(laneletmap, traffic_rules, [routing_cost]) debug_map = graph.getDebugLaneletMap() diff --git a/lanelet2_python/scripts/make_ids_positive.py b/lanelet2_python/scripts/make_ids_positive.py index 538c191e..c9962c64 100755 --- a/lanelet2_python/scripts/make_ids_positive.py +++ b/lanelet2_python/scripts/make_ids_positive.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -import lanelet2 -import sys import argparse +import lanelet2 + def make_positive(layer): for elem in layer: @@ -14,7 +14,7 @@ def make_positive(layer): parser = argparse.ArgumentParser() parser.add_argument("filename", help="Path to the input osm file") group = parser.add_mutually_exclusive_group(required=True) -group.add_argument("output", help="Path to results", nargs='?') +group.add_argument("output", help="Path to results", nargs="?") group.add_argument("-i", "--inplace", action="store_true", help="Overwrite input file") args = parser.parse_args() @@ -24,7 +24,6 @@ def make_positive(layer): proj = lanelet2.projection.MercatorProjector(lanelet2.io.Origin(49, 8)) map = lanelet2.io.load(args.filename, proj) - make_positive(map.pointLayer) make_positive(map.lineStringLayer) make_positive(map.polygonLayer) diff --git a/lanelet2_python/scripts/print_ids.py b/lanelet2_python/scripts/print_ids.py index d2435f9b..d95a3964 100755 --- a/lanelet2_python/scripts/print_ids.py +++ b/lanelet2_python/scripts/print_ids.py @@ -1,8 +1,9 @@ #!/usr/bin/env python -import lanelet2 -import sys import argparse +import sys + +import lanelet2 def print_layer(layer, layerName): @@ -18,8 +19,14 @@ def print_layer(layer, layerName): proj = lanelet2.projection.MercatorProjector(lanelet2.io.Origin(49, 8)) map = lanelet2.io.load(args.filename, proj) -layers = {"Points": map.pointLayer, "Line Strings": map.lineStringLayer, "Polygons": map.polygonLayer, - "Lanelets": map.laneletLayer, "Areas": map.areaLayer, "Regulatory Elements": map.regulatoryElementLayer} +layers = { + "Points": map.pointLayer, + "Line Strings": map.lineStringLayer, + "Polygons": map.polygonLayer, + "Lanelets": map.laneletLayer, + "Areas": map.areaLayer, + "Regulatory Elements": map.regulatoryElementLayer, +} for layer_name, layer in layers.iteritems(): if not args.has_id: diff --git a/lanelet2_python/setup.py.template b/lanelet2_python/setup.py.template deleted file mode 100644 index d5d2b7e7..00000000 --- a/lanelet2_python/setup.py.template +++ /dev/null @@ -1,38 +0,0 @@ -""" -setup.py template. use e.g. sed to replace placeholders with the correct values - - $ sed 's/${{ version }}/1.2.0/' setup.py.template > setup.py -""" -from setuptools import setup -from pathlib import Path - -DISTNAME = "lanelet2" -DESCRIPTION = "Map handling framework for automated driving." -MAINTAINER = "Fabian Immel" -MAINTAINER_EMAIL = "fabian.immel@kit.edu" -URL = "https://github.com/fzi-forschungszentrum-informatik/Lanelet2" -LICENSE = "BSD" -DOWNLOAD_URL = "https://github.com/fzi-forschungszentrum-informatik/Lanelet2/releases/tag/{{ version }}" -VERSION = "{{ version }}" -this_directory = Path(__file__).parent -long_description = (this_directory /"src" / "lanelet2" / "README.md").read_text() - -class ExtModules(list): - def __bool__(self): - return True - -setup(name=DISTNAME, - description=DESCRIPTION, - maintainer=MAINTAINER, - maintainer_email=MAINTAINER_EMAIL, - url=URL, - license=LICENSE, - download_url=DOWNLOAD_URL, - version=VERSION, - packages=["lanelet2"], - # Include pre-compiled extension - package_data={"lanelet2": ["*"]}, - ext_modules=ExtModules(), - has_ext_modules=lambda: True, - long_description=long_description, - long_description_content_type='text/markdown') diff --git a/python/lanelet2/__init__.py b/lanelet2_python/src/lanelet2/__init__.py similarity index 50% rename from python/lanelet2/__init__.py rename to lanelet2_python/src/lanelet2/__init__.py index 0d664d3a..485324ce 100644 --- a/python/lanelet2/__init__.py +++ b/lanelet2_python/src/lanelet2/__init__.py @@ -1,6 +1,24 @@ +import os from os.path import dirname from pkgutil import iter_modules +__version__ = "1.2.1" + +if os.name == "nt": + bin_dir = None + + try: + bin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "bin")) + try: + os.add_dll_directory(bin_dir) + except (Exception,): + pass + os.environ["PATH"] = bin_dir + ";" + os.environ["PATH"] + except (Exception,): + pass + + del bin_dir + # automatically import all files in this module __all__ = [name for _, name, _ in iter_modules([dirname(__file__)])] diff --git a/lanelet2_python/test/test_lanelet2.py b/lanelet2_python/test/test_lanelet2.py index df13c236..2d580fbb 100644 --- a/lanelet2_python/test/test_lanelet2.py +++ b/lanelet2_python/test/test_lanelet2.py @@ -1,66 +1,75 @@ import unittest -import lanelet2 # if we fail here, there is something wrong with registration -from lanelet2.core import AttributeMap, getId, BasicPoint2d, Point3d, LineString3d, Lanelet, RegulatoryElement, TrafficLight, LaneletMap, createMapFromLanelets + +from lanelet2.core import ( + AttributeMap, + getId, + BasicPoint2d, + Point3d, + LineString3d, + Lanelet, + TrafficLight, + createMapFromLanelets, +) from lanelet2.geometry import distance, intersects2d, boundingBox2d, to2D, intersection -def getAttributes(): +def get_attributes(): return AttributeMap({"key": "value"}) -def getPoint(): - return Point3d(getId(), 0, 0, 0, getAttributes()) +def get_point(): + return Point3d(getId(), 0, 0, 0, get_attributes()) -def getLineString(): - return LineString3d(getId(), [getPoint(), getPoint()], getAttributes()) +def get_line_string(): + return LineString3d(getId(), [get_point(), get_point()], get_attributes()) -def getLanelet(): - return Lanelet(getId(), getLineString(), getLineString(), getAttributes()) +def get_lanelet(): + return Lanelet(getId(), get_line_string(), get_line_string(), get_attributes()) -def getRegelem(): - return TrafficLight(getId(), AttributeMap(), [getLineString()], getLineString()) +def get_regelem(): + return TrafficLight(getId(), AttributeMap(), [get_line_string()], get_line_string()) -def getLaneletMap(): - lanelet = getLanelet() - lanelet.addRegulatoryElement(getRegelem()) +def get_lanelet_map(): + lanelet = get_lanelet() + lanelet.addRegulatoryElement(get_regelem()) return createMapFromLanelets([lanelet]) -def checkPrimitiveId(testClass, primitive): +def check_primitive_id(test_class, primitive): primitive.id = 30 - testClass.assertEqual(primitive.id, 30) + test_class.assertEqual(primitive.id, 30) -def checkPrimitiveAttributes(testClass, primitive): +def check_primitive_attributes(test_class, primitive): lenBefore = len(primitive.attributes) primitive.attributes["newkey"] = "newvalue" - testClass.assertEqual(lenBefore + 1, len(primitive.attributes)) - testClass.assertTrue("newkey" in primitive.attributes) - testClass.assertEqual(primitive.attributes["newkey"], "newvalue") + test_class.assertEqual(lenBefore + 1, len(primitive.attributes)) + test_class.assertTrue("newkey" in primitive.attributes) + test_class.assertEqual(primitive.attributes["newkey"], "newvalue") del primitive.attributes["newkey"] - testClass.assertFalse("newkey" in primitive.attributes) + test_class.assertFalse("newkey" in primitive.attributes) class LaneletApiTestCase(unittest.TestCase): def test_lanelet_id(self): - checkPrimitiveId(self, getLanelet()) + check_primitive_id(self, get_lanelet()) def test_lanelet_attributes(self): - checkPrimitiveAttributes(self, getLanelet()) + check_primitive_attributes(self, get_lanelet()) def test_lanelet_modification(self): - lanelet = getLanelet() - bound = getLineString() + lanelet = get_lanelet() + bound = get_line_string() lanelet.leftBound = bound self.assertEqual(bound, lanelet.leftBound) def test_lanelet_regelem(self): - regelem = getRegelem() - llt = getLanelet() + regelem = get_regelem() + llt = get_lanelet() llt.addRegulatoryElement(regelem) self.assertEqual(len(llt.trafficLights()), 1) self.assertEqual(len(llt.trafficSigns()), 0) @@ -69,12 +78,12 @@ def test_lanelet_regelem(self): class LaneletMapApiTestCase(unittest.TestCase): def test_lanelet_map_basic(self): - map = getLaneletMap() + map = get_lanelet_map() self.assertEqual(len(map.laneletLayer), 1) self.assertEqual(len(map.regulatoryElementLayer), 1) def test_lanelet_map_search(self): - map = getLaneletMap() + map = get_lanelet_map() nearest = map.laneletLayer.nearest(BasicPoint2d(0, 0), 1) self.assertEqual(len(nearest), 1) self.assertTrue(map.laneletLayer.exists(nearest[0].id)) @@ -82,29 +91,29 @@ def test_lanelet_map_search(self): class GeometryApiTestCase(unittest.TestCase): def test_distance_p2p(self): - self.assertEqual(distance(getPoint(), getPoint()), 0) + self.assertEqual(distance(get_point(), get_point()), 0) def test_distance_basic_p2p(self): - self.assertEqual(distance(getPoint().basicPoint(), getPoint()), 0) + self.assertEqual(distance(get_point().basicPoint(), get_point()), 0) def test_distance_l2l(self): - self.assertEqual(distance(getLineString(), getLineString()), 0) + self.assertEqual(distance(get_line_string(), get_line_string()), 0) def test_distance_llt2llt(self): - self.assertEqual(distance(getLanelet(), getLanelet()), 0) + self.assertEqual(distance(get_lanelet(), get_lanelet()), 0) def test_intersects_l2l(self): - self.assertTrue(intersects2d(to2D(getLineString()), to2D(getLineString()))) + self.assertTrue(intersects2d(to2D(get_line_string()), to2D(get_line_string()))) def test_bounding_box_line(self): - bbox = boundingBox2d(to2D(getLineString())) + bbox = boundingBox2d(to2D(get_line_string())) self.assertEqual(bbox.min.x, 0) def test_intersection_l2l(self): - point_list = intersection(to2D(getLineString()), to2D(getLineString())) + point_list = intersection(to2D(get_line_string()), to2D(get_line_string())) self.assertEqual(point_list[0].x, 0.0) self.assertEqual(point_list[0].y, 0.0) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/lanelet2_python/test/test_lanelet2_matching.py b/lanelet2_python/test/test_lanelet2_matching.py index 876b8020..c8723767 100644 --- a/lanelet2_python/test/test_lanelet2_matching.py +++ b/lanelet2_python/test/test_lanelet2_matching.py @@ -1,9 +1,24 @@ import unittest + import lanelet2 # if we fail here, there is something wrong with lanelet2 registration -from lanelet2.core import AttributeMap, getId, BasicPoint2d, Point3d, LineString3d, Lanelet, RegulatoryElement, TrafficLight, LaneletMap, createMapFromLanelets, ConstLanelet, ConstLineString3d -from lanelet2.geometry import distance, intersects2d, boundingBox2d, to2D, equals -from lanelet2.matching import Pose2d, getDeterministicMatches, getProbabilisticMatches, Object2d, ObjectWithCovariance2d, PositionCovariance2d, removeNonRuleCompliantMatches +from lanelet2.core import ( + getId, + Point3d, + LineString3d, + Lanelet, + LaneletMap, + ConstLanelet, +) from lanelet2.matching import ConstLaneletMatch, ConstLaneletMatchProbabilistic +from lanelet2.matching import ( + Pose2d, + getDeterministicMatches, + getProbabilisticMatches, + Object2d, + ObjectWithCovariance2d, + PositionCovariance2d, + removeNonRuleCompliantMatches, +) def get_sample_lanelet_map(): @@ -44,11 +59,11 @@ def test_custom_init(self): self.assertEqual(len(obj_with_cov_2d.absoluteHull), 0) self.assertEqual(obj_with_cov_2d.vonMisesKappa, 2) - pos_cov_2d = PositionCovariance2d(1., 2., 3.) + pos_cov_2d = PositionCovariance2d(1.0, 2.0, 3.0) self.assertTrue(isinstance(pos_cov_2d, PositionCovariance2d)) self.assertEqual("1 3\n3 2", str(pos_cov_2d)) - pose_2d = Pose2d(1., 2., 3.) + pose_2d = Pose2d(1.0, 2.0, 3.0) self.assertTrue(isinstance(pose_2d, Pose2d)) self.assertEqual("x: 1\ny: 2\nphi: 3", str(pose_2d)) @@ -58,18 +73,19 @@ def test_matching(self): mymap = get_sample_lanelet_map() obj = Object2d(1, Pose2d(1, 1, 0), []) - obj_with_cov = ObjectWithCovariance2d(1, Pose2d(1, 1, 0), [], PositionCovariance2d(1., 1., 0.), 2) + obj_with_cov = ObjectWithCovariance2d(1, Pose2d(1, 1, 0), [], PositionCovariance2d(1.0, 1.0, 0.0), 2) - obj_matches = getDeterministicMatches(mymap, obj, 1.) + obj_matches = getDeterministicMatches(mymap, obj, 1.0) self.assertEqual(len(obj_matches), 2) # lanelet in both directions self.assertTrue(isinstance(obj_matches[0], ConstLaneletMatch)) - obj_with_cov_matches = getProbabilisticMatches(mymap, obj_with_cov, 1.) + obj_with_cov_matches = getProbabilisticMatches(mymap, obj_with_cov, 1.0) self.assertEqual(len(obj_with_cov_matches), 2) # lanelet in both directions self.assertTrue(isinstance(obj_with_cov_matches[0], ConstLaneletMatchProbabilistic)) - traffic_rules = lanelet2.traffic_rules.create(lanelet2.traffic_rules.Locations.Germany, - lanelet2.traffic_rules.Participants.Vehicle) + traffic_rules = lanelet2.traffic_rules.create( + lanelet2.traffic_rules.Locations.Germany, lanelet2.traffic_rules.Participants.Vehicle + ) obj_matches_rule_compliant = removeNonRuleCompliantMatches(obj_matches, traffic_rules) self.assertEqual(len(obj_matches_rule_compliant), 1) # lanelet only in one direction @@ -90,5 +106,5 @@ def test_matching(self): self.assertRaises(RuntimeError, removeNonRuleCompliantMatches, [obj], traffic_rules) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/lanelet2_python/test/test_lanelet2_projection.py b/lanelet2_python/test/test_lanelet2_projection.py index f282bb1b..38e6b2a3 100644 --- a/lanelet2_python/test/test_lanelet2_projection.py +++ b/lanelet2_python/test/test_lanelet2_projection.py @@ -1,10 +1,8 @@ import unittest -import lanelet2 # if we fail here, there is something wrong with lanelet2 registration -from lanelet2.core import (BasicPoint3d, GPSPoint) + +from lanelet2.core import BasicPoint3d, GPSPoint from lanelet2.io import Origin -from lanelet2.projection import (UtmProjector, - GeocentricProjector, - LocalCartesianProjector) +from lanelet2.projection import UtmProjector, GeocentricProjector, LocalCartesianProjector class MatchingApiTestCase(unittest.TestCase): @@ -22,7 +20,7 @@ class MatchingApiTestCase(unittest.TestCase): # the larges number of decimal places for assertEqual comparisons decimals = 8 - def test_UtmProjector(self): + def test_utm_projector(self): # NOTE: the projected plane is on the WGS84 ellipsoid origin = Origin(self.origin_lat, self.origin_lon) utm_projector = UtmProjector(origin) @@ -38,14 +36,13 @@ def test_UtmProjector(self): self.assertEqual(round(gps_point.lon, 5), self.origin_lon) self.assertEqual(round(gps_point.alt, 5), self.origin_ele) - def test_LocalCartesianProjector(self): + def test_local_cartesian_projector(self): # NOTE: the projected plane is tangential to the WGS84 ellipsoid # but it is at the given elevation above the ellipsoid origin = Origin(self.origin_lat, self.origin_lon, self.origin_ele) local_cartesian_projector = LocalCartesianProjector(origin) - local_cartesian_point = local_cartesian_projector.forward( - self.origin_gps_point) + local_cartesian_point = local_cartesian_projector.forward(self.origin_gps_point) self.assertEqual(local_cartesian_point.x, 0.0) self.assertEqual(local_cartesian_point.y, 0.0) self.assertEqual(local_cartesian_point.z, 0.0) @@ -56,7 +53,7 @@ def test_LocalCartesianProjector(self): self.assertEqual(round(gps_point.lon, self.decimals), self.origin_lon) self.assertEqual(round(gps_point.alt, self.decimals), self.origin_ele) - def test_GeocentricProjector(self): + def test_geocentric_projector(self): geocentric_projector = GeocentricProjector() ecef_point = geocentric_projector.forward(self.origin_gps_point) @@ -70,5 +67,5 @@ def test_GeocentricProjector(self): self.assertEqual(round(gps_point.alt, self.decimals), self.origin_ele) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/lanelet2_routing/CMakeLists.txt b/lanelet2_routing/CMakeLists.txt index cf9c3ed9..6c926f9f 100644 --- a/lanelet2_routing/CMakeLists.txt +++ b/lanelet2_routing/CMakeLists.txt @@ -29,14 +29,16 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core lanelet2_traffic_rule ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") -install(DIRECTORY res/ DESTINATION "res/") +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(DIRECTORY doc/ DESTINATION "doc/${PROJECT_NAME}") + install(DIRECTORY res/ DESTINATION "res/") +endif () ############# ## Testing ## diff --git a/lanelet2_traffic_rules/CMakeLists.txt b/lanelet2_traffic_rules/CMakeLists.txt index 0eba4405..39241ec8 100644 --- a/lanelet2_traffic_rules/CMakeLists.txt +++ b/lanelet2_traffic_rules/CMakeLists.txt @@ -28,12 +28,14 @@ target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core) ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif () ############# ## Testing ## diff --git a/lanelet2_validation/CMakeLists.txt b/lanelet2_validation/CMakeLists.txt index 77f12cad..81a41247 100644 --- a/lanelet2_validation/CMakeLists.txt +++ b/lanelet2_validation/CMakeLists.txt @@ -50,12 +50,14 @@ endif () ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (NOT DEFINED SKBUILD) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif () ############# ## Testing ## diff --git a/pyproject.toml b/pyproject.toml index 9f0bde3d..2fee5005 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "lanelet2x" -version = "1.2.1" +dynamic = ["version"] authors = [ { name = "Fabian Poggenhans", email = "fabian.poggenhans@kit.edu" }, { name = "Fabian Immel", email = "fabian.immel@kit.edu" }, @@ -20,18 +20,27 @@ license = { file = "LICENSE" } classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: BSD License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", ] [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.args = ["--preset conan-release"] +cmake.define = { LANELET2_ENABLE_TESTING = "OFF" } cmake.build-type = "Release" -wheel.packages = ["python/lanelet2"] +wheel.packages = ["lanelet2_python/src/lanelet2"] wheel.license-files = ["LICENSE", "CODEOWNERS"] -[tool.scikit-build.cmake.define] -LANELET2_BUILD_TESTING = "OFF" +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "lanelet2_python/src/lanelet2/__init__.py" [[tool.scikit-build.overrides]] if.platform-system = "win32"