-
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.
Merge branch 'main' into feat/move-autoware-utils-tf
- Loading branch information
Showing
10 changed files
with
191 additions
and
45 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
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,19 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(autoware_utils_diagnostics) | ||
|
||
find_package(autoware_cmake REQUIRED) | ||
autoware_package() | ||
|
||
ament_auto_add_library(${PROJECT_NAME} SHARED | ||
"src/diagnostics_interface.cpp" | ||
) | ||
|
||
if(BUILD_TESTING) | ||
ament_add_ros_isolated_gtest(test_${PROJECT_NAME} | ||
"test/main.cpp" | ||
"test/cases/diagnostics_interface.cpp" | ||
) | ||
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME}) | ||
endif() | ||
|
||
ament_auto_package() |
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,11 @@ | ||
# autoware_utils_diagnostics | ||
|
||
## Overview | ||
|
||
The **autoware_utils** library is a comprehensive toolkit designed to facilitate the development of autonomous driving applications. | ||
This package provides essential utilities for diagnostics. | ||
It is extensively used in the Autoware project to handle common tasks such as handling diagnostic tasks. | ||
|
||
## Design | ||
|
||
- **`diagnostics_interface.hpp`**: An interface for publishing diagnostic messages. |
61 changes: 61 additions & 0 deletions
61
autoware_utils_diagnostics/include/autoware_utils_diagnostics/diagnostics_interface.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2023 Autoware Foundation | ||
// | ||
// 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. | ||
|
||
#ifndef AUTOWARE_UTILS_DIAGNOSTICS__DIAGNOSTICS_INTERFACE_HPP_ | ||
#define AUTOWARE_UTILS_DIAGNOSTICS__DIAGNOSTICS_INTERFACE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <diagnostic_msgs/msg/diagnostic_array.hpp> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace autoware_utils_diagnostics | ||
{ | ||
class DiagnosticsInterface | ||
{ | ||
public: | ||
DiagnosticsInterface(rclcpp::Node * node, const std::string & diagnostic_name); | ||
void clear(); | ||
void add_key_value(const diagnostic_msgs::msg::KeyValue & key_value_msg); | ||
template <typename T> | ||
void add_key_value(const std::string & key, const T & value); | ||
void add_key_value(const std::string & key, const std::string & value); | ||
void add_key_value(const std::string & key, bool value); | ||
void update_level_and_message(const int8_t level, const std::string & message); | ||
void publish(const rclcpp::Time & publish_time_stamp); | ||
|
||
private: | ||
[[nodiscard]] diagnostic_msgs::msg::DiagnosticArray create_diagnostics_array( | ||
const rclcpp::Time & publish_time_stamp) const; | ||
|
||
rclcpp::Clock::SharedPtr clock_; | ||
rclcpp::Publisher<diagnostic_msgs::msg::DiagnosticArray>::SharedPtr diagnostics_pub_; | ||
|
||
diagnostic_msgs::msg::DiagnosticStatus diagnostics_status_msg_; | ||
}; | ||
|
||
template <typename T> | ||
void DiagnosticsInterface::add_key_value(const std::string & key, const T & value) | ||
{ | ||
diagnostic_msgs::msg::KeyValue key_value; | ||
key_value.key = key; | ||
key_value.value = std::to_string(value); | ||
add_key_value(key_value); | ||
} | ||
|
||
} // namespace autoware_utils_diagnostics | ||
|
||
#endif // AUTOWARE_UTILS_DIAGNOSTICS__DIAGNOSTICS_INTERFACE_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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>autoware_utils_diagnostics</name> | ||
<version>1.1.0</version> | ||
<description>The autoware_utils_diagnostics package</description> | ||
<maintainer email="egon.kang@autocore.ai">Jian Kang</maintainer> | ||
<maintainer email="ryohsuke.mitsudome@tier4.jp">Ryohsuke Mitsudome</maintainer> | ||
<maintainer email="esteve.fernandez@tier4.jp">Esteve Fernandez</maintainer> | ||
<maintainer email="yutaka.kondo@tier4.jp">Yutaka Kondo</maintainer> | ||
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
<buildtool_depend>autoware_cmake</buildtool_depend> | ||
|
||
<depend>diagnostic_msgs</depend> | ||
<depend>rclcpp</depend> | ||
|
||
<test_depend>ament_cmake_ros</test_depend> | ||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>autoware_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
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
25 changes: 25 additions & 0 deletions
25
autoware_utils_diagnostics/test/cases/diagnostics_interface.cpp
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,25 @@ | ||
// 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_diagnostics/diagnostics_interface.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
|
||
TEST(TestDiagnosticsInterface, Instantiation) | ||
{ | ||
const auto node = std::make_shared<rclcpp::Node>("test_node"); | ||
autoware_utils_diagnostics::DiagnosticsInterface(node.get(), "diag_name"); | ||
} |
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,36 @@ | ||
// 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 <rclcpp/rclcpp.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
class RclcppEnvironment : public testing::Environment | ||
{ | ||
public: | ||
RclcppEnvironment(int argc, char ** argv) : argc(argc), argv(argv) {} | ||
void SetUp() override { rclcpp::init(argc, argv); } | ||
void TearDown() override { rclcpp::shutdown(); } | ||
|
||
private: | ||
int argc; | ||
char ** argv; | ||
}; | ||
|
||
int main(int argc, char ** argv) | ||
{ | ||
testing::InitGoogleTest(&argc, argv); | ||
testing::AddGlobalTestEnvironment(new RclcppEnvironment(argc, argv)); | ||
return RUN_ALL_TESTS(); | ||
} |