Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .devcontainer/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ elif [ -n "$BASH_VERSION" ]; then
source ~/.bashrc 2>/dev/null || true
fi

# Initialize rosdep
sudo rosdep init
# Initialize rosdep if not already initialized
if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
sudo rosdep init
fi
rosdep update

# Test installations
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
pull_request:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up ROS 2 Jazzy
uses: ros-tooling/[email protected]
with:
required-ros-distributions: jazzy

- name: Install dependencies
run: |
sudo apt-get update
rosdep update
rosdep install --from-paths src --ignore-src -r -y

- name: Build packages
run: |
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

- name: Run tests
run: |
source /opt/ros/jazzy/setup.bash
source install/setup.bash
colcon test --return-code-on-test-failure

- name: Show test results
if: always()
run: |
colcon test-result --verbose
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ros2_diag_tree

[![CI](https://github.com/bburda/ros2_diag_tree/actions/workflows/ci.yml/badge.svg)](https://github.com/bburda/ros2_diag_tree/actions/workflows/ci.yml)

Modern, SOVD-compatible diagnostics for ROS 2 robots, built around an entity tree
(Area / Component / Function / App) for runtime discovery, health modeling, and troubleshooting.

Expand Down Expand Up @@ -31,6 +33,32 @@ so the same concepts can be used across robots, vehicles, and other embedded sys
- Health state modeled per Area / Component / Function / App
- Better remote troubleshooting and fleet-level observability for ROS 2 robots

## Development

### Installing Dependencies

```bash
rosdep install --from-paths src --ignore-src -r -y
```

### Building

```bash
colcon build --symlink-install
```

### Testing

```bash
colcon test
colcon test-result --verbose
```

### CI/CD

All pull requests are automatically built and tested using GitHub Actions.
The CI workflow runs on Ubuntu 24.04 with ROS 2 Jazzy.

## Contributing

Contributions and early feedback are welcome! Please read [`CONTRIBUTING.md`](CONTRIBUTING.md) for guidelines.
Expand Down
28 changes: 7 additions & 21 deletions src/ros2_diag_tree_gateway/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,16 @@ endif()
# Find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(nlohmann_json REQUIRED)

# Add dependencies via FetchContent
include(FetchContent)

# httplib
fetchcontent_declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.14.3
)

# nlohmann/json
fetchcontent_declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)

fetchcontent_makeavailable(httplib json)
# Find cpp-httplib using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(cpp_httplib REQUIRED IMPORTED_TARGET cpp-httplib)

# Gateway node executable
add_executable(gateway_node src/gateway_node.cpp)
ament_target_dependencies(gateway_node rclcpp)
target_link_libraries(gateway_node httplib::httplib nlohmann_json::nlohmann_json)
target_link_libraries(gateway_node PkgConfig::cpp_httplib nlohmann_json::nlohmann_json)
target_include_directories(gateway_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
Expand All @@ -44,14 +30,14 @@ install(TARGETS gateway_node
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# Exclude uncrustify since we use clang-format
set(ament_cmake_uncrustify_FOUND TRUE)
list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify)
ament_lint_auto_find_test_dependencies()

# Add GTest
find_package(ament_cmake_gtest REQUIRED)

ament_add_gtest(test_gateway_node test/test_gateway_node.cpp)
target_link_libraries(test_gateway_node httplib::httplib nlohmann_json::nlohmann_json)
target_link_libraries(test_gateway_node PkgConfig::cpp_httplib nlohmann_json::nlohmann_json)
ament_target_dependencies(test_gateway_node rclcpp)
endif()

Expand Down
2 changes: 2 additions & 0 deletions src/ros2_diag_tree_gateway/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>nlohmann-json-dev</depend>
<depend>libcpp-httplib-dev</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
6 changes: 3 additions & 3 deletions src/ros2_diag_tree_gateway/src/gateway_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <memory>
#include <thread>

#include <httplib.h> // NOLINT(build/include_order)
#include <httplib.h> // NOLINT(build/include_order)
#include <nlohmann/json.hpp>
#include <rclcpp/rclcpp.hpp>

Expand Down Expand Up @@ -62,7 +62,7 @@ class GatewayNode : public rclcpp::Node {
// Health endpoint
http_server_->Get(
"/health", [this](const httplib::Request &req, httplib::Response &res) {
(void)req; // Unused parameter
(void)req; // Unused parameter

nlohmann::json health_json = {{"status", "ok"},
{"node", node_name_},
Expand All @@ -75,7 +75,7 @@ class GatewayNode : public rclcpp::Node {
// Root endpoint
http_server_->Get(
"/", [this](const httplib::Request &req, httplib::Response &res) {
(void)req; // Unused parameter
(void)req; // Unused parameter

nlohmann::json info_json = {
{"service", "ros2_diag_tree_gateway"},
Expand Down
2 changes: 1 addition & 1 deletion src/ros2_diag_tree_gateway/test/test_gateway_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <memory>
#include <thread>

#include <httplib.h> // NOLINT(build/include_order)
#include <httplib.h> // NOLINT(build/include_order)
#include <nlohmann/json.hpp>
#include <rclcpp/rclcpp.hpp>

Expand Down