-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(planning_evaluator,control_evaluator, evaluator utils): add diag…
…nostics subscriber to planning eval (#7849) * add utils and diagnostics subscription to planning_evaluator Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> * add diagnostics eval Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> * fix input diag in launch Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> --------- Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com> Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> Co-authored-by: kosuke55 <kosuke.tnp@gmail.com>
- Loading branch information
1 parent
5e5ad0b
commit 6dc805e
Showing
12 changed files
with
225 additions
and
55 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,13 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(autoware_evaluator_utils) | ||
|
||
find_package(autoware_cmake REQUIRED) | ||
autoware_package() | ||
|
||
ament_auto_add_library(evaluator_utils SHARED | ||
src/evaluator_utils.cpp | ||
) | ||
|
||
ament_auto_package( | ||
INSTALL_TO_SHARE | ||
) |
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,5 @@ | ||
# Evaluator Utils | ||
|
||
## Purpose | ||
|
||
This package provides utils functions for other evaluator packages |
45 changes: 45 additions & 0 deletions
45
evaluator/autoware_evaluator_utils/include/autoware/evaluator_utils/evaluator_utils.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,45 @@ | ||
// Copyright 2024 Tier IV, Inc. | ||
// | ||
// 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__EVALUATOR_UTILS__EVALUATOR_UTILS_HPP_ | ||
#define AUTOWARE__EVALUATOR_UTILS__EVALUATOR_UTILS_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <diagnostic_msgs/msg/diagnostic_array.hpp> | ||
|
||
#include <deque> | ||
#include <optional> | ||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace autoware::evaluator_utils | ||
{ | ||
|
||
using diagnostic_msgs::msg::DiagnosticArray; | ||
using diagnostic_msgs::msg::DiagnosticStatus; | ||
using DiagnosticQueue = std::deque<std::pair<DiagnosticStatus, rclcpp::Time>>; | ||
|
||
void removeOldDiagnostics(const rclcpp::Time & stamp, DiagnosticQueue & diag_queue); | ||
void removeDiagnosticsByName(const std::string & name, DiagnosticQueue & diag_queue); | ||
void addDiagnostic( | ||
const DiagnosticStatus & diag, const rclcpp::Time & stamp, DiagnosticQueue & diag_queue); | ||
void updateDiagnosticQueue( | ||
const DiagnosticArray & input_diagnostics, const std::string & function, | ||
const rclcpp::Time & stamp, DiagnosticQueue & diag_queue); | ||
|
||
} // namespace autoware::evaluator_utils | ||
|
||
#endif // AUTOWARE__EVALUATOR_UTILS__EVALUATOR_UTILS_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,24 @@ | ||
<?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_evaluator_utils</name> | ||
<version>0.1.0</version> | ||
<description>ROS 2 node for evaluating control</description> | ||
<maintainer email="daniel.sanchez@tier4.jp">Daniel SANCHEZ</maintainer> | ||
<maintainer email="takayuki.murooka@tier4.jp">Takayuki MUROOKA</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<author email="daniel.sanchez@tier4.jp">Daniel SANCHEZ</author> | ||
<author email="takayuki.murooka@tier4.jp">Takayuki MUROOKA</author> | ||
|
||
<buildtool_depend>ament_cmake_auto</buildtool_depend> | ||
<buildtool_depend>autoware_cmake</buildtool_depend> | ||
|
||
<depend>diagnostic_msgs</depend> | ||
<depend>rclcpp</depend> | ||
<depend>rclcpp_components</depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
66 changes: 66 additions & 0 deletions
66
evaluator/autoware_evaluator_utils/src/evaluator_utils.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,66 @@ | ||
// Copyright 2024 Tier IV, Inc. | ||
// | ||
// 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/evaluator_utils/evaluator_utils.hpp" | ||
|
||
#include <algorithm> | ||
|
||
namespace autoware::evaluator_utils | ||
{ | ||
void removeOldDiagnostics(const rclcpp::Time & stamp, DiagnosticQueue & diag_queue) | ||
{ | ||
constexpr double KEEP_TIME = 1.0; | ||
diag_queue.erase( | ||
std::remove_if( | ||
diag_queue.begin(), diag_queue.end(), | ||
[stamp](const std::pair<DiagnosticStatus, rclcpp::Time> & p) { | ||
return (stamp - p.second).seconds() > KEEP_TIME; | ||
}), | ||
diag_queue.end()); | ||
} | ||
|
||
void removeDiagnosticsByName(const std::string & name, DiagnosticQueue & diag_queue) | ||
{ | ||
diag_queue.erase( | ||
std::remove_if( | ||
diag_queue.begin(), diag_queue.end(), | ||
[&name](const std::pair<DiagnosticStatus, rclcpp::Time> & p) { | ||
return p.first.name.find(name) != std::string::npos; | ||
}), | ||
diag_queue.end()); | ||
} | ||
|
||
void addDiagnostic( | ||
const DiagnosticStatus & diag, const rclcpp::Time & stamp, DiagnosticQueue & diag_queue) | ||
{ | ||
diag_queue.push_back(std::make_pair(diag, stamp)); | ||
} | ||
|
||
void updateDiagnosticQueue( | ||
const DiagnosticArray & input_diagnostics, const std::string & function, | ||
const rclcpp::Time & stamp, DiagnosticQueue & diag_queue) | ||
{ | ||
const auto it = std::find_if( | ||
input_diagnostics.status.begin(), input_diagnostics.status.end(), | ||
[&function](const DiagnosticStatus & diag) { | ||
return diag.name.find(function) != std::string::npos; | ||
}); | ||
if (it != input_diagnostics.status.end()) { | ||
removeDiagnosticsByName(it->name, diag_queue); | ||
addDiagnostic(*it, input_diagnostics.header.stamp, diag_queue); | ||
} | ||
|
||
removeOldDiagnostics(stamp, diag_queue); | ||
} | ||
} // namespace autoware::evaluator_utils |
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
Oops, something went wrong.