Compare commits
4
Commits
93a9f1baba
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5b36e3163 | ||
|
|
7ec72dbbdb | ||
|
|
f5adbb59a4 | ||
|
|
d1314797a5 |
No files matched your search
+37
-4
@@ -3,6 +3,8 @@ project(j7s_diagnostics_ros CXX)
|
|||||||
|
|
||||||
find_package(ament_cmake REQUIRED)
|
find_package(ament_cmake REQUIRED)
|
||||||
find_package(rclcpp REQUIRED)
|
find_package(rclcpp REQUIRED)
|
||||||
|
find_package(diagnostic_msgs REQUIRED)
|
||||||
|
find_package(fmt REQUIRED)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
@@ -14,14 +16,11 @@ FetchContent_MakeAvailable(Corrosion)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
# Rust bindings.
|
||||||
corrosion_import_crate(MANIFEST_PATH j7s_diagnostics_cxx/Cargo.toml)
|
corrosion_import_crate(MANIFEST_PATH j7s_diagnostics_cxx/Cargo.toml)
|
||||||
corrosion_add_cxxbridge(j7s_diagnostics_cxx_bridge
|
corrosion_add_cxxbridge(j7s_diagnostics_cxx_bridge
|
||||||
CRATE j7s_diagnostics_cxx
|
CRATE j7s_diagnostics_cxx
|
||||||
FILES lib.rs)
|
FILES lib.rs)
|
||||||
|
|
||||||
add_executable(test_bin src/test.cpp)
|
|
||||||
target_link_libraries(test_bin PRIVATE j7s_diagnostics_cxx_bridge j7s_diagnostics_cxx)
|
|
||||||
|
|
||||||
corrosion_install(TARGETS j7s_diagnostics_cxx
|
corrosion_install(TARGETS j7s_diagnostics_cxx
|
||||||
EXPORT export_${PROJECT_NAME}
|
EXPORT export_${PROJECT_NAME}
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
@@ -29,8 +28,42 @@ corrosion_install(TARGETS j7s_diagnostics_cxx
|
|||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The rest of the stuff.
|
||||||
|
# Note that rust/cxx doesn't support shared libraries so
|
||||||
|
# this library (and anything that uses it) will have
|
||||||
|
# to be statically linked.
|
||||||
|
add_library(conversions STATIC src/conversions.cpp)
|
||||||
|
target_include_directories(conversions PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||||
|
target_link_libraries(conversions PUBLIC
|
||||||
|
j7s_diagnostics_cxx_bridge
|
||||||
|
j7s_diagnostics_cxx
|
||||||
|
fmt
|
||||||
|
${diagnostic_msgs_TARGETS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(test_bin src/test.cpp)
|
||||||
|
target_include_directories(test_bin PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||||
|
target_link_libraries(test_bin PRIVATE
|
||||||
|
conversions
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(j7s_diagnostic_node src/j7s_diagnostic_node.cpp)
|
||||||
|
target_include_directories(j7s_diagnostic_node PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||||
|
target_link_libraries(j7s_diagnostic_node PRIVATE
|
||||||
|
conversions
|
||||||
|
rclcpp::rclcpp
|
||||||
|
)
|
||||||
|
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
|
conversions
|
||||||
test_bin
|
test_bin
|
||||||
|
j7s_diagnostic_node
|
||||||
DESTINATION lib/${PROJECT_NAME})
|
DESTINATION lib/${PROJECT_NAME})
|
||||||
|
|
||||||
ament_export_targets(export_${PROJECT_NAME})
|
ament_export_targets(export_${PROJECT_NAME})
|
||||||
|
|||||||
@@ -0,0 +1,373 @@
|
|||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
|
||||||
|
#include <diagnostic_msgs/msg/diagnostic_status.hpp>
|
||||||
|
|
||||||
|
#include "j7s_diagnostics_cxx_bridge/lib.h"
|
||||||
|
|
||||||
|
std::string convertString(const rust::String & rust);
|
||||||
|
|
||||||
|
j7s_diagnostics_cxx::DiagnosticLevel convertLevel(const uint8_t rosLevel);
|
||||||
|
|
||||||
|
uint8_t convertLevel(const j7s_diagnostics_cxx::DiagnosticLevel & level);
|
||||||
|
|
||||||
|
std::vector<diagnostic_msgs::msg::KeyValue> convertValues(
|
||||||
|
const rust::Box<j7s_diagnostics_cxx::StringMap> & map);
|
||||||
|
|
||||||
|
rust::Box<j7s_diagnostics_cxx::StringMap> convertValues(
|
||||||
|
const std::vector<diagnostic_msgs::msg::KeyValue> & map);
|
||||||
|
|
||||||
|
j7s_diagnostics_cxx::DiagnosticStatus fromMsg(const diagnostic_msgs::msg::DiagnosticStatus & msg);
|
||||||
|
|
||||||
|
diagnostic_msgs::msg::DiagnosticStatus toMsg(const j7s_diagnostics_cxx::DiagnosticStatus & status);
|
||||||
|
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> fromMsg(
|
||||||
|
const diagnostic_msgs::msg::DiagnosticArray & msg);
|
||||||
|
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> fromMsg(
|
||||||
|
const std::vector<diagnostic_msgs::msg::DiagnosticStatus> & msgs);
|
||||||
|
|
||||||
|
diagnostic_msgs::msg::DiagnosticArray toMsg(
|
||||||
|
const rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> & statuses);
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
|
||||||
|
#include <diagnostic_msgs/msg/diagnostic_status.hpp>
|
||||||
|
#include <rclcpp/rclcpp.hpp>
|
||||||
|
|
||||||
|
namespace j7s
|
||||||
|
{
|
||||||
|
class DiagnosticAggregator : public rclcpp::Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DiagnosticAggregator(const rclcpp::NodeOptions & options);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<rclcpp::Publisher<diagnostic_msgs::msg::DiagnosticArray>> m_publisher;
|
||||||
|
std::shared_ptr<rclcpp::Subscription<diagnostic_msgs::msg::DiagnosticArray>> m_subscriber;
|
||||||
|
rclcpp::TimerBase::SharedPtr m_timer;
|
||||||
|
|
||||||
|
std::vector<diagnostic_msgs::msg::DiagnosticStatus> m_queue;
|
||||||
|
};
|
||||||
|
} // namespace j7s
|
||||||
Generated
+64
-31
@@ -16,9 +16,9 @@ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.3.0"
|
version = "1.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8"
|
checksum = "a3eb0f42d6c360dc3f8a821f6bf2fdea7f72bfd36b3076eb0e6d1e9e0752fff4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex",
|
"shlex",
|
||||||
@@ -26,18 +26,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.6.2"
|
version = "4.6.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd059f9da4f5c36b3787f65d38ccaab1cc315f07b01f89abc8359ee6a8205011"
|
checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.6.2"
|
version = "4.6.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b"
|
checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
@@ -46,9 +46,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
|
checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
@@ -63,9 +63,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cxx"
|
name = "cxx"
|
||||||
version = "1.0.198"
|
version = "1.0.202"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fe442a792c7c736eea18b32a7f8a3b63cf8aafabda6760042dc2fdeda456291"
|
checksum = "13f6de320895f42e6e081abb5c7983bedcf0b6d0ff9323de0d33f620c8ac1199"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"cxx-build",
|
"cxx-build",
|
||||||
@@ -78,9 +78,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cxx-build"
|
name = "cxx-build"
|
||||||
version = "1.0.198"
|
version = "1.0.202"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e3184a94384c663718698311a78a51ac00c484c10b4eeac06fb0a068c5f64fa2"
|
checksum = "4fde53ca86b9704a943fef0f1e1d836239a6aedca5de3c65fa9f97ec0bd46d39"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
@@ -93,9 +93,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cxxbridge-cmd"
|
name = "cxxbridge-cmd"
|
||||||
version = "1.0.198"
|
version = "1.0.202"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0148d8fd1199329ddf1d157a5e134e51ceff37c6a7ddd38615c399d81cb05d8d"
|
checksum = "07bae89236c811fd4d08ed3441759ac4ac98d752cbfd3de341315ba16ad20ec3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
@@ -107,15 +107,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cxxbridge-flags"
|
name = "cxxbridge-flags"
|
||||||
version = "1.0.198"
|
version = "1.0.202"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52850339faed2eaadd24e286dc1d8268cc6f8a7bd9524d713adc9099566b4c89"
|
checksum = "49045042e5fced01b80742aba5508de82aa4f13677ed3fa2b4cda709c40c5918"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cxxbridge-macro"
|
name = "cxxbridge-macro"
|
||||||
version = "1.0.198"
|
version = "1.0.202"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2c77c856545d886c9bd5215409ebb63b925e262135248b50c79e5a5f194ee47c"
|
checksum = "b181252e2e3d3b5d183afbdc033a3958b445eb3e1a0ae65fc3d4f5259f5da6fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -131,9 +131,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "find-msvc-tools"
|
name = "find-msvc-tools"
|
||||||
version = "0.1.9"
|
version = "0.1.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foldhash"
|
name = "foldhash"
|
||||||
@@ -149,20 +149,28 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.14.0"
|
version = "2.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
|
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "j7s_diagnostics"
|
name = "j7s_diagnostics"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.jpace121.net/public/j7s_diagnostics.git?branch=main#f40b64151807cbca03a021e66cb3bf3558e4619d"
|
source = "git+ssh://git@git.jpace121.net:2222/public/j7s_diagnostics.git?branch=main#c8b5db719c0de550a22b87f88c34ac7c0489f78c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_graph",
|
"limbo_graph",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -190,6 +198,12 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.107"
|
version = "1.0.107"
|
||||||
@@ -244,6 +258,19 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.151"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"memchr",
|
||||||
|
"serde",
|
||||||
|
"serde_core",
|
||||||
|
"zmij",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@@ -258,9 +285,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "3.0.1"
|
version = "3.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5edbec4ed188954a10c12c038215f8ce7606b2d5c973cd8dc43e8795065c5f2f"
|
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -278,18 +305,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.19"
|
version = "2.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
|
checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.19"
|
version = "2.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
|
checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -298,9 +325,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.24"
|
version = "1.0.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
checksum = "ab72a15cf68d77cb0987d3684aa8a45c5ef827e8cb49ee2f30bfd7ba2feb519f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
@@ -331,3 +358,9 @@ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-link",
|
"windows-link",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zmij"
|
||||||
|
version = "1.0.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||||
@@ -9,7 +9,7 @@ crate-type = ["staticlib"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.103"
|
anyhow = "1.0.103"
|
||||||
cxx = "1.0"
|
cxx = "1.0"
|
||||||
j7s_diagnostics = { branch = "main", git="https://git.jpace121.net/public/j7s_diagnostics.git" }
|
j7s_diagnostics = { branch="main", git="ssh://git@git.jpace121.net:2222/public/j7s_diagnostics.git", features=["std"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cxx-build = "1.0"
|
cxx-build = "1.0"
|
||||||
|
|||||||
+103
-25
@@ -1,8 +1,18 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
#[cxx::bridge]
|
#[cxx::bridge(namespace = "j7s_diagnostics_cxx")]
|
||||||
mod ffi {
|
mod ffi {
|
||||||
// Shared structs whose fields can be seen in both C++ and Rust.
|
// Shared structs whose fields can be seen in both C++ and Rust.
|
||||||
#[derive(Clone, PartialOrd, PartialEq, Default)]
|
#[derive(Clone, PartialOrd, PartialEq, Default)]
|
||||||
@@ -21,13 +31,16 @@ mod ffi {
|
|||||||
name: String,
|
name: String,
|
||||||
message: String,
|
message: String,
|
||||||
hardware_id: String,
|
hardware_id: String,
|
||||||
values: Box<StringMap>
|
values: Box<StringMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "Rust" {
|
extern "Rust" {
|
||||||
// Functions in here can be seen on both sides, but are
|
// Functions in here can be seen on both sides, but are
|
||||||
// defined in rust.
|
// defined in rust.
|
||||||
// types can be seen in both languages, but only opaquely in C++.
|
// types can be seen in both languages, but only opaquely in C++.
|
||||||
|
#[Self = "DiagnosticStatus"]
|
||||||
|
fn build() -> DiagnosticStatus;
|
||||||
|
|
||||||
type OptionalString;
|
type OptionalString;
|
||||||
#[Self = "OptionalString"]
|
#[Self = "OptionalString"]
|
||||||
fn some(val: String) -> Box<OptionalString>;
|
fn some(val: String) -> Box<OptionalString>;
|
||||||
@@ -36,29 +49,81 @@ mod ffi {
|
|||||||
fn is_some(self: &OptionalString) -> bool;
|
fn is_some(self: &OptionalString) -> bool;
|
||||||
fn value(self: &OptionalString) -> Result<String>;
|
fn value(self: &OptionalString) -> Result<String>;
|
||||||
|
|
||||||
|
|
||||||
type StringMap;
|
type StringMap;
|
||||||
#[Self = "StringMap"]
|
#[Self = "StringMap"]
|
||||||
fn build() -> Box<StringMap>;
|
fn build() -> Box<StringMap>;
|
||||||
fn get(self: &StringMap, key: &String) -> Box<OptionalString>;
|
fn get(self: &StringMap, key: &String) -> Box<OptionalString>;
|
||||||
fn insert(self: &mut StringMap, key: String, value: String);
|
fn insert(self: &mut StringMap, key: String, value: String);
|
||||||
|
fn keys(self: &StringMap) -> Vec<String>;
|
||||||
|
|
||||||
type DiagnosticTree;
|
type DiagnosticTree;
|
||||||
#[Self = "DiagnosticTree"]
|
#[Self = "DiagnosticTree"]
|
||||||
fn build() -> Box<DiagnosticTree>;
|
fn build() -> Box<DiagnosticTree>;
|
||||||
fn add_statuses(self: &mut DiagnosticTree, statuses: &Vec<DiagnosticStatus>) -> Result<()> ;
|
fn add_statuses(self: &mut DiagnosticTree, statuses: &Vec<DiagnosticStatus>) -> Result<()>;
|
||||||
|
fn add_status(self: &mut DiagnosticTree, status: &DiagnosticStatus) -> Result<()>;
|
||||||
fn reconcile(self: &mut DiagnosticTree) -> Result<()>;
|
fn reconcile(self: &mut DiagnosticTree) -> Result<()>;
|
||||||
fn aggregate(self: &DiagnosticTree) -> Result<Vec<DiagnosticStatus>>;
|
fn aggregate(self: &DiagnosticTree) -> Result<Vec<DiagnosticStatus>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diagnostic_status_to_rust(cpp: &crate::ffi::DiagnosticStatus) -> j7s_diagnostics::DiagnosticStatus {
|
fn diagnostic_level_to_rust(cpp: &crate::ffi::DiagnosticLevel) -> j7s_diagnostics::DiagnosticLevel {
|
||||||
todo!()
|
match cpp {
|
||||||
|
&crate::ffi::DiagnosticLevel::UNSET => j7s_diagnostics::DiagnosticLevel::UNSET,
|
||||||
|
&crate::ffi::DiagnosticLevel::OK => j7s_diagnostics::DiagnosticLevel::OK,
|
||||||
|
&crate::ffi::DiagnosticLevel::WARN => j7s_diagnostics::DiagnosticLevel::WARN,
|
||||||
|
&crate::ffi::DiagnosticLevel::ERROR => j7s_diagnostics::DiagnosticLevel::ERROR,
|
||||||
|
&crate::ffi::DiagnosticLevel::STALE => j7s_diagnostics::DiagnosticLevel::STALE,
|
||||||
|
_ => j7s_diagnostics::DiagnosticLevel::UNSET,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diagnostic_status_from_rust(rust: &j7s_diagnostics::DiagnosticStatus) -> crate::ffi::DiagnosticStatus {
|
fn diagnostic_level_from_rust(
|
||||||
todo!()
|
rust: &j7s_diagnostics::DiagnosticLevel,
|
||||||
|
) -> crate::ffi::DiagnosticLevel {
|
||||||
|
match rust {
|
||||||
|
&j7s_diagnostics::DiagnosticLevel::UNSET => crate::ffi::DiagnosticLevel::UNSET,
|
||||||
|
&j7s_diagnostics::DiagnosticLevel::OK => crate::ffi::DiagnosticLevel::OK,
|
||||||
|
&j7s_diagnostics::DiagnosticLevel::WARN => crate::ffi::DiagnosticLevel::WARN,
|
||||||
|
&j7s_diagnostics::DiagnosticLevel::ERROR => crate::ffi::DiagnosticLevel::ERROR,
|
||||||
|
&j7s_diagnostics::DiagnosticLevel::STALE => crate::ffi::DiagnosticLevel::STALE,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn diagnostic_status_to_rust(
|
||||||
|
cpp: &crate::ffi::DiagnosticStatus,
|
||||||
|
) -> j7s_diagnostics::DiagnosticStatus {
|
||||||
|
j7s_diagnostics::DiagnosticStatus::new(
|
||||||
|
diagnostic_level_to_rust(&cpp.level),
|
||||||
|
cpp.name.clone(),
|
||||||
|
cpp.message.clone(),
|
||||||
|
cpp.hardware_id.clone(),
|
||||||
|
cpp.values.to_btree(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn diagnostic_status_from_rust(
|
||||||
|
rust: &j7s_diagnostics::DiagnosticStatus,
|
||||||
|
) -> crate::ffi::DiagnosticStatus {
|
||||||
|
crate::ffi::DiagnosticStatus {
|
||||||
|
level: diagnostic_level_from_rust(&rust.level()),
|
||||||
|
name: rust.name(),
|
||||||
|
message: rust.message(),
|
||||||
|
hardware_id: rust.hardware_id(),
|
||||||
|
values: Box::new(StringMap::from_btree(rust.values())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::ffi::DiagnosticStatus {
|
||||||
|
fn build() -> Self {
|
||||||
|
Self {
|
||||||
|
level: crate::ffi::DiagnosticLevel::default(),
|
||||||
|
name: String::default(),
|
||||||
|
message: String::default(),
|
||||||
|
hardware_id: String::default(),
|
||||||
|
values: StringMap::build(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -69,13 +134,14 @@ pub struct DiagnosticTree {
|
|||||||
impl DiagnosticTree {
|
impl DiagnosticTree {
|
||||||
pub fn build() -> Box<DiagnosticTree> {
|
pub fn build() -> Box<DiagnosticTree> {
|
||||||
let graph = j7s_diagnostics::DiagnosticGraph::new();
|
let graph = j7s_diagnostics::DiagnosticGraph::new();
|
||||||
let tree = DiagnosticTree {
|
let tree = DiagnosticTree { graph: graph };
|
||||||
graph: graph
|
|
||||||
};
|
|
||||||
Box::new(tree)
|
Box::new(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_statuses(self: &mut DiagnosticTree, statuses: &Vec<crate::ffi::DiagnosticStatus>) -> anyhow::Result<()> {
|
pub fn add_statuses(
|
||||||
|
self: &mut DiagnosticTree,
|
||||||
|
statuses: &Vec<crate::ffi::DiagnosticStatus>,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
let mut converted_statuses = Vec::new();
|
let mut converted_statuses = Vec::new();
|
||||||
for status in statuses.iter() {
|
for status in statuses.iter() {
|
||||||
converted_statuses.push(diagnostic_status_to_rust(&status));
|
converted_statuses.push(diagnostic_status_to_rust(&status));
|
||||||
@@ -83,6 +149,10 @@ impl DiagnosticTree {
|
|||||||
Ok(self.graph.add_status_vec(&converted_statuses)?)
|
Ok(self.graph.add_status_vec(&converted_statuses)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_status(self: &mut DiagnosticTree, status: &crate::ffi::DiagnosticStatus) -> anyhow::Result<()> {
|
||||||
|
Ok(self.graph.add_status(diagnostic_status_to_rust(&status))?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reconcile(self: &mut DiagnosticTree) -> anyhow::Result<()> {
|
pub fn reconcile(self: &mut DiagnosticTree) -> anyhow::Result<()> {
|
||||||
Ok(self.graph.reconcile_levels()?)
|
Ok(self.graph.reconcile_levels()?)
|
||||||
}
|
}
|
||||||
@@ -99,21 +169,17 @@ impl DiagnosticTree {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct OptionalString {
|
pub struct OptionalString {
|
||||||
val: Option<String>
|
val: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OptionalString {
|
impl OptionalString {
|
||||||
pub fn some(val: String) -> Box<Self> {
|
pub fn some(val: String) -> Box<Self> {
|
||||||
let raw = Self {
|
let raw = Self { val: Some(val) };
|
||||||
val: Some(val)
|
|
||||||
};
|
|
||||||
Box::new(raw)
|
Box::new(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn none() -> Box<Self> {
|
pub fn none() -> Box<Self> {
|
||||||
let raw = Self {
|
let raw = Self { val: None };
|
||||||
val: None
|
|
||||||
};
|
|
||||||
Box::new(raw)
|
Box::new(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,22 +197,34 @@ impl OptionalString {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StringMap {
|
pub struct StringMap {
|
||||||
map: BTreeMap<String, String>
|
map: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StringMap {
|
impl StringMap {
|
||||||
pub fn build() -> Box<Self> {
|
pub fn build() -> Box<Self> {
|
||||||
let raw = Self {
|
let raw = Self {
|
||||||
map: BTreeMap::<String, String>::new()
|
map: BTreeMap::<String, String>::new(),
|
||||||
};
|
};
|
||||||
Box::new(raw)
|
Box::new(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_btree(map: BTreeMap<String, String>) -> Self {
|
||||||
|
Self { map: map }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn keys(&self) -> Vec<String> {
|
||||||
|
self.map.keys().map(|s| s.clone()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_btree(&self) -> BTreeMap<String, String> {
|
||||||
|
self.map.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(&self, key: &String) -> Box<OptionalString> {
|
pub fn get(&self, key: &String) -> Box<OptionalString> {
|
||||||
match self.map.get(key) {
|
match self.map.get(key) {
|
||||||
None => OptionalString::none(),
|
None => OptionalString::none(),
|
||||||
Some(val) => OptionalString::some(val.clone()),
|
Some(val) => OptionalString::some(val.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert(&mut self, key: String, value: String) {
|
pub fn insert(&mut self, key: String, value: String) {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||||
|
|
||||||
|
<depend>diagnostic_msgs</depend>
|
||||||
|
|
||||||
<export>
|
<export>
|
||||||
<build_type>ament_cmake</build_type>
|
<build_type>ament_cmake</build_type>
|
||||||
</export>
|
</export>
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
|
#include <j7s_diagnostics_ros/conversions.hpp>
|
||||||
|
|
||||||
|
std::string convertString(const rust::String & rust)
|
||||||
|
{
|
||||||
|
auto copy = rust;
|
||||||
|
return std::string(copy.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
j7s_diagnostics_cxx::DiagnosticLevel convertLevel(const uint8_t rosLevel)
|
||||||
|
{
|
||||||
|
switch (rosLevel)
|
||||||
|
{
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::OK:
|
||||||
|
return j7s_diagnostics_cxx::DiagnosticLevel::OK;
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::WARN:
|
||||||
|
return j7s_diagnostics_cxx::DiagnosticLevel::WARN;
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::ERROR:
|
||||||
|
return j7s_diagnostics_cxx::DiagnosticLevel::ERROR;
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::STALE:
|
||||||
|
default:
|
||||||
|
return j7s_diagnostics_cxx::DiagnosticLevel::STALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t convertLevel(const j7s_diagnostics_cxx::DiagnosticLevel & level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case j7s_diagnostics_cxx::DiagnosticLevel::OK:
|
||||||
|
return diagnostic_msgs::msg::DiagnosticStatus::OK;
|
||||||
|
case j7s_diagnostics_cxx::DiagnosticLevel::WARN:
|
||||||
|
return diagnostic_msgs::msg::DiagnosticStatus::WARN;
|
||||||
|
case j7s_diagnostics_cxx::DiagnosticLevel::ERROR:
|
||||||
|
return diagnostic_msgs::msg::DiagnosticStatus::ERROR;
|
||||||
|
case j7s_diagnostics_cxx::DiagnosticLevel::STALE:
|
||||||
|
case j7s_diagnostics_cxx::DiagnosticLevel::UNSET:
|
||||||
|
default:
|
||||||
|
return diagnostic_msgs::msg::DiagnosticStatus::STALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<diagnostic_msgs::msg::KeyValue> convertValues(
|
||||||
|
const rust::Box<j7s_diagnostics_cxx::StringMap> & map)
|
||||||
|
{
|
||||||
|
std::vector<diagnostic_msgs::msg::KeyValue> toReturn;
|
||||||
|
|
||||||
|
const rust::Vec<rust::String> keys = map->keys();
|
||||||
|
if (keys.empty())
|
||||||
|
{
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto & key : keys)
|
||||||
|
{
|
||||||
|
const auto value = map->get(key);
|
||||||
|
diagnostic_msgs::msg::KeyValue msg;
|
||||||
|
msg.key = convertString(key);
|
||||||
|
msg.value = std::string(value->value().c_str());
|
||||||
|
toReturn.emplace_back(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
rust::Box<j7s_diagnostics_cxx::StringMap> convertValues(
|
||||||
|
const std::vector<diagnostic_msgs::msg::KeyValue> & map)
|
||||||
|
{
|
||||||
|
rust::Box<j7s_diagnostics_cxx::StringMap> toReturn = j7s_diagnostics_cxx::StringMap::build();
|
||||||
|
|
||||||
|
for (const auto & pair : map)
|
||||||
|
{
|
||||||
|
toReturn->insert(rust::String(pair.key), rust::String(pair.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
j7s_diagnostics_cxx::DiagnosticStatus fromMsg(const diagnostic_msgs::msg::DiagnosticStatus & msg)
|
||||||
|
{
|
||||||
|
auto toReturn = j7s_diagnostics_cxx::DiagnosticStatus::build();
|
||||||
|
toReturn.level = convertLevel(msg.level);
|
||||||
|
toReturn.name = rust::String(msg.name);
|
||||||
|
toReturn.message = rust::String(msg.message);
|
||||||
|
toReturn.hardware_id = rust::String(msg.hardware_id);
|
||||||
|
toReturn.values = convertValues(msg.values);
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> fromMsg(
|
||||||
|
const diagnostic_msgs::msg::DiagnosticArray & msg)
|
||||||
|
{
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> toReturn;
|
||||||
|
toReturn.reserve(msg.status.size());
|
||||||
|
|
||||||
|
for (const auto & rosMsg : msg.status)
|
||||||
|
{
|
||||||
|
toReturn.emplace_back(fromMsg(rosMsg));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> fromMsg(
|
||||||
|
const std::vector<diagnostic_msgs::msg::DiagnosticStatus> & msgs)
|
||||||
|
{
|
||||||
|
rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> toReturn;
|
||||||
|
toReturn.reserve(msgs.size());
|
||||||
|
|
||||||
|
for (const auto & rosMsg : msgs)
|
||||||
|
{
|
||||||
|
toReturn.emplace_back(fromMsg(rosMsg));
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostic_msgs::msg::DiagnosticStatus toMsg(const j7s_diagnostics_cxx::DiagnosticStatus & status)
|
||||||
|
{
|
||||||
|
diagnostic_msgs::msg::DiagnosticStatus toReturn;
|
||||||
|
toReturn.level = convertLevel(status.level);
|
||||||
|
toReturn.name = convertString(status.name);
|
||||||
|
toReturn.message = convertString(status.message);
|
||||||
|
toReturn.hardware_id = convertString(status.hardware_id);
|
||||||
|
toReturn.values = convertValues(status.values);
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostic_msgs::msg::DiagnosticArray toMsg(
|
||||||
|
const rust::Vec<j7s_diagnostics_cxx::DiagnosticStatus> & statuses)
|
||||||
|
{
|
||||||
|
diagnostic_msgs::msg::DiagnosticArray msg;
|
||||||
|
msg.status.reserve(statuses.size());
|
||||||
|
|
||||||
|
for (const auto & status : statuses)
|
||||||
|
{
|
||||||
|
msg.status.emplace_back(toMsg(status));
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
|
#include <chrono>
|
||||||
|
#include <j7s_diagnostics_ros/conversions.hpp>
|
||||||
|
#include <j7s_diagnostics_ros/j7s_diagnostic_node.hpp>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
namespace j7s
|
||||||
|
{
|
||||||
|
DiagnosticAggregator::DiagnosticAggregator(const rclcpp::NodeOptions & options) :
|
||||||
|
Node("j7s_diagnostic_agg", options)
|
||||||
|
{
|
||||||
|
m_publisher =
|
||||||
|
this->create_publisher<diagnostic_msgs::msg::DiagnosticArray>("/diagnostics_agg", 1);
|
||||||
|
m_subscriber = this->create_subscription<diagnostic_msgs::msg::DiagnosticArray>(
|
||||||
|
"/diagnostics", 1,
|
||||||
|
[this](const diagnostic_msgs::msg::DiagnosticArray & msg)
|
||||||
|
{
|
||||||
|
for (const auto status : msg.status)
|
||||||
|
{
|
||||||
|
m_queue.emplace_back(status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
m_timer = this->create_timer(
|
||||||
|
1s,
|
||||||
|
[this]()
|
||||||
|
{
|
||||||
|
const auto queueCopy = m_queue;
|
||||||
|
m_queue.clear();
|
||||||
|
|
||||||
|
auto tree = j7s_diagnostics_cxx::DiagnosticTree::build();
|
||||||
|
tree->add_statuses(fromMsg(queueCopy));
|
||||||
|
tree->reconcile();
|
||||||
|
const auto aggregate = toMsg(tree->aggregate());
|
||||||
|
m_publisher->publish(aggregate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}; // namespace j7s
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
rclcpp::init(argc, argv);
|
||||||
|
|
||||||
|
auto node = std::make_shared<j7s::DiagnosticAggregator>(rclcpp::NodeOptions());
|
||||||
|
|
||||||
|
rclcpp::spin(node);
|
||||||
|
|
||||||
|
rclcpp::shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
+56
-10
@@ -1,18 +1,64 @@
|
|||||||
#include "j7s_diagnostics_cxx_bridge/lib.h"
|
//
|
||||||
|
// Copyright 2026 James Pace
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
//
|
||||||
|
// This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
// defined by the Mozilla Public License, v. 2.0.
|
||||||
|
//
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <j7s_diagnostics_ros/conversions.hpp>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
diagnostic_msgs::msg::DiagnosticStatus make_test_status(const std::string & name, uint8_t level)
|
||||||
{
|
{
|
||||||
const auto my_string = OptionalString::some(rust::String("test"));
|
diagnostic_msgs::msg::DiagnosticStatus status;
|
||||||
if(my_string->is_some())
|
status.name = name;
|
||||||
{
|
status.level = level;
|
||||||
auto as_string = my_string->value();
|
|
||||||
std::cout << as_string.c_str() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto my_map = StringMap::build();
|
return status;
|
||||||
my_map->insert(rust::String("a"), rust::String("b"));
|
}
|
||||||
|
|
||||||
|
std::string levelToString(uint8_t level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::OK:
|
||||||
|
return "OK";
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::WARN:
|
||||||
|
return "WARN";
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::ERROR:
|
||||||
|
return "ERROR";
|
||||||
|
case diagnostic_msgs::msg::DiagnosticStatus::STALE:
|
||||||
|
return "STALE";
|
||||||
|
default:
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
diagnostic_msgs::msg::DiagnosticArray diagArray;
|
||||||
|
diagArray.status.emplace_back(
|
||||||
|
make_test_status("a", diagnostic_msgs::msg::DiagnosticStatus::OK));
|
||||||
|
diagArray.status.emplace_back(
|
||||||
|
make_test_status("a/b", diagnostic_msgs::msg::DiagnosticStatus::WARN));
|
||||||
|
diagArray.status.emplace_back(
|
||||||
|
make_test_status("a/c", diagnostic_msgs::msg::DiagnosticStatus::OK));
|
||||||
|
diagArray.status.emplace_back(
|
||||||
|
make_test_status("a/c/d", diagnostic_msgs::msg::DiagnosticStatus::OK));
|
||||||
|
|
||||||
|
auto tree = j7s_diagnostics_cxx::DiagnosticTree::build();
|
||||||
|
tree->add_statuses(fromMsg(diagArray));
|
||||||
|
tree->reconcile();
|
||||||
|
const auto aggregate = toMsg(tree->aggregate());
|
||||||
|
for (const auto & status : aggregate.status)
|
||||||
|
{
|
||||||
|
fmt::println("Name: {} Level: {}", status.name, levelToString(status.level));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user