Skip to content

Commit

Permalink
make camera and pixel format configurable in launch file
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Aug 4, 2024
1 parent cc43ae1 commit ce18594
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions launch/camera.launch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from launch.actions import DeclareLaunchArgument
from launch.launch_description import LaunchDescription
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
Expand All @@ -13,6 +15,32 @@ def generate_launch_description() -> LaunchDescription:
LaunchDescription: the launch description
"""
# parameters
camera_param_name = "camera"
camera_param_default = str(0)
camera_param = LaunchConfiguration(
camera_param_name,
default=camera_param_default,
)
camera_launch_arg = DeclareLaunchArgument(
camera_param_name,
default_value=camera_param_default,
description="camera ID or name"
)

format_param_name = "format"
format_param_default = str()
format_param = LaunchConfiguration(
format_param_name,
default=format_param_default,
)
format_launch_arg = DeclareLaunchArgument(
format_param_name,
default_value=format_param_default,
description="pixel format"
)

# composable nodes in single container
container = ComposableNodeContainer(
name='camera_container',
namespace='',
Expand All @@ -23,9 +51,10 @@ def generate_launch_description() -> LaunchDescription:
package='camera_ros',
plugin='camera::CameraNode',
parameters=[{
"camera": 0,
"camera": camera_param,
"width": 640,
"height": 480,
"format": format_param,
}],
extra_arguments=[{'use_intra_process_comms': True}],
),
Expand All @@ -38,4 +67,8 @@ def generate_launch_description() -> LaunchDescription:
],
)

return LaunchDescription([container])
return LaunchDescription([
container,
camera_launch_arg,
format_launch_arg,
])

0 comments on commit ce18594

Please sign in to comment.