-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
- Loading branch information
1 parent
5827423
commit 9d3e172
Showing
5 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# autoware_utils_testing | ||
|
||
## Notice | ||
|
||
**This package is under construction. All interfaces currently provided are unstable.** | ||
|
||
## Overview | ||
|
||
The **autoware_utils** library is a comprehensive toolkit designed to facilitate the development of autonomous driving applications. | ||
This package provides essential utilities for visualization. | ||
It is extensively used in the Autoware project to handle common tasks such as creating markers for RViz. | ||
This package provides essential utilities for testing. | ||
It is extensively used in the Autoware project to handle common tasks such as handling executor and mock node. | ||
|
||
## Design | ||
## Usage Example | ||
|
||
- **`marker_helper.hpp`**: Helper functions for creating and manipulating visualization markers. | ||
- See [test/main.cpp](./test/main.cpp) | ||
- `gtest/ros_env.hpp` | ||
- See [test/cases/mock_node.cpp](./test/cases/mock_node.cpp) | ||
- `mock_node.hpp` | ||
- `spin_thread.hpp` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2025 The Autoware Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <autoware_utils_testing/mock_node.hpp> | ||
#include <autoware_utils_testing/spin_thread.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <std_msgs/msg/int32.hpp> | ||
#include <std_msgs/msg/string.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
#include <thread> | ||
|
||
TEST(TestDebugPublisher, Main) | ||
{ | ||
const auto mock = std::make_shared<autoware_utils_testing::MockNode>("mock_node"); | ||
const auto node = std::make_shared<rclcpp::Node>("test_node"); | ||
|
||
auto pub1 = node->create_publisher<std_msgs::msg::Int32>("/test/foo", rclcpp::QoS(1)); | ||
auto pub2 = node->create_publisher<std_msgs::msg::String>("/test/bar", rclcpp::QoS(1)); | ||
auto sub1 = mock->sub<std_msgs::msg::Int32>("/test/foo", rclcpp::QoS(1)); | ||
auto sub2 = mock->sub<std_msgs::msg::String>("/test/bar", rclcpp::QoS(1)); | ||
|
||
autoware_utils_testing::SpinThread thread; | ||
thread.add_node(mock); | ||
thread.add_node(node); | ||
thread.start(); | ||
pub1->publish(std_msgs::build<std_msgs::msg::Int32>().data(123)); | ||
pub2->publish(std_msgs::build<std_msgs::msg::String>().data("hello")); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
pub1->publish(std_msgs::build<std_msgs::msg::Int32>().data(456)); | ||
pub2->publish(std_msgs::build<std_msgs::msg::String>().data("world")); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
thread.stop(); | ||
|
||
EXPECT_EQ(sub1->data.size(), 2); | ||
EXPECT_EQ(sub1->data[0].data, 123); | ||
EXPECT_EQ(sub1->data[1].data, 456); | ||
|
||
EXPECT_EQ(sub2->data.size(), 2); | ||
EXPECT_EQ(sub2->data[0].data, "hello"); | ||
EXPECT_EQ(sub2->data[1].data, "world"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters