ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Interesting finding here, this works if I use OpaqueFunction
as my on_exit
action. This will for for my needs, but I still find it odd that these other actions work but ExecuteProcess
does not.
from launch import LaunchDescription
from launch.actions import ExecuteProcess, LogInfo, OpaqueFunction
def exit_process_function(_launch_context):
"""Print something."""
print('exit_process_function() called')
def generate_launch_description():
"""Launch the thing."""
return LaunchDescription([
ExecuteProcess(
cmd=['sleep', '5'],
log_cmd=True,
sigterm_timeout='0',
sigkill_timeout='0',
on_exit=[
OpaqueFunction(
function=exit_process_function
),
LogInfo(msg='This message prints properly.')
]
)
])
Output:
✔ 14:13 ~ # ros2 launch test_package test_launch.py
[INFO] [launch]: All log files can be found below <redacted>
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [sleep-1]: process details: cmd=[sleep, 5], cwd='None', custom_env?=False
[INFO] [sleep-1]: process started with pid [21809]
[INFO] [sleep-1]: process has finished cleanly [pid 21809]
exit_process_function() called
[INFO] [launch.user]: This message prints properly.
✔ 14:13 ~ # ros2 launch test_package test_launch.py
[INFO] [launch]: All log files can be found below <redacted>
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [sleep-1]: process details: cmd=[sleep, 5], cwd='None', custom_env?=False
[INFO] [sleep-1]: process started with pid [21847]
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[ERROR] [sleep-1]: process has died [pid 21847, exit code -2, cmd 'sleep 5'].
exit_process_function() called
[INFO] [launch.user]: This message prints properly.