ros / ros_tutorials

Code used in tutorials found on ROS wiki
http://wiki.ros.org/ros_tutorials
805 stars 540 forks source link

[ROS2-foxy] Cannot start turtlesim simulation and teleop nodes in one launch file #125

Closed kurshakuz closed 2 years ago

kurshakuz commented 3 years ago

Hello! I am interested in porting Introduction to tf2 tutorial to ROS2, which is based on the turtlesim package. To do so, I wanted to port old turtlesim_tf2 package, but during the process I got stuck with one issue.

For some reason, I cannot start both turtlesim turtlesim_node and turtle_teleop_key nodes in one launch file. I tried using both .launch.py and .xml formats, but both had the same behavior. I launch the script and the window with turtle appears, but the turtle_teleop_key starts only after I interrupt the launch process with keyboard.

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    ld = LaunchDescription()
    sim_node = Node(
        package="turtlesim",
        executable="turtlesim_node",
        name="sim",
    )
    teleop_node = Node(
        package="turtlesim",
        executable="turtle_teleop_key",
        name="teleop",
        output="screen",
    )
    ld.add_action(sim_node)
    ld.add_action(teleop_node)
    return ld

and

<launch>
  <node pkg="turtlesim" exec="turtlesim_node" name="sim" output="screen"/>
  <node pkg="turtlesim" exec="turtle_teleop_key" name="teleop" output="screen"/>
</launch>
kurshakuz commented 2 years ago

Apparently this is not an issue as a teleop node needs to have an access to keyboard capture and cannot be used in launch file. Closing