Skip to content

Commit

Permalink
Adapted ruff formetter
Browse files Browse the repository at this point in the history
  • Loading branch information
KuraZuzu committed Nov 20, 2024
1 parent 2c1d411 commit 0c851db
Show file tree
Hide file tree
Showing 8 changed files with 272 additions and 197 deletions.
103 changes: 51 additions & 52 deletions launch/camera_line_follower.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,71 @@

def generate_launch_description():
declare_mouse = DeclareLaunchArgument(
'mouse',
default_value="true",
description='Launch raspimouse node'
'mouse', default_value='true', description='Launch raspimouse node'
)
declare_use_camera_node = DeclareLaunchArgument(
'use_camera_node',
default_value='true',
description='Use camera node.'
'use_camera_node', default_value='true', description='Use camera node.'
)
declare_video_device = DeclareLaunchArgument(
'video_device',
default_value='/dev/video0',
description='Set video device.'
'video_device', default_value='/dev/video0', description='Set video device.'
)

"""Generate launch description with multiple components."""
container = ComposableNodeContainer(
name='camera_line_follower_container',
namespace='',
package='rclcpp_components',
executable='component_container_mt',
composable_node_descriptions=[
ComposableNode(
package='raspimouse_ros2_examples',
plugin='camera_line_follower::CameraFollower',
name='camera_follower',
extra_arguments=[{'use_intra_process_comms': True}]),
ComposableNode(
package='raspimouse',
plugin='raspimouse::Raspimouse',
name='raspimouse',
parameters=[{'use_light_sensors': False}],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('mouse'))),
ComposableNode(
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam',
remappings=[('image_raw', 'camera/color/image_raw')],
parameters=[
{'video_device': LaunchConfiguration('video_device')},
{'frame_id': 'camera_color_optical_frame'},
{'pixel_format': 'yuyv2rgb'},
{'image_width': 320},
{'image_height': 240},
{'auto_white_balance': False},
{'autoexposure': False}
],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('use_camera_node'))),
],
output='screen',
name='camera_line_follower_container',
namespace='',
package='rclcpp_components',
executable='component_container_mt',
composable_node_descriptions=[
ComposableNode(
package='raspimouse_ros2_examples',
plugin='camera_line_follower::CameraFollower',
name='camera_follower',
extra_arguments=[{'use_intra_process_comms': True}],
),
ComposableNode(
package='raspimouse',
plugin='raspimouse::Raspimouse',
name='raspimouse',
parameters=[{'use_light_sensors': False}],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('mouse')),
),
ComposableNode(
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam',
remappings=[('image_raw', 'camera/color/image_raw')],
parameters=[
{'video_device': LaunchConfiguration('video_device')},
{'frame_id': 'camera_color_optical_frame'},
{'pixel_format': 'yuyv2rgb'},
{'image_width': 320},
{'image_height': 240},
{'auto_white_balance': False},
{'autoexposure': False},
],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('use_camera_node')),
),
],
output='screen',
)

manager = Node(
name='manager',
package='raspimouse_ros2_examples',
executable='lifecycle_node_manager',
output='screen',
parameters=[{'components': ['raspimouse', 'camera_follower']}]
parameters=[{'components': ['raspimouse', 'camera_follower']}],
)

return launch.LaunchDescription([
declare_mouse,
declare_use_camera_node,
declare_video_device,
container,
manager
])
return launch.LaunchDescription(
[
declare_mouse,
declare_use_camera_node,
declare_video_device,
container,
manager,
]
)
25 changes: 18 additions & 7 deletions launch/direction_controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,29 @@
def generate_launch_description():
"""Generate launch description with multiple components."""
mouse_node = LifecycleNode(
name='raspimouse', namespace="",
name='raspimouse',
namespace='',
package='raspimouse',
executable='raspimouse',
output='screen',
parameters=[{'use_light_sensors': False, }]
parameters=[
{
'use_light_sensors': False,
}
],
)

imu_driver = LifecycleNode(
name='rt_usb_9axisimu_driver', namespace="",
name='rt_usb_9axisimu_driver',
namespace='',
package='rt_usb_9axisimu_driver',
executable='rt_usb_9axisimu_driver',
output='screen',
parameters=[{'port': '/dev/ttyACM0', }]
parameters=[
{
'port': '/dev/ttyACM0',
}
],
)

direction_controller = Node(
Expand All @@ -46,8 +56,9 @@ def generate_launch_description():
package='raspimouse_ros2_examples',
executable='lifecycle_node_manager',
output='screen',
parameters=[{'components': ['raspimouse', 'rt_usb_9axisimu_driver']}]
parameters=[{'components': ['raspimouse', 'rt_usb_9axisimu_driver']}],
)

return launch.LaunchDescription([
mouse_node, imu_driver, direction_controller, manager])
return launch.LaunchDescription(
[mouse_node, imu_driver, direction_controller, manager]
)
4 changes: 2 additions & 2 deletions launch/line_follower.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def generate_launch_description():
package='raspimouse_ros2_examples',
executable='line_follower',
output='screen',
parameters=[{'use_pulse_counters': False}]
parameters=[{'use_pulse_counters': False}],
)

manager = Node(
name='manager',
package='raspimouse_ros2_examples',
executable='lifecycle_node_manager',
output='screen',
parameters=[{'components': ['raspimouse', 'follower']}]
parameters=[{'components': ['raspimouse', 'follower']}],
)

return launch.LaunchDescription([line_follower, manager])
39 changes: 27 additions & 12 deletions launch/mouse_with_lidar.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,40 @@

def generate_launch_description():
declare_lidar = DeclareLaunchArgument(
'lidar', default_value='lds',
description='LiDAR: lds only, for now.'
'lidar', default_value='lds', description='LiDAR: lds only, for now.'
)

mouse_node = LifecycleNode(
name='raspimouse', namespace="",
package='raspimouse', executable='raspimouse', output='screen',
parameters=[os.path.join(get_package_share_directory(
'raspimouse_ros2_examples'), 'config', 'mouse.yml')]
name='raspimouse',
namespace='',
package='raspimouse',
executable='raspimouse',
output='screen',
parameters=[
os.path.join(
get_package_share_directory('raspimouse_ros2_examples'),
'config',
'mouse.yml',
)
],
)

def func_launch_lidar_node(context):
if context.launch_configurations['lidar'] == 'lds':
return [IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(
get_package_share_directory('hls_lfcd_lds_driver'),
'launch'),
'/hlds_laser.launch.py'
]),)]
return [
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
os.path.join(
get_package_share_directory('hls_lfcd_lds_driver'),
'launch',
),
'/hlds_laser.launch.py',
]
),
)
]

launch_lidar_node = OpaqueFunction(function=func_launch_lidar_node)

ld = LaunchDescription()
Expand Down
95 changes: 47 additions & 48 deletions launch/object_tracking.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,67 @@

def generate_launch_description():
declare_mouse = DeclareLaunchArgument(
'mouse',
default_value="true",
description='Launch raspimouse node'
'mouse', default_value='true', description='Launch raspimouse node'
)
declare_use_camera_node = DeclareLaunchArgument(
'use_camera_node',
default_value='true',
description='Use camera node.'
'use_camera_node', default_value='true', description='Use camera node.'
)
declare_video_device = DeclareLaunchArgument(
'video_device',
default_value='/dev/video0',
description='Set video device.'
'video_device', default_value='/dev/video0', description='Set video device.'
)

"""Generate launch description with multiple components."""
container = ComposableNodeContainer(
name='object_tracking_container',
namespace='',
package='rclcpp_components',
executable='component_container_mt',
composable_node_descriptions=[
ComposableNode(
package='raspimouse_ros2_examples',
plugin='object_tracking::Tracker',
name='tracker',
extra_arguments=[{'use_intra_process_comms': True}]),
ComposableNode(
package='raspimouse',
plugin='raspimouse::Raspimouse',
name='raspimouse',
parameters=[{'use_light_sensors': False}],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('mouse'))),
ComposableNode(
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam',
remappings=[('image_raw', 'camera/color/image_raw')],
parameters=[
{'video_device': LaunchConfiguration('video_device')},
{'frame_id': 'camera_color_optical_frame'},
{'pixel_format': 'yuyv2rgb'}
],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('use_camera_node'))),
],
output='screen',
name='object_tracking_container',
namespace='',
package='rclcpp_components',
executable='component_container_mt',
composable_node_descriptions=[
ComposableNode(
package='raspimouse_ros2_examples',
plugin='object_tracking::Tracker',
name='tracker',
extra_arguments=[{'use_intra_process_comms': True}],
),
ComposableNode(
package='raspimouse',
plugin='raspimouse::Raspimouse',
name='raspimouse',
parameters=[{'use_light_sensors': False}],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('mouse')),
),
ComposableNode(
package='usb_cam',
plugin='usb_cam::UsbCamNode',
name='usb_cam',
remappings=[('image_raw', 'camera/color/image_raw')],
parameters=[
{'video_device': LaunchConfiguration('video_device')},
{'frame_id': 'camera_color_optical_frame'},
{'pixel_format': 'yuyv2rgb'},
],
extra_arguments=[{'use_intra_process_comms': True}],
condition=IfCondition(LaunchConfiguration('use_camera_node')),
),
],
output='screen',
)

manager = Node(
name='manager',
package='raspimouse_ros2_examples',
executable='lifecycle_node_manager',
output='screen',
parameters=[{'components': ['raspimouse', 'tracker']}]
parameters=[{'components': ['raspimouse', 'tracker']}],
)

return launch.LaunchDescription([
declare_mouse,
declare_use_camera_node,
declare_video_device,
container,
manager
])
return launch.LaunchDescription(
[
declare_mouse,
declare_use_camera_node,
declare_video_device,
container,
manager,
]
)
19 changes: 11 additions & 8 deletions launch/slam.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,32 @@

def generate_launch_description():
slam_node = Node(
package='slam_toolbox', executable='sync_slam_toolbox_node',
package='slam_toolbox',
executable='sync_slam_toolbox_node',
output='screen',
parameters=[
get_package_share_directory(
'raspimouse_ros2_examples')
get_package_share_directory('raspimouse_ros2_examples')
+ '/config/mapper_params_offline.yaml'
],
)

rviz2_node = Node(
name='rviz2',
package='rviz2', executable='rviz2', output='screen',
package='rviz2',
executable='rviz2',
output='screen',
arguments=[
'-d',
get_package_share_directory('raspimouse_ros2_examples')
+ '/config/default.rviz'],
+ '/config/default.rviz',
],
)

static_transform_publisher_node = Node(
package='tf2_ros',
executable='static_transform_publisher', output='screen',
arguments=['0', '0', '0.1', '0', '3.14',
'3.14', 'base_footprint', 'laser'],
executable='static_transform_publisher',
output='screen',
arguments=['0', '0', '0.1', '0', '3.14', '3.14', 'base_footprint', 'laser'],
)

ld = LaunchDescription()
Expand Down
Loading

0 comments on commit 0c851db

Please sign in to comment.