cps_rmp220_support/launch/robot_joystick.launch.py

87 lines
3.2 KiB
Python
Raw Normal View History

2023-07-28 09:07:50 +00:00
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration, Command, FindExecutable, PathJoinSubstitution
from launch.actions import DeclareLaunchArgument
from launch_ros.substitutions import FindPackageShare
from launch_ros.descriptions import ParameterValue
from launch_ros.actions import LifecycleNode
import os
from ament_index_python.packages import get_package_share_directory
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time')
2023-08-04 09:23:38 +00:00
# joy_params = os.path.join(get_package_share_directory('cps_rmp220_support'),'config','joystick.yaml')
# namespace = "/rmp"
# joy_node = Node(
# package='joy',
# executable='joy_node',
# parameters=[joy_params, {'use_sim_time': use_sim_time}],
# namespace = namespace
# )
# teleop_node = Node(
# package='rmp220_teleop',
# executable='rmp220_teleop',
# name='rmp220_teleop',
# parameters=[joy_params, {'use_sim_time': use_sim_time}],
# remappings=[('/cmd_vel', 'cmd_vel_joy')],
# namespace = namespace
# )
# twist_mux_params = os.path.join(get_package_share_directory('cps_rmp220_support'),'config','twist_mux.yaml')
# twist_mux = Node(
# package="twist_mux",
# executable="twist_mux",
# parameters=[twist_mux_params, {'use_sim_time': False}],
# #remappings=[('cmd_vel_joy','/rmp/cmd_vel_joy')],
# namespace = namespace
# )
2023-08-04 10:04:04 +00:00
# Using the more 'ROS' way: joy node publishes at 50Hz defined in the config and joy-teleop
# node publishes the joy messages only when enable button is pressed.
2023-08-04 09:23:38 +00:00
2023-07-28 09:07:50 +00:00
joy_params = os.path.join(get_package_share_directory('cps_rmp220_support'),'config','joystick.yaml')
2023-08-03 10:33:43 +00:00
namespace = "/rmp"
2023-07-28 09:07:50 +00:00
joy_node = Node(
package='joy',
executable='joy_node',
parameters=[joy_params, {'use_sim_time': use_sim_time}],
#namespace = namespace
2023-07-28 09:07:50 +00:00
)
2023-08-04 09:23:38 +00:00
2023-07-28 09:07:50 +00:00
teleop_node = Node(
2023-08-04 09:23:38 +00:00
package='teleop_twist_joy',
executable='teleop_node',
name='teleop_twist_joy',
2023-07-28 09:07:50 +00:00
parameters=[joy_params, {'use_sim_time': use_sim_time}],
2023-08-04 10:04:04 +00:00
remappings=[('cmd_vel', 'cmd_vel_out')],
#namespace = namespace
2023-07-28 09:07:50 +00:00
)
2023-08-09 06:20:26 +00:00
twist_mux_params = os.path.join(get_package_share_directory('cps_rmp220_support'),'config','twist_mux.yaml')
twist_mux_node = Node(
package="twist_mux",
executable="twist_mux",
parameters=[twist_mux_params, {'use_sim_time': False}],
#remappings=[('/cmd_vel_out','/diffbot_base_controller/cmd_vel_unstamped')]
)
rmp_teleop_node = Node(
package='rmp220_teleop',
executable='rmp220_teleop',
name='rmp220_teleop',
2023-08-10 09:03:55 +00:00
remappings=[('cmd_vel', 'cmd_vel_joy')],
2023-08-09 06:20:26 +00:00
)
2023-07-28 09:07:50 +00:00
return LaunchDescription([
DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use sim time if true'),
joy_node,
2023-08-09 06:20:26 +00:00
#teleop_node,
rmp_teleop_node,
twist_mux_node
2023-07-28 09:07:50 +00:00
])