-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ndt_scan_matcher): remake diag (#5076)
* feat(ndt_scan_matcher): remake diag Signed-off-by: yamato-ando <Yamato ANDO> * style(pre-commit): autofix * add latest_ndt_aling_service_best_score Signed-off-by: yamato-ando <Yamato ANDO> * style(pre-commit): autofix * check nullptr Signed-off-by: yamato-ando <Yamato ANDO> * style(pre-commit): autofix * add validate_distance_from_initial_to_result Signed-off-by: yamato-ando <Yamato ANDO> * style(pre-commit): autofix * rename Signed-off-by: yamato-ando <Yamato ANDO> * style(pre-commit): autofix * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * update readme Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * [WIP] udpate Signed-off-by: Yamato Ando <[email protected]> * [WIP] udpate Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * add is_need_rebuild Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * add image Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * remove unused func Signed-off-by: Yamato Ando <[email protected]> * fix Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * update image Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * fix Signed-off-by: Yamato Ando <[email protected]> * remove unused include Signed-off-by: Yamato Ando <[email protected]> * move code Signed-off-by: Yamato Ando <[email protected]> * move code Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix FIX ME Signed-off-by: Yamato Ando <[email protected]> * update Signed-off-by: Yamato Ando <[email protected]> * remove unused func Signed-off-by: Yamato Ando <[email protected]> * [WIP] update Signed-off-by: Yamato Ando <[email protected]> * add diag for trigger node service Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * move code Signed-off-by: Yamato Ando <[email protected]> * update Signed-off-by: Yamato Ando <[email protected]> * delete unused code Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * udpate Signed-off-by: Yamato Ando <[email protected]> * delete RCLCPP message Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * update Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * rename diag Signed-off-by: Yamato Ando <[email protected]> * rename func Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * remove Transition condition to OK Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix table Signed-off-by: Yamato Ando <[email protected]> * update readme Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix order Signed-off-by: Yamato Ando <[email protected]> * fix typo Signed-off-by: Yamato Ando <[email protected]> * remove diag prefix Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix readme Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * rename diag Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * remove unused code Signed-off-by: Yamato Ando <[email protected]> * fix double free Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix typo Signed-off-by: Yamato Ando <[email protected]> * output to terminal Signed-off-by: Yamato Ando <[email protected]> * style(pre-commit): autofix * fix typo Signed-off-by: Yamato Ando <[email protected]> --------- Signed-off-by: yamato-ando <Yamato ANDO> Signed-off-by: Yamato Ando <[email protected]> Co-authored-by: yamato-ando <Yamato ANDO> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1872e9b
commit 2809a67
Showing
15 changed files
with
734 additions
and
276 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
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
localization/ndt_scan_matcher/include/ndt_scan_matcher/diagnostics_module.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,59 @@ | ||
// 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 NDT_SCAN_MATCHER__DIAGNOSTICS_MODULE_HPP_ | ||
#define NDT_SCAN_MATCHER__DIAGNOSTICS_MODULE_HPP_ | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <diagnostic_msgs/msg/diagnostic_array.hpp> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
class DiagnosticsModule | ||
{ | ||
public: | ||
DiagnosticsModule(rclcpp::Node * node, const std::string & diagnostic_name); | ||
void clear(); | ||
void addKeyValue(const diagnostic_msgs::msg::KeyValue & key_value_msg); | ||
template <typename T> | ||
void addKeyValue(const std::string & key, const T & value); | ||
void updateLevelAndMessage(const int8_t level, const std::string & message); | ||
void publish(); | ||
|
||
private: | ||
diagnostic_msgs::msg::DiagnosticArray createDiagnosticsArray() 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 DiagnosticsModule::addKeyValue(const std::string & key, const T & value) | ||
{ | ||
diagnostic_msgs::msg::KeyValue key_value; | ||
key_value.key = key; | ||
key_value.value = std::to_string(value); | ||
addKeyValue(key_value); | ||
} | ||
|
||
template <> | ||
void DiagnosticsModule::addKeyValue(const std::string & key, const std::string & value); | ||
template <> | ||
void DiagnosticsModule::addKeyValue(const std::string & key, const bool & value); | ||
|
||
#endif // NDT_SCAN_MATCHER__DIAGNOSTICS_MODULE_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
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
Binary file added
BIN
+23 KB
localization/ndt_scan_matcher/media/diagnostic_initial_pose_subscriber_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.1 KB
localization/ndt_scan_matcher/media/diagnostic_ndt_align_service_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.5 KB
...ion/ndt_scan_matcher/media/diagnostic_regularization_pose_subscriber_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+72.3 KB
localization/ndt_scan_matcher/media/diagnostic_scan_matching_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.2 KB
localization/ndt_scan_matcher/media/diagnostic_trigger_node_service_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions
104
localization/ndt_scan_matcher/src/diagnostics_module.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,104 @@ | ||
// 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. | ||
|
||
#include "ndt_scan_matcher/diagnostics_module.hpp" | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <diagnostic_msgs/msg/diagnostic_array.hpp> | ||
|
||
#include <algorithm> | ||
#include <string> | ||
|
||
DiagnosticsModule::DiagnosticsModule(rclcpp::Node * node, const std::string & diagnostic_name) | ||
: clock_(node->get_clock()) | ||
{ | ||
diagnostics_pub_ = | ||
node->create_publisher<diagnostic_msgs::msg::DiagnosticArray>("/diagnostics", 10); | ||
|
||
diagnostics_status_msg_.name = | ||
std::string(node->get_name()) + std::string(": ") + diagnostic_name; | ||
diagnostics_status_msg_.hardware_id = node->get_name(); | ||
} | ||
|
||
void DiagnosticsModule::clear() | ||
{ | ||
diagnostics_status_msg_.values.clear(); | ||
diagnostics_status_msg_.values.shrink_to_fit(); | ||
|
||
diagnostics_status_msg_.level = diagnostic_msgs::msg::DiagnosticStatus::OK; | ||
diagnostics_status_msg_.message = ""; | ||
} | ||
|
||
void DiagnosticsModule::addKeyValue(const diagnostic_msgs::msg::KeyValue & key_value_msg) | ||
{ | ||
auto it = std::find_if( | ||
std::begin(diagnostics_status_msg_.values), std::end(diagnostics_status_msg_.values), | ||
[key_value_msg](const auto & arg) { return arg.key == key_value_msg.key; }); | ||
|
||
if (it != std::cend(diagnostics_status_msg_.values)) { | ||
it->value = key_value_msg.value; | ||
} else { | ||
diagnostics_status_msg_.values.push_back(key_value_msg); | ||
} | ||
} | ||
|
||
template <> | ||
void DiagnosticsModule::addKeyValue(const std::string & key, const std::string & value) | ||
{ | ||
diagnostic_msgs::msg::KeyValue key_value; | ||
key_value.key = key; | ||
key_value.value = value; | ||
addKeyValue(key_value); | ||
} | ||
|
||
template <> | ||
void DiagnosticsModule::addKeyValue(const std::string & key, const bool & value) | ||
{ | ||
diagnostic_msgs::msg::KeyValue key_value; | ||
key_value.key = key; | ||
key_value.value = value ? "True" : "False"; | ||
addKeyValue(key_value); | ||
} | ||
|
||
void DiagnosticsModule::updateLevelAndMessage(const int8_t level, const std::string & message) | ||
{ | ||
if ((level > diagnostic_msgs::msg::DiagnosticStatus::OK)) { | ||
if (!diagnostics_status_msg_.message.empty()) { | ||
diagnostics_status_msg_.message += "; "; | ||
} | ||
diagnostics_status_msg_.message += message; | ||
} | ||
if (level > diagnostics_status_msg_.level) { | ||
diagnostics_status_msg_.level = level; | ||
} | ||
} | ||
|
||
void DiagnosticsModule::publish() | ||
{ | ||
diagnostics_pub_->publish(createDiagnosticsArray()); | ||
} | ||
|
||
diagnostic_msgs::msg::DiagnosticArray DiagnosticsModule::createDiagnosticsArray() const | ||
{ | ||
diagnostic_msgs::msg::DiagnosticArray diagnostics_msg; | ||
diagnostics_msg.header.stamp = clock_->now(); | ||
diagnostics_msg.status.push_back(diagnostics_status_msg_); | ||
|
||
if (diagnostics_msg.status.at(0).level == diagnostic_msgs::msg::DiagnosticStatus::OK) { | ||
diagnostics_msg.status.at(0).message = "OK"; | ||
} | ||
|
||
return diagnostics_msg; | ||
} |
Oops, something went wrong.