Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Ignored lifecycle state Event/EventHandler in launch file #1303

Open
2 of 4 tasks
NickLaurenson-Visionick opened this issue Nov 16, 2024 · 0 comments
Open
2 of 4 tasks
Labels
bug Something isn't working

Comments

@NickLaurenson-Visionick

(Please add appropriate labels)

  • Windows: (Version)
  • Linux: (Dist/Version)
  • ROS 1: Dist
  • ROS 2: Dist

<Version of the plugin>
v0.9.2

<Copy the Version information from the Help | About menu>
Version: 1.95.3
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Linux x64 6.8.0-48-generic snap

what is the bug

When debugging in the case of a ros Lifecycle node, I want to activate my node from a lauch file, via launch.actions.EmitEvent and launch_ros.events.lifecycle.ChangeState, but it look like the EmitEvent is not done. Event if I change the state manually via ros2 lifecycle <node_name> <state>, the EventHandler of the launch file do not work.

Minimal example launch example:

from launch.actions import Shutdown
from launch_ros.actions import LifecycleNode
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, EmitEvent, RegisterEventHandler, LogInfo
from launch_ros.event_handlers import OnStateTransition
from launch_ros.events.lifecycle import ChangeState
import launch
from lifecycle_msgs.msg import Transition


def generate_launch_description():
    node = LifecycleNode(package='lifecycle', executable='lifecycle_talker',
                         name='lc_talker', namespace='', output='screen')
    # THIS DO NOT WORK in Launch Debugging
    configure_event = EmitEvent(
        event=ChangeState(
            lifecycle_node_matcher=launch.events.matches_action(
                node),
            transition_id=Transition.TRANSITION_CONFIGURE,
        ))
    # THIS DO NOT WORK in Launch Debugging
    state_handler = RegisterEventHandler(
        OnStateTransition(
            target_lifecycle_node=node,
            goal_state='inactive',
            entities=[
                # Log
                LogInfo(
                    msg="RegisterEventHandler worked")]))
    return LaunchDescription([
        configure_event, node, state_handler
        # Node(package='lifecycle', executable='lifecycle_listener', output='screen'),
        # Node(package='lifecycle', executable='lifecycle_service_client', output='screen',
        #      on_exit=Shutdown()),

My final goal is perfrom something similar to this example.. But all the lifecycle node state dependencies doesn't seem to be handle correctly in the debugger.

Repro steps

<how to reproduce the bug. Please attach sample files or github repo if appropriate.>
I made a minimal example using the ros lifecycle demo code, only modifying the launch file:

  1. clone this repo
  2. compile the lifecycle package
  3. launch debugin on the lauch package

expected behavior

<what you would expect to happen>
The behavior should be similar as when the launch file is run without debugger :

  • signal are emitted
  • handler are called
  • and in the proivided example, we should have the LogInfo message

additional context

<any additional information would be helpful for a better understanding>

@NickLaurenson-Visionick NickLaurenson-Visionick added the bug Something isn't working label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant