diff --git a/app/imshow/launch/imshow_launch.py b/app/imshow/launch/imshow_launch.py index 61f97d9..701dab8 100644 --- a/app/imshow/launch/imshow_launch.py +++ b/app/imshow/launch/imshow_launch.py @@ -20,6 +20,7 @@ def generate_launch_description() -> LaunchDescription: "log_level", default_value="info", choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", ) index = LaunchConfiguration("index") log_level = LaunchConfiguration("log_level") diff --git a/app/power_map/launch/power_map_launch.py b/app/power_map/launch/power_map_launch.py index 181fa7a..cc9993a 100644 --- a/app/power_map/launch/power_map_launch.py +++ b/app/power_map/launch/power_map_launch.py @@ -14,6 +14,7 @@ def generate_launch_description(): "log_level", default_value="info", choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", ) log_level = LaunchConfiguration("log_level") power_map = Node( diff --git a/app/simple_joy_app/launch/app_launch.py b/app/simple_joy_app/launch/app_launch.py index 6622bb4..46b8596 100644 --- a/app/simple_joy_app/launch/app_launch.py +++ b/app/simple_joy_app/launch/app_launch.py @@ -9,6 +9,7 @@ def generate_launch_description(): "log_level", default_value="info", choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", ) log_level = LaunchConfiguration("log_level") app = Node( diff --git a/device/camera_reader/launch/camera_reader_launch.py b/device/camera_reader/launch/camera_reader_launch.py index e6d0f50..e06005b 100644 --- a/device/camera_reader/launch/camera_reader_launch.py +++ b/device/camera_reader/launch/camera_reader_launch.py @@ -21,6 +21,13 @@ def camera_node(**kwargs: Any) -> Node: def generate_launch_description() -> LaunchDescription: index_arg = DeclareLaunchArgument("index", default_value="-1") + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") index = LaunchConfiguration("index") index_specified = PythonExpression([index, ">= 0"]) default_config_path = PathJoinSubstitution( @@ -30,13 +37,15 @@ def generate_launch_description() -> LaunchDescription: name=["camera_", index], parameters=[{"camera_id": index}], remappings=[("/device/camera_image", ["/packet/camera_image_", index])], + ros_arguments=["--log-level", log_level], condition=IfCondition(index_specified), ) unuse_index = camera_node( parameters=[default_config_path], remappings=[("/device/camera_image", "/packet/camera_image")], + ros_arguments=["--log-level", log_level], condition=UnlessCondition(index_specified), ) return LaunchDescription( - [index_arg, use_index, unuse_index], + [index_arg, log_level_arg,use_index, unuse_index], ) diff --git a/device/joystick/joystick/joystick.py b/device/joystick/joystick/joystick.py index c187124..743f774 100644 --- a/device/joystick/joystick/joystick.py +++ b/device/joystick/joystick/joystick.py @@ -12,7 +12,7 @@ def __init__(self): super().__init__("joystick") self._timer = self.create_timer(0.01, self._timer_callback) self._joy_publisher = self.create_publisher(Joy, "joystick", 10) - # TODO: ここparameterで変えられるようにしたい + # TODO : ここparameterで変えられるようにしたい self._joystick = pygame.joystick.Joystick(0) # logging name = self._joystick.get_name() diff --git a/device/joystick/launch/joystick_launch.py b/device/joystick/launch/joystick_launch.py index 5850e2a..8f7579c 100644 --- a/device/joystick/launch/joystick_launch.py +++ b/device/joystick/launch/joystick_launch.py @@ -1,15 +1,33 @@ +from typing import Any + from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node -def generate_launch_description(): - return LaunchDescription( - [ - Node( - package="joystick", - executable="joystick", - namespace="device", - remappings=[("/device/joystick", "/packet/joystick")], - ), - ], +def joystick_node(**kwargs: Any) -> Node: + kwargs["package"] = "joystick" + kwargs["executable"] = "joystick" + kwargs["namespace"] = "device" + return Node(**kwargs) + + +def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", ) + log_level = LaunchConfiguration("log_level") + + joystick = Node( + package="joystick", + executable="joystick", + namespace="device", + remappings=[("/device/joystick", "/packet/joystick")], + ros_arguments=["--log-level", log_level], + ) + + return LaunchDescription([log_level_arg, joystick]) diff --git a/device/nucleo_communicate/launch/channel_launch.py b/device/nucleo_communicate/launch/channel_launch.py index 64b0f54..2d2d39a 100644 --- a/device/nucleo_communicate/launch/channel_launch.py +++ b/device/nucleo_communicate/launch/channel_launch.py @@ -1,8 +1,17 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description(): + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") channel = Node( package="nucleo_communicate", executable="nucleo-channel", @@ -15,5 +24,6 @@ def generate_launch_description(): ("/device/power", "/packet/order/power"), ("/device/quit", "/packet/order/quit"), ], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([channel]) + return LaunchDescription([log_level_arg, channel]) diff --git a/device/nucleo_communicate_py/launch/channel_launch.py b/device/nucleo_communicate_py/launch/channel_launch.py index d61926e..cee3c96 100644 --- a/device/nucleo_communicate_py/launch/channel_launch.py +++ b/device/nucleo_communicate_py/launch/channel_launch.py @@ -1,8 +1,17 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") main = Node( package="nucleo_communicate_py", executable="channel", @@ -15,5 +24,6 @@ def generate_launch_description() -> LaunchDescription: ("/device/quit", "/packet/order/quit"), ("/device/order/power", "/packet/order/power"), ], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([main]) + return LaunchDescription([log_level_arg, main]) diff --git a/device/nucleo_communicate_py/launch/receiver_launch.py b/device/nucleo_communicate_py/launch/receiver_launch.py index 5b5952f..2704285 100644 --- a/device/nucleo_communicate_py/launch/receiver_launch.py +++ b/device/nucleo_communicate_py/launch/receiver_launch.py @@ -1,8 +1,17 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") receiver = Node( package="nucleo_communicate_py", executable="receiver", @@ -13,5 +22,6 @@ def generate_launch_description() -> LaunchDescription: ("/device/current", "/packet/sensor/current"), ("/device/voltage", "/packet/sensor/voltage"), ], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([receiver]) + return LaunchDescription([log_level_arg, receiver]) diff --git a/device/nucleo_communicate_py/launch/sender_launch.py b/device/nucleo_communicate_py/launch/sender_launch.py index 901f40f..a1951a4 100644 --- a/device/nucleo_communicate_py/launch/sender_launch.py +++ b/device/nucleo_communicate_py/launch/sender_launch.py @@ -1,8 +1,17 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") sender = Node( package="nucleo_communicate_py", executable="sender", @@ -11,5 +20,6 @@ def generate_launch_description() -> LaunchDescription: ("/device/quit", "/packet/order/quit"), ("/device/order/power", "/packet/order/power"), ], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([sender]) + return LaunchDescription([log_level_arg, sender]) diff --git a/device/pi_i2c/launch/all_launch.py b/device/pi_i2c/launch/all_launch.py index 5424f5f..0d7878f 100644 --- a/device/pi_i2c/launch/all_launch.py +++ b/device/pi_i2c/launch/all_launch.py @@ -1,12 +1,22 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") all_exec = Node( package="pi_i2c", executable="all", namespace="device", remappings=[("/device/imu", "/packet/sensors/imu")], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([all_exec]) + return LaunchDescription([log_level_arg, all_exec]) diff --git a/device/pi_i2c/launch/depth_launch.py b/device/pi_i2c/launch/depth_launch.py index f37f542..68b83a9 100644 --- a/device/pi_i2c/launch/depth_launch.py +++ b/device/pi_i2c/launch/depth_launch.py @@ -1,11 +1,21 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") depth = Node( package="pi_i2c", executable="depth", namespace="device", + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([depth]) + return LaunchDescription([log_level_arg, depth]) diff --git a/device/pi_i2c/launch/imu_launch.py b/device/pi_i2c/launch/imu_launch.py index 95564bc..3ad8942 100644 --- a/device/pi_i2c/launch/imu_launch.py +++ b/device/pi_i2c/launch/imu_launch.py @@ -1,12 +1,22 @@ from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") imu = Node( package="pi_i2c", executable="imu", namespace="device", remappings=[("/device/imu", "/packet/sensors/imu")], + ros_arguments=["--log-level", log_level], ) - return LaunchDescription([imu]) + return LaunchDescription([log_level_arg, imu]) diff --git a/device/pi_led/launch/led_launch.py b/device/pi_led/launch/led_launch.py index e812f37..6afdc5e 100644 --- a/device/pi_led/launch/led_launch.py +++ b/device/pi_led/launch/led_launch.py @@ -20,9 +20,17 @@ def led_node(**kwargs: Any) -> Node: def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_valye="info", + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log-level") # arguments variant_arg = DeclareLaunchArgument( - "variant", default_value="default", choices=["default", "right", "left", "custom"] + "variant", + default_value="default", + choices=["default", "right", "left", "custom"], ) param_file_arg = DeclareLaunchArgument("param_file", default_value="") # substitutions @@ -42,27 +50,32 @@ def generate_launch_description() -> LaunchDescription: use_default = led_node( parameters=[right_param_file], remappings=[("/device/led_color", "/packet/order/led_color")], + ros_arguments=["--log-level", log_level], condition=IfCondition(variant_is_default), ) use_right = led_node( name="led_right", parameters=[right_param_file], remappings=[("/device/led_color", "/packet/order/led_color_right")], + ros_arguments=["--log-level", log_level], condition=IfCondition(variant_is_right), ) use_left = led_node( name="led_left", parameters=[left_param_file], remappings=[("/device/led_color", "/packet/order/led_color_left")], + ros_arguments=["--log-level", log_level], condition=IfCondition(variant_is_left), ) use_custom = led_node( name="led_custom", parameters=[param_file], remappings=[("/device/led_color", "/packet/order/led_color_custom")], + ros_arguments=["--log-level", log_level], condition=IfCondition(variant_is_custom), ) return LaunchDescription( - [variant_arg, param_file_arg, use_default, use_right, use_left, use_custom] + [log_level_arg,variant_arg, param_file_arg, use_default, use_right, + use_left, use_custom] ) diff --git a/ul/launch/double_camera.py b/ul/launch/double_camera.py index fcfde1c..14912ff 100644 --- a/ul/launch/double_camera.py +++ b/ul/launch/double_camera.py @@ -1,11 +1,18 @@ from launch import LaunchDescription -from launch.actions import GroupAction, IncludeLaunchDescription +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.substitutions import FindPackageShare def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") camera0 = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -22,5 +29,11 @@ def generate_launch_description() -> LaunchDescription: ), launch_arguments=[("index", "1")], ) - cameras = GroupAction([camera0, camera1], forwarding=False) - return LaunchDescription([cameras]) + cameras = GroupAction([camera0, camera1], + forwarding=False, + launch_configurations={ + "log_level":log_level, + } + ) + + return LaunchDescription([log_level_arg, cameras]) diff --git a/ul/launch/double_imshow.py b/ul/launch/double_imshow.py index 18d70ce..0bbf3cb 100644 --- a/ul/launch/double_imshow.py +++ b/ul/launch/double_imshow.py @@ -1,11 +1,19 @@ from launch import LaunchDescription -from launch.actions import GroupAction, IncludeLaunchDescription +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.substitutions import FindPackageShare def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") + imshow0 = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -22,5 +30,10 @@ def generate_launch_description() -> LaunchDescription: ), launch_arguments=[("index", "1")], ) - imshows = GroupAction([imshow0, imshow1], forwarding=False) - return LaunchDescription([imshows]) + imshows = GroupAction([imshow0, imshow1], + forwarding=False, + launch_configurations={ + "log_level":log_level, + } + ) + return LaunchDescription([log_level_arg, imshows]) diff --git a/ul/launch/double_led.py b/ul/launch/double_led.py index 94cd291..dde86fd 100644 --- a/ul/launch/double_led.py +++ b/ul/launch/double_led.py @@ -1,11 +1,18 @@ from launch import LaunchDescription -from launch.actions import GroupAction, IncludeLaunchDescription +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.substitutions import FindPackageShare def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") led_right = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution([FindPackageShare("pi_led"), "launch", "led_launch.py"]) @@ -18,5 +25,10 @@ def generate_launch_description() -> LaunchDescription: ), launch_arguments=[("variant", "left")], ) - leds = GroupAction([led_left, led_right], forwarding=False) - return LaunchDescription([leds]) + leds = GroupAction([led_left, led_right], + forwarding=False, + launch_configurations={ + "log_level":log_level, + } + ) + return LaunchDescription([log_level_arg, leds]) diff --git a/ul/launch/nucleo_channel.py b/ul/launch/nucleo_channel.py index 6116074..d419ee2 100644 --- a/ul/launch/nucleo_channel.py +++ b/ul/launch/nucleo_channel.py @@ -1,11 +1,18 @@ from launch import LaunchDescription -from launch.actions import GroupAction, IncludeLaunchDescription +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import PathJoinSubstitution +from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.substitutions import FindPackageShare def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") channel = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( @@ -13,4 +20,9 @@ def generate_launch_description() -> LaunchDescription: ) ) ) - return LaunchDescription([GroupAction([channel], forwarding=False)]) + nodes = GroupAction( + actions=[channel], + forwarding=False, + launch_configurations={"log_level":log_level}, + ) + return LaunchDescription([log_level_arg, nodes]) diff --git a/ul/launch/pi_devices.py b/ul/launch/pi_devices.py index 251cb81..3d721b6 100644 --- a/ul/launch/pi_devices.py +++ b/ul/launch/pi_devices.py @@ -17,6 +17,13 @@ def generate_launch_description() -> LaunchDescription: # args + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + choices=["debug", "info", "warn", "error", "fatal"], + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log_level") use_nucleo_arg = DeclareLaunchArgument( "use_nucleo", default_value="true", choices=["true", "false"] ) @@ -36,7 +43,8 @@ def generate_launch_description() -> LaunchDescription: choices=["true", "false"], ) args = GroupAction( - [use_nucleo_arg, camera_variant_arg, use_led_arg, use_imu_arg], scoped=False + [log_level_arg, use_nucleo_arg, camera_variant_arg, use_led_arg, use_imu_arg], + scoped=False, ) # substitutions use_nucleo = LaunchConfiguration("use_nucleo") @@ -50,6 +58,7 @@ def generate_launch_description() -> LaunchDescription: PythonLaunchDescriptionSource( PathJoinSubstitution([FindPackageShare("ul"), "launch", "nucleo_channel.py"]) ), + launch_arguments=[("log_level", log_level)], condition=IfCondition(use_nucleo), ) single_camera = IncludeLaunchDescription( @@ -58,6 +67,7 @@ def generate_launch_description() -> LaunchDescription: [FindPackageShare("camera_reader"), "launch", "camera_reader_launch.py"] ) ), + launch_arguments=[("log_level", log_level)], condition=IfCondition(use_single_camera), ) double_camera = IncludeLaunchDescription( @@ -66,6 +76,7 @@ def generate_launch_description() -> LaunchDescription: [FindPackageShare("camera_reader"), "launch", "camera_reader_launch.py"] ) ), + launch_arguments=[("log_level", log_level)], condition=IfCondition(use_double_camera), ) led = GroupAction( @@ -76,6 +87,7 @@ def generate_launch_description() -> LaunchDescription: [FindPackageShare("ul"), "launch", "double_led.py"] ) ), + launch_arguments=[("log_level", log_level)], ), ExecuteProcess( cmd=[ @@ -106,6 +118,7 @@ def generate_launch_description() -> LaunchDescription: PythonLaunchDescriptionSource( PathJoinSubstitution([FindPackageShare("pi_i2c"), "launch", "imu_launch.py"]) ), + launch_arguments=[("log_level", log_level)], condition=IfCondition(use_imu), ) nodes = GroupAction( diff --git a/ul/launch/simple_joy_app_pc.py b/ul/launch/simple_joy_app_pc.py index 1123c5b..3c0e914 100644 --- a/ul/launch/simple_joy_app_pc.py +++ b/ul/launch/simple_joy_app_pc.py @@ -6,6 +6,12 @@ def generate_launch_description() -> LaunchDescription: + log_level_arg = DeclareLaunchArgument( + "log_level", + default_value="info", + description="Logging level for the nodes", + ) + log_level = LaunchConfiguration("log-level") power_map_param_file_arg = DeclareLaunchArgument( "power_map_param_file", default_value=PathJoinSubstitution( @@ -18,14 +24,16 @@ def generate_launch_description() -> LaunchDescription: PathJoinSubstitution( [FindPackageShare("joystick"), "launch", "joystick_launch.py"] ) - ) + ), + launch_arguments=[("log-level", log_level)], ) app = IncludeLaunchDescription( PythonLaunchDescriptionSource( PathJoinSubstitution( [FindPackageShare("simple_joy_app"), "launch", "app_launch.py"] ) - ) + ), + launch_arguments=[("log-level", log_level)], ) power_map = IncludeLaunchDescription( PythonLaunchDescriptionSource( @@ -40,4 +48,4 @@ def generate_launch_description() -> LaunchDescription: forwarding=False, launch_configurations={"param_file": power_map_param_file}, ) - return LaunchDescription([power_map_param_file_arg, nodes]) + return LaunchDescription([log_level_arg,power_map_param_file_arg, nodes])