Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log_level #62

Merged
merged 21 commits into from
Nov 28, 2024
2 changes: 1 addition & 1 deletion device/joystick/joystick/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
37 changes: 27 additions & 10 deletions device/joystick/launch/joystick_launch.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
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"],
)
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])
11 changes: 10 additions & 1 deletion device/nucleo_communicate/launch/channel_launch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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"],
)
log_level = LaunchConfiguration("log_level")
channel = Node(
package="nucleo_communicate",
executable="nucleo-channel",
Expand All @@ -15,5 +23,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])
11 changes: 10 additions & 1 deletion device/nucleo_communicate_py/launch/channel_launch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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"],
)
log_level = LaunchConfiguration("log_level")
main = Node(
package="nucleo_communicate_py",
executable="channel",
Expand All @@ -15,5 +23,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])
11 changes: 10 additions & 1 deletion device/nucleo_communicate_py/launch/receiver_launch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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"],
)
log_level = LaunchConfiguration("log_level")
receiver = Node(
package="nucleo_communicate_py",
executable="receiver",
Expand All @@ -13,5 +21,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])
11 changes: 10 additions & 1 deletion device/nucleo_communicate_py/launch/sender_launch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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"],
)
log_level = LaunchConfiguration("log_level")
sender = Node(
package="nucleo_communicate_py",
executable="sender",
Expand All @@ -11,5 +19,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])
11 changes: 10 additions & 1 deletion device/pi_i2c/launch/all_launch.py
Original file line number Diff line number Diff line change
@@ -1,12 +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"],
)
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])
11 changes: 10 additions & 1 deletion device/pi_i2c/launch/depth_launch.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
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"],
)
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])
11 changes: 10 additions & 1 deletion device/pi_i2c/launch/imu_launch.py
Original file line number Diff line number Diff line change
@@ -1,12 +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"],
)
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])
4 changes: 3 additions & 1 deletion device/pi_led/launch/led_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def led_node(**kwargs: Any) -> Node:
def generate_launch_description() -> LaunchDescription:
# 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
Expand Down
17 changes: 12 additions & 5 deletions ul/launch/double_camera.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
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(
[FindPackageShare("camera_reader"), "launch", "camera_reader_launch.py"]
)
),
launch_arguments=[("index", "0")],
launch_arguments=[("index", "0"), ("log_level", log_level)],
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

やっぱりこれだけだと通りません
launch_configurationsを設定する必要があります、記述例↓

launch_configurations={"param_file": power_map_param_file},

他のIncludeLaunchDescriptionを使っているところもこれをやる必要があるんですが、GroupActionの引数に設定する必要があるので気をつけてください

camera1 = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[FindPackageShare("camera_reader"), "launch", "camera_reader_launch.py"]
)
),
launch_arguments=[("index", "1")],
launch_arguments=[("index", "1"), ("log_level", log_level)],
)
cameras = GroupAction([camera0, camera1], forwarding=False)
return LaunchDescription([cameras])
return LaunchDescription([log_level_arg, cameras])
18 changes: 13 additions & 5 deletions ul/launch/double_imshow.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
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(
[FindPackageShare("imshow"), "launch", "imshow_launch.py"]
)
),
launch_arguments=[("index", "0")],
launch_arguments=[("index", "0"), ("log_level", log_level)],
)
imshow1 = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution(
[FindPackageShare("imshow"), "launch", "imshow_launch.py"]
)
),
launch_arguments=[("index", "1")],
launch_arguments=[("index", "1"), ("log_level", log_level)],
)
imshows = GroupAction([imshow0, imshow1], forwarding=False)
return LaunchDescription([imshows])
return LaunchDescription([log_level_arg, imshows])
17 changes: 12 additions & 5 deletions ul/launch/double_led.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
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",
H1rono marked this conversation as resolved.
Show resolved Hide resolved
)
log_level = LaunchConfiguration("log_level")
led_right = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([FindPackageShare("pi_led"), "launch", "led_launch.py"])
),
launch_arguments=[("variant", "right")],
launch_arguments=[("variant", "right"), ("log_level", log_level)],
)
led_left = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([FindPackageShare("pi_led"), "launch", "led_launch.py"])
),
launch_arguments=[("variant", "left")],
launch_arguments=[("variant", "left"), ("log_level", log_level)],
)
leds = GroupAction([led_left, led_right], forwarding=False)
return LaunchDescription([leds])
return LaunchDescription([log_level_arg, leds])
16 changes: 12 additions & 4 deletions ul/launch/nucleo_channel.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
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(
[FindPackageShare("nucleo_communicate"), "launch", "channel_launch.py"]
)
)
),
launch_arguments=[("log_level", log_level)],
)
return LaunchDescription([GroupAction([channel], forwarding=False)])
return LaunchDescription([log_level_arg, GroupAction([channel], forwarding=False)])
Loading