This commit is contained in:
acki
2025-05-29 08:50:57 -04:00
parent ed7770bc3f
commit ccf06397e5
2 changed files with 20 additions and 16 deletions

View File

@@ -30,9 +30,10 @@ def generate_launch_description():
with_com = LaunchConfiguration('with_com') with_com = LaunchConfiguration('with_com')
with_strat = LaunchConfiguration('with_strat') with_strat = LaunchConfiguration('with_strat')
def launch_rplidar_restart_if_needed(context, *args, **kwargs): def launch_rplidar_restart_if_needed(context, *args, **kwargs):
if context.launch_configurations.get('with_rplidar') == 'true': if context.launch_configurations.get('with_rplidar') == 'true':
rplidar_node = Node( def create_rplidar_node():
return Node(
package='rplidar_ros', package='rplidar_ros',
executable='rplidar_node', executable='rplidar_node',
name='rplidar_node', name='rplidar_node',
@@ -47,19 +48,22 @@ def generate_launch_description():
output='screen' output='screen'
) )
restart_handler = RegisterEventHandler( rplidar_node = create_rplidar_node()
OnProcessExit(
target_action=rplidar_node, restart_handler = RegisterEventHandler(
on_exit=[ OnProcessExit(
TimerAction( target_action=rplidar_node,
period=5.0, # Delay before restarting (in seconds) on_exit=[
actions=[rplidar_node] # Restart the rplidar_node TimerAction(
) period=5.0,
] actions=[create_rplidar_node()] # ✅ créer un NOUVEAU Node
) )
]
) )
return [rplidar_node, restart_handler] )
return []
return [rplidar_node, restart_handler]
return []
# Function to launch GUI and shutdown handler # Function to launch GUI and shutdown handler

View File

@@ -9,7 +9,7 @@
<min_move_threshold_mm>50</min_move_threshold_mm> <min_move_threshold_mm>50</min_move_threshold_mm>
<refresh_rate>0.5</refresh_rate> <refresh_rate>0.5</refresh_rate>
<max_stationary_time_s>5</max_stationary_time_s> <max_stationary_time_s>5</max_stationary_time_s>
<min_emergency_distance_mm>500</min_emergency_distance_mm> <min_emergency_distance_mm>50</min_emergency_distance_mm>
<margin_detection_table_mm>50</margin_detection_table_mm> <margin_detection_table_mm>50</margin_detection_table_mm>
</detection> </detection>
<factor_close_enemy>-0.3</factor_close_enemy> <factor_close_enemy>-0.3</factor_close_enemy>