I can use “ros2 run teleop_twist_keyboard teleop_twist_keyboard” to move a robot. It works very well
But I want to run by a launch file for convenience, I use the launch file as:
import os
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import TimerAction
from ament_index_python.packages import get_package_share_directory
The commands ros2 launch ... and ros2 run ... cannot be interchangeably used.
If a package does not have a launch file, then you cannot launch that program.
You can use run command to execute any executables that are available in a package.
Due to a specific dependency in teleop_twist_keyboard program that depends on inputs from the terminal, that program does not have a launch file and only a run file. This is because the mentioned dependency is not a ROS2 package and also does not have a ROS2 package. Also, ROS2 does not support inputs from the terminal, which makes it difficult to make a teleop program purely using ROS2 packages / dependencies.
There are some work-arounds to get it working purely with ROS2, but that is quite tedious and not a simple solution (as far as I know), but it is doable.
Therefore, you don’t have a launch command for teleop. Only run command.