Skip to content

Commit

Permalink
Merge pull request #454 from pawelir/add-panther-diagnostics-config
Browse files Browse the repository at this point in the history
The panther_diagnostics reconfiguration
  • Loading branch information
KmakD authored Dec 13, 2024
2 parents 997bb1c + 4d7f8f4 commit 836d3ec
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 28 deletions.
3 changes: 2 additions & 1 deletion husarion_ugv_diagnostics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ set(ENV{PKG_CONFIG_PATH} "${CPPUPROFILE_PREFIX}/lib:$ENV{PKG_CONFIG_PATH}")

pkg_check_modules(CPPUPROFILE REQUIRED IMPORTED_TARGET cppuprofile)

generate_parameter_library(system_monitor_parameters config/system_monitor.yaml)
generate_parameter_library(system_monitor_parameters
src/system_monitor_parameters.yaml)

add_executable(system_monitor_node src/main.cpp src/system_monitor_node.cpp)
target_include_directories(system_monitor_node
Expand Down
34 changes: 8 additions & 26 deletions husarion_ugv_diagnostics/config/system_monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
system_monitor:
cpu_usage_warn_threshold:
type: double
default_value: 95.0
description: Threshold for CPU usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
cpu_temperature_warn_threshold:
type: double
default_value: 80.0
description: Threshold for CPU temperature warning in degrees Celsius.
validation: { bounds<>: [0.0, 1000.0] }
ram_usage_warn_threshold:
type: double
default_value: 95.0
description: Threshold for memory usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
disk_usage_warn_threshold:
type: double
default_value: 95.0
description: Threshold for disk usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
publish_frequency:
type: double
default_value: 5.0
description: System status publishing frequency [Hz].
validation: { bounds<>: [0.1, 10.0] }
/**:
system_monitor:
ros__parameters:
cpu_usage_warn_threshold: 95.0
cpu_temperature_warn_threshold: 80.0
ram_usage_warn_threshold: 90.0
disk_usage_warn_threshold: 90.0
publish_frequency: 5.0
22 changes: 21 additions & 1 deletion husarion_ugv_diagnostics/launch/system_monitor.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import EnvironmentVariable, LaunchConfiguration
from launch.substitutions import (
EnvironmentVariable,
LaunchConfiguration,
PathJoinSubstitution,
)
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
Expand All @@ -28,17 +33,32 @@ def generate_launch_description():
description="Add namespace to all launched nodes",
)

system_monitor_config_path = LaunchConfiguration("system_monitor_config_path")
declare_system_monitor_config_path_arg = DeclareLaunchArgument(
"system_monitor_config_path",
default_value=PathJoinSubstitution(
[
FindPackageShare("husarion_ugv_diagnostics"),
"config",
"system_monitor.yaml",
]
),
description="Specify the path to the system monitor configuration file.",
)

system_monitor_node = Node(
package="husarion_ugv_diagnostics",
executable="system_monitor_node",
name="system_monitor",
parameters=[system_monitor_config_path],
namespace=namespace,
remappings=[("/diagnostics", "diagnostics")],
emulate_tty=True,
)

actions = [
declare_namespace_arg,
declare_system_monitor_config_path_arg,
system_monitor_node,
]

Expand Down
26 changes: 26 additions & 0 deletions husarion_ugv_diagnostics/src/system_monitor_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
system_monitor:
cpu_usage_warn_threshold:
type: double
default_value: 95.0
description: Threshold for CPU usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
cpu_temperature_warn_threshold:
type: double
default_value: 80.0
description: Threshold for CPU temperature warning in degrees Celsius.
validation: { bounds<>: [0.0, 120.0] }
ram_usage_warn_threshold:
type: double
default_value: 90.0
description: Threshold for memory usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
disk_usage_warn_threshold:
type: double
default_value: 90.0
description: Threshold for disk usage warning in percentage.
validation: { bounds<>: [0.0, 100.0] }
publish_frequency:
type: double
default_value: 5.0
description: System status publishing frequency [Hz].
validation: { bounds<>: [0.1, 10.0] }

0 comments on commit 836d3ec

Please sign in to comment.