Skip to content

Commit 66a8518

Browse files
move to planning test utils
Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent 3f3ed45 commit 66a8518

File tree

11 files changed

+77
-74
lines changed

11 files changed

+77
-74
lines changed

planning/planning_test_utils/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@ project(planning_test_utils)
44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

7+
ament_auto_add_library(route_parser SHARED
8+
src/route_parser.cpp)
9+
10+
target_link_libraries(route_parser
11+
yaml-cpp
12+
)
13+
14+
if(BUILD_TESTING)
15+
ament_add_ros_isolated_gtest(test_route_parser
16+
test/test_route_parser.cpp)
17+
18+
target_link_libraries(test_route_parser
19+
route_parser)
20+
endif()
21+
722
ament_auto_package(INSTALL_TO_SHARE
823
config
924
test_map
25+
test_data
1026
)

planning/route_handler/test/route_parser.hpp planning/planning_test_utils/include/planning_test_utils/route_parser.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef ROUTE_PARSER_HPP_
16-
#define ROUTE_PARSER_HPP_
15+
#ifndef PLANNING_TEST_UTILS__ROUTE_PARSER_HPP_
16+
#define PLANNING_TEST_UTILS__ROUTE_PARSER_HPP_
1717

1818
#include <autoware_planning_msgs/msg/lanelet_primitive.hpp>
1919
#include <autoware_planning_msgs/msg/lanelet_route.hpp>
@@ -25,7 +25,7 @@
2525
#include <string>
2626
#include <vector>
2727

28-
namespace route_handler::test
28+
namespace test_utils
2929
{
3030
using autoware_planning_msgs::msg::LaneletPrimitive;
3131
using autoware_planning_msgs::msg::LaneletRoute;
@@ -41,6 +41,6 @@ std::vector<LaneletPrimitive> parse_lanelet_primitives(const YAML::Node & node);
4141
std::vector<LaneletSegment> parse_segments(const YAML::Node & node);
4242

4343
LaneletRoute parse_route_file(const std::string & filename);
44-
} // namespace route_handler::test
44+
} // namespace test_utils
4545

46-
#endif // ROUTE_PARSER_HPP_
46+
#endif // PLANNING_TEST_UTILS__ROUTE_PARSER_HPP_

planning/route_handler/test/route_parser.cpp planning/planning_test_utils/src/route_parser.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "route_parser.hpp"
15+
#include "planning_test_utils/route_parser.hpp"
1616

1717
#include <rclcpp/logging.hpp>
1818

@@ -27,7 +27,7 @@
2727
#include <string>
2828
#include <vector>
2929

30-
namespace route_handler::test
30+
namespace test_utils
3131
{
3232
Pose parse_pose(const YAML::Node & node)
3333
{
@@ -89,4 +89,4 @@ LaneletRoute parse_route_file(const std::string & filename)
8989
}
9090
return lanelet_route;
9191
}
92-
} // namespace route_handler::test
92+
} // namespace test_utils

planning/route_handler/test/test_route_parser.cpp planning/planning_test_utils/test/test_route_parser.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
// Assuming the parseRouteFile function is in 'RouteHandler.h'
1818
#include "ament_index_cpp/get_package_share_directory.hpp"
19-
#include "route_parser.hpp"
19+
#include "planning_test_utils/route_parser.hpp"
2020

21-
namespace route_handler::test
21+
namespace test_utils
2222
{
2323
// Example YAML structure as a string for testing
2424
const char g_complete_yaml[] = R"(
@@ -94,8 +94,9 @@ TEST(ParseFunctions, CompleteYAMLTest)
9494
TEST(ParseFunction, CompleteFromFilename)
9595
{
9696
const auto planning_test_utils_dir =
97-
ament_index_cpp::get_package_share_directory("route_handler");
98-
const auto parser_test_route = planning_test_utils_dir + "/test_route/parser_test.route";
97+
ament_index_cpp::get_package_share_directory("planning_test_utils");
98+
const auto parser_test_route =
99+
planning_test_utils_dir + "/test_data/lanelet_route_parser_test.yaml";
99100

100101
const auto lanelet_route = parse_route_file(parser_test_route);
101102
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.x, 1.0);
@@ -130,4 +131,4 @@ TEST(ParseFunction, CompleteFromFilename)
130131
EXPECT_EQ(segment1.primitives[3].id, 88);
131132
EXPECT_EQ(segment1.primitives[3].primitive_type, "lane");
132133
}
133-
} // namespace route_handler::test
134+
} // namespace test_utils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
start_pose:
2+
position:
3+
x: 1.0
4+
y: 2.0
5+
z: 3.0
6+
orientation:
7+
x: 0.1
8+
y: 0.2
9+
z: 0.3
10+
w: 0.4
11+
goal_pose:
12+
position:
13+
x: 4.0
14+
y: 5.0
15+
z: 6.0
16+
orientation:
17+
x: 0.5
18+
y: 0.6
19+
z: 0.7
20+
w: 0.8
21+
segments:
22+
- preferred_primitive:
23+
id: 11
24+
primitive_type: ""
25+
primitives:
26+
- id: 22
27+
primitive_type: lane
28+
- id: 33
29+
primitive_type: lane
30+
- preferred_primitive:
31+
id: 44
32+
primitive_type: ""
33+
primitives:
34+
- id: 55
35+
primitive_type: lane
36+
- id: 66
37+
primitive_type: lane
38+
- id: 77
39+
primitive_type: lane
40+
- id: 88
41+
primitive_type: lane

planning/route_handler/CMakeLists.txt

-15
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,15 @@ ament_auto_add_library(route_handler SHARED
99
)
1010

1111
if(BUILD_TESTING)
12-
ament_auto_add_library(route_parser SHARED
13-
test/route_parser.cpp)
14-
15-
target_link_libraries(route_parser
16-
yaml-cpp
17-
)
18-
19-
ament_add_ros_isolated_gtest(test_route_parser
20-
test/test_route_parser.cpp)
21-
2212
ament_add_ros_isolated_gtest(test_route_handler
2313
test/test_route_handler.cpp)
2414

25-
target_link_libraries(test_route_parser
26-
route_parser)
27-
2815
target_link_libraries(test_route_handler
2916
route_handler
30-
route_parser
3117
)
3218

3319
endif()
3420

3521
ament_auto_package(INSTALL_TO_SHARE
36-
test_map
3722
test_route
3823
)

planning/route_handler/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<depend>autoware_planning_msgs</depend>
2828
<depend>geometry_msgs</depend>
2929
<depend>lanelet2_extension</depend>
30+
<depend>planning_test_utils</depend>
3031
<depend>rclcpp</depend>
3132
<depend>rclcpp_components</depend>
3233
<depend>tf2_ros</depend>

planning/route_handler/test/test_route_handler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "test_route_handler.hpp"
1616

17-
#include "route_parser.hpp"
17+
#include "planning_test_utils/route_parser.hpp"
1818

1919
#include <rclcpp/rclcpp.hpp>
2020

@@ -28,7 +28,7 @@ TEST_F(TestRouteHandler, isRouteHandlerReadyTest)
2828
ament_index_cpp::get_package_share_directory("route_handler");
2929
const auto rh_test_route = planning_test_utils_dir + "/test_route/rh_test.route";
3030
ASSERT_FALSE(route_handler_->isHandlerReady());
31-
route_handler_->setRoute(parse_route_file(rh_test_route));
31+
route_handler_->setRoute(test_utils::parse_route_file(rh_test_route));
3232
ASSERT_TRUE(route_handler_->isHandlerReady());
3333
}
3434

@@ -38,7 +38,7 @@ TEST_F(TestRouteHandler, checkIfIDReturned)
3838
ament_index_cpp::get_package_share_directory("route_handler");
3939
const auto rh_test_route = planning_test_utils_dir + "/test_route/rh_test.route";
4040

41-
route_handler_->setRoute(parse_route_file(rh_test_route));
41+
route_handler_->setRoute(test_utils::parse_route_file(rh_test_route));
4242
const auto lanelet = route_handler_->getLaneletsFromId(4870);
4343

4444
const auto is_in_goal_route_section = route_handler_->isInGoalRouteSection(lanelet);

planning/route_handler/test/test_route_handler.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class TestRouteHandler : public ::testing::Test
6565
static HADMapBin makeMapBinMsg()
6666
{
6767
const auto planning_test_utils_dir =
68-
ament_index_cpp::get_package_share_directory("route_handler");
69-
const auto lanelet2_path = planning_test_utils_dir + "/test_map/lanelet2_map.osm";
68+
ament_index_cpp::get_package_share_directory("planning_test_utils");
69+
const auto lanelet2_path = planning_test_utils_dir + "/test_map/2km_test.osm";
7070
double center_line_resolution = 5.0;
7171
// load map from file
7272
const auto map = loadMap(lanelet2_path);

planning/route_handler/test_route/parser_test.route

-41
This file was deleted.

0 commit comments

Comments
 (0)