Skip to content

Commit

Permalink
Apply same behavior to independent launch file
Browse files Browse the repository at this point in the history
  • Loading branch information
Samahu committed Sep 9, 2023
1 parent ba8382e commit d246c3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ouster-ros/launch/driver.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import launch
import lifecycle_msgs.msg
from ament_index_python.packages import get_package_share_directory
from launch_ros.actions import Node, LifecycleNode
from launch_ros.actions import LifecycleNode
from launch.actions import (DeclareLaunchArgument, IncludeLaunchDescription,
RegisterEventHandler, EmitEvent, LogInfo)
from launch.conditions import IfCondition
Expand Down
2 changes: 1 addition & 1 deletion ouster-ros/launch/sensor.composite.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
import launch
from ament_index_python.packages import get_package_share_directory
from launch_ros.actions import Node, ComposableNodeContainer
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
from launch.actions import (DeclareLaunchArgument, IncludeLaunchDescription,
ExecuteProcess, TimerAction)
Expand Down
27 changes: 13 additions & 14 deletions ouster-ros/launch/sensor.independent.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,18 @@ def generate_launch_description():
)
)

# TODO: figure out why registering for on_shutdown event causes an exception
# and error handling
# shutdown_event = RegisterEventHandler(
# OnShutdown(
# on_shutdown=[
# EmitEvent(event=ChangeState(
# lifecycle_node_matcher=matches_node_name(node_name=F"/ouster/os_sensor"),
# transition_id=lifecycle_msgs.msg.Transition.TRANSITION_ACTIVE_SHUTDOWN,
# )),
# LogInfo(msg="os_sensor node exiting..."),
# ],
# )
# )
sensor_finalized_event = RegisterEventHandler(
OnStateTransition(
target_lifecycle_node=os_sensor, goal_state='finalized',
entities=[
LogInfo(
msg="Failed to communicate with the sensor in a timely manner."),
EmitEvent(event=launch.events.Shutdown(
reason="Couldn't communicate with sensor"))
],
)
)


os_cloud = Node(
package='ouster_ros',
Expand Down Expand Up @@ -118,5 +117,5 @@ def generate_launch_description():
os_image,
sensor_configure_event,
sensor_activate_event,
# shutdown_event
sensor_finalized_event
])

0 comments on commit d246c3d

Please sign in to comment.