Skip to content

Commit

Permalink
Add unit tests for geojson map parsing functions (#144)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <luca@openrobotics.org>
Signed-off-by: Morgan Quigley <morgan@osrfoundation.org>
Co-authored-by: Morgan Quigley <morgan@osrfoundation.org>
  • Loading branch information
luca-della-vedova and codebot committed Feb 12, 2022
1 parent 6b5883f commit 1453302
Show file tree
Hide file tree
Showing 4 changed files with 1,952 additions and 26 deletions.
4 changes: 4 additions & 0 deletions rmf_traffic_ros2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ if(BUILD_TESTING)
test_rmf_traffic_ros2 test/main.cpp ${unit_test_srcs}
TIMEOUT 300)

target_compile_definitions(test_rmf_traffic_ros2
PRIVATE
"-DTEST_RESOURCES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/test/resources/\"")

target_link_libraries(test_rmf_traffic_ros2
rmf_traffic_ros2
yaml-cpp
Expand Down
10 changes: 10 additions & 0 deletions rmf_traffic_ros2/src/rmf_traffic_ros2/convert_Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ rmf_traffic::agv::Graph json_to_graph(
double rounded_x = std::round(easting / wp_tolerance) * wp_tolerance;
double rounded_y = std::round(northing / wp_tolerance) * wp_tolerance;
idx_map[level_idx][rounded_x][rounded_y] = wp.index();

// Set waypoint properties
if (feature["properties"].contains("is_holding_point"))
wp.set_holding_point(feature["properties"]["is_holding_point"]);
if (feature["properties"].contains("is_passthrough_point"))
wp.set_passthrough_point(feature["properties"]["is_passthrough_point"]);
if (feature["properties"].contains("is_parking_spot"))
wp.set_parking_spot(feature["properties"]["is_parking_spot"]);
if (feature["properties"].contains("is_charger"))
wp.set_charger(feature["properties"]["is_charger"]);
}

// now spin through the features again, looking for lanes
Expand Down
Loading

0 comments on commit 1453302

Please sign in to comment.