Skip to content

Commit

Permalink
Merge branch 'main' into feat/sensing_point_type
Browse files Browse the repository at this point in the history
  • Loading branch information
badai-nguyen authored Jun 14, 2024
2 parents 1c5c9f0 + 7bc9ae0 commit c62f167
Show file tree
Hide file tree
Showing 1,168 changed files with 9,499 additions and 10,393 deletions.
92 changes: 51 additions & 41 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions .github/workflows/build-and-test-differential-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ jobs:
container: ghcr.io/autowarefoundation/autoware:latest-prebuilt
build-depends-repos: build_depends.repos
steps:
- name: Check out repository
- name: Set PR fetch depth
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"

- name: Checkout PR branch and all PR commits
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Show disk space before the tasks
run: df -h
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build-and-test-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ jobs:
container: ghcr.io/autowarefoundation/autoware:latest-prebuilt
build-depends-repos: build_depends.repos
steps:
- name: Check out repository
- name: Set PR fetch depth
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"

- name: Checkout PR branch and all PR commits
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Show disk space before the tasks
run: df -h
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/clang-tidy-differential.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
label: tag:run-clang-tidy-differential

clang-tidy-differential:
needs: prevent-no-label-execution
if: ${{ needs.prevent-no-label-execution.outputs.run == 'true' }}
runs-on: ubuntu-latest
container: ghcr.io/autowarefoundation/autoware:latest-prebuilt-cuda
steps:
Expand Down
1 change: 1 addition & 0 deletions common/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nav:
- 'Testing Libraries':
- 'autoware_testing': common/autoware_testing/design/autoware_testing-design
- 'fake_test_node': common/fake_test_node/design/fake_test_node-design
- 'Test Utils': common/autoware_test_utils
- 'Common Libraries':
- 'autoware_auto_common':
- 'comparisons': common/autoware_auto_common/design/comparisons
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.14)
project(planning_test_utils)
project(autoware_test_utils)

find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_library(planning_test_utils SHARED
src/planning_test_utils.cpp)
ament_auto_add_library(autoware_test_utils SHARED
src/autoware_test_utils.cpp)

ament_auto_add_library(mock_data_parser SHARED
src/mock_data_parser.cpp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The objective of the `test_utils` is to develop a unit testing library for the A

## Available Maps

The following maps are available [here](https://github.com/autowarefoundation/autoware.universe/tree/main/planning/planning_test_utils/test_map)
The following maps are available [here](https://github.com/autowarefoundation/autoware.universe/tree/main/planning/autoware_test_utils/test_map)

### Common

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PLANNING_TEST_UTILS__PLANNING_TEST_UTILS_HPP_
#define PLANNING_TEST_UTILS__PLANNING_TEST_UTILS_HPP_

#include "ament_index_cpp/get_package_share_directory.hpp"
#include "rclcpp/rclcpp.hpp"
#ifndef AUTOWARE_TEST_UTILS__AUTOWARE_TEST_UTILS_HPP_
#define AUTOWARE_TEST_UTILS__AUTOWARE_TEST_UTILS_HPP_

#include <component_interface_specs/planning.hpp>
#include <lanelet2_extension/io/autoware_osm_parser.hpp>
Expand Down Expand Up @@ -51,10 +48,9 @@
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace test_utils
namespace autoware::test_utils
{
using autoware_adapi_v1_msgs::msg::OperationModeState;
using autoware_map_msgs::msg::LaneletMapBin;
Expand Down Expand Up @@ -174,6 +170,45 @@ LaneletRoute makeNormalRoute();
*/
OccupancyGrid makeCostMapMsg(size_t width = 150, size_t height = 150, double resolution = 0.2);

/**
* @brief Get the absolute path to the lanelet map file.
*
* This function retrieves the absolute path to a lanelet map file located in the
* package's share directory under the "test_map" folder.
*
* @param package_name The name of the package containing the map file.
* @param map_filename The name of the map file.
* @return A string representing the absolute path to the lanelet map file.
*/
std::string get_absolute_path_to_lanelet_map(
const std::string & package_name, const std::string & map_filename);

/**
* @brief Get the absolute path to the route file.
*
* This function retrieves the absolute path to a route file located in the
* package's share directory under the "test_route" folder.
*
* @param package_name The name of the package containing the route file.
* @param route_filename The name of the route file.
* @return A string representing the absolute path to the route file.
*/
std::string get_absolute_path_to_route(
const std::string & package_name, const std::string & route_filename);

/**
* @brief Get the absolute path to the config file.
*
* This function retrieves the absolute path to a route file located in the
* package's share directory under the "config" folder.
*
* @param package_name The name of the package containing the route file.
* @param route_filename The name of the config file.
* @return A string representing the absolute path to the config file.
*/
std::string get_absolute_path_to_config(
const std::string & package_name, const std::string & config_filename);

/**
* @brief Creates a LaneletMapBin message from a Lanelet map file.
*
Expand All @@ -191,7 +226,7 @@ LaneletMapBin make_map_bin_msg(
* @brief Creates a LaneletMapBin message using a predefined Lanelet2 map file.
*
* This function loads a lanelet2_map.osm from the test_map folder in the
* planning_test_utils package, overwrites the centerline with a resolution of 5.0,
* autoware_test_utils package, overwrites the centerline with a resolution of 5.0,
* and converts the map to a LaneletMapBin message.
*
* @return A LaneletMapBin message containing the map data.
Expand Down Expand Up @@ -299,7 +334,7 @@ void updateNodeOptions(
* @brief Loads a PathWithLaneId message from a YAML file.
*
* This function loads a PathWithLaneId message from a YAML file located in the
* planning_test_utils package.
* autoware_test_utils package.
*
* @return A PathWithLaneId message containing the loaded data.
*/
Expand Down Expand Up @@ -468,15 +503,15 @@ void publishToTargetNode(
throw std::runtime_error(std::string("Topic name for ") + typeid(data).name() + " is empty");
}

test_utils::setPublisher<T>(test_node, topic_name, publisher);
autoware::test_utils::setPublisher<T>(test_node, topic_name, publisher);
publisher->publish(data);

if (target_node->count_subscribers(topic_name) == 0) {
throw std::runtime_error("No subscriber for " + topic_name);
}
test_utils::spinSomeNodes(test_node, target_node, repeat_count);
autoware::test_utils::spinSomeNodes(test_node, target_node, repeat_count);
}

} // namespace test_utils
} // namespace autoware::test_utils

#endif // PLANNING_TEST_UTILS__PLANNING_TEST_UTILS_HPP_
#endif // AUTOWARE_TEST_UTILS__AUTOWARE_TEST_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PLANNING_TEST_UTILS__MOCK_DATA_PARSER_HPP_
#define PLANNING_TEST_UTILS__MOCK_DATA_PARSER_HPP_
#ifndef AUTOWARE_TEST_UTILS__MOCK_DATA_PARSER_HPP_
#define AUTOWARE_TEST_UTILS__MOCK_DATA_PARSER_HPP_

#include <autoware_planning_msgs/msg/lanelet_primitive.hpp>
#include <autoware_planning_msgs/msg/lanelet_route.hpp>
Expand All @@ -25,7 +25,7 @@
#include <string>
#include <vector>

namespace test_utils
namespace autoware::test_utils
{
using autoware_planning_msgs::msg::LaneletPrimitive;
using autoware_planning_msgs::msg::LaneletRoute;
Expand All @@ -41,6 +41,6 @@ std::vector<LaneletPrimitive> parse_lanelet_primitives(const YAML::Node & node);
std::vector<LaneletSegment> parse_segments(const YAML::Node & node);

LaneletRoute parse_lanelet_route_file(const std::string & filename);
} // namespace test_utils
} // namespace autoware::test_utils

#endif // PLANNING_TEST_UTILS__MOCK_DATA_PARSER_HPP_
#endif // AUTOWARE_TEST_UTILS__MOCK_DATA_PARSER_HPP_
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>planning_test_utils</name>
<name>autoware_test_utils</name>
<version>0.1.0</version>
<description>ROS 2 node for testing interface of the nodes in planning module</description>
<maintainer email="[email protected]">Kyoichi Sugahara</maintainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "planning_test_utils/planning_test_utils.hpp"
namespace test_utils
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <autoware_test_utils/autoware_test_utils.hpp>
#include <rclcpp/clock.hpp>
#include <rclcpp/executors/single_threaded_executor.hpp>
#include <rclcpp/logging.hpp>
#include <rclcpp/node.hpp>

#include <utility>

namespace autoware::test_utils
{

geometry_msgs::msg::Pose createPose(
Expand Down Expand Up @@ -103,6 +111,27 @@ OccupancyGrid makeCostMapMsg(size_t width, size_t height, double resolution)
return costmap_msg;
}

std::string get_absolute_path_to_lanelet_map(
const std::string & package_name, const std::string & map_filename)
{
const auto dir = ament_index_cpp::get_package_share_directory(package_name);
return dir + "/test_map/" + map_filename;
}

std::string get_absolute_path_to_route(
const std::string & package_name, const std::string & route_filename)
{
const auto dir = ament_index_cpp::get_package_share_directory(package_name);
return dir + "/test_route/" + route_filename;
}

std::string get_absolute_path_to_config(
const std::string & package_name, const std::string & config_filename)
{
const auto dir = ament_index_cpp::get_package_share_directory(package_name);
return dir + "/config/" + config_filename;
}

LaneletMapBin make_map_bin_msg(
const std::string & absolute_path, const double center_line_resolution)
{
Expand All @@ -122,12 +151,8 @@ LaneletMapBin make_map_bin_msg(

LaneletMapBin makeMapBinMsg()
{
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");
const auto lanelet2_path = planning_test_utils_dir + "/test_map/lanelet2_map.osm";
double center_line_resolution = 5.0;

return make_map_bin_msg(lanelet2_path, center_line_resolution);
return make_map_bin_msg(
get_absolute_path_to_lanelet_map("autoware_test_utils", "lanelet2_map.osm"));
}

Odometry makeOdometry(const double shift)
Expand All @@ -147,7 +172,7 @@ Odometry makeInitialPose(const double shift)
const auto shift_y = shift * std::cos(yaw);
const std::array<double, 4> start_pose{
3722.16015625 + shift_x, 73723.515625 + shift_y, 0.233112560494183, yaw};
current_odometry.pose.pose = test_utils::createPose(start_pose);
current_odometry.pose.pose = autoware::test_utils::createPose(start_pose);
current_odometry.header.frame_id = "map";
return current_odometry;
}
Expand Down Expand Up @@ -251,9 +276,8 @@ void updateNodeOptions(

PathWithLaneId loadPathWithLaneIdInYaml()
{
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");
const auto yaml_path = planning_test_utils_dir + "/config/path_with_lane_id_data.yaml";
const auto yaml_path =
get_absolute_path_to_config("autoware_test_utils", "path_with_lane_id_data.yaml");
YAML::Node yaml_node = YAML::LoadFile(yaml_path);
PathWithLaneId path_msg;

Expand Down Expand Up @@ -311,4 +335,4 @@ PathWithLaneId loadPathWithLaneIdInYaml()
return path_msg;
}

} // namespace test_utils
} // namespace autoware::test_utils
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "planning_test_utils/mock_data_parser.hpp"
#include "autoware_test_utils/mock_data_parser.hpp"

#include <rclcpp/logging.hpp>

Expand All @@ -27,7 +27,7 @@
#include <string>
#include <vector>

namespace test_utils
namespace autoware::test_utils
{
Pose parse_pose(const YAML::Node & node)
{
Expand Down Expand Up @@ -85,8 +85,8 @@ LaneletRoute parse_lanelet_route_file(const std::string & filename)
lanelet_route.goal_pose = (config["goal_pose"]) ? parse_pose(config["goal_pose"]) : Pose();
lanelet_route.segments = parse_segments(config["segments"]);
} catch (const std::exception & e) {
RCLCPP_DEBUG(rclcpp::get_logger("planning_test_utils"), "Exception caught: %s", e.what());
RCLCPP_DEBUG(rclcpp::get_logger("autoware_test_utils"), "Exception caught: %s", e.what());
}
return lanelet_route;
}
} // namespace test_utils
} // namespace autoware::test_utils
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

// Assuming the parseRouteFile function is in 'RouteHandler.h'
#include "ament_index_cpp/get_package_share_directory.hpp"
#include "planning_test_utils/mock_data_parser.hpp"
#include "autoware_test_utils/mock_data_parser.hpp"

namespace test_utils
namespace autoware::test_utils
{
// Example YAML structure as a string for testing
const char g_complete_yaml[] = R"(
Expand Down Expand Up @@ -94,10 +94,10 @@ TEST(ParseFunctions, CompleteYAMLTest)

TEST(ParseFunction, CompleteFromFilename)
{
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");
const auto autoware_test_utils_dir =
ament_index_cpp::get_package_share_directory("autoware_test_utils");
const auto parser_test_route =
planning_test_utils_dir + "/test_data/lanelet_route_parser_test.yaml";
autoware_test_utils_dir + "/test_data/lanelet_route_parser_test.yaml";

const auto lanelet_route = parse_lanelet_route_file(parser_test_route);
EXPECT_DOUBLE_EQ(lanelet_route.start_pose.position.x, 1.0);
Expand Down Expand Up @@ -132,4 +132,4 @@ TEST(ParseFunction, CompleteFromFilename)
EXPECT_EQ(segment1.primitives[3].id, 88);
EXPECT_EQ(segment1.primitives[3].primitive_type, "lane");
}
} // namespace test_utils
} // namespace autoware::test_utils
Loading

0 comments on commit c62f167

Please sign in to comment.