diff --git a/husarion_ugv_diagnostics/CMakeLists.txt b/husarion_ugv_diagnostics/CMakeLists.txt index 64b9751d5..ae00f60c7 100644 --- a/husarion_ugv_diagnostics/CMakeLists.txt +++ b/husarion_ugv_diagnostics/CMakeLists.txt @@ -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 diff --git a/husarion_ugv_diagnostics/config/system_monitor.yaml b/husarion_ugv_diagnostics/config/system_monitor.yaml index 7253eea5b..32efc9e2f 100644 --- a/husarion_ugv_diagnostics/config/system_monitor.yaml +++ b/husarion_ugv_diagnostics/config/system_monitor.yaml @@ -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 diff --git a/husarion_ugv_diagnostics/launch/system_monitor.launch.py b/husarion_ugv_diagnostics/launch/system_monitor.launch.py index 34a82815f..6bba1d6c0 100644 --- a/husarion_ugv_diagnostics/launch/system_monitor.launch.py +++ b/husarion_ugv_diagnostics/launch/system_monitor.launch.py @@ -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(): @@ -28,10 +33,24 @@ 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, @@ -39,6 +58,7 @@ def generate_launch_description(): actions = [ declare_namespace_arg, + declare_system_monitor_config_path_arg, system_monitor_node, ] diff --git a/husarion_ugv_diagnostics/src/system_monitor_parameters.yaml b/husarion_ugv_diagnostics/src/system_monitor_parameters.yaml new file mode 100644 index 000000000..e84528dd8 --- /dev/null +++ b/husarion_ugv_diagnostics/src/system_monitor_parameters.yaml @@ -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] }