From 1ce23b19037764fc83d97b84af2d6c6b2f0a0fc6 Mon Sep 17 00:00:00 2001 From: alan le run Date: Fri, 22 Dec 2023 08:48:10 +0100 Subject: [PATCH] joystick and launch file --- src/ezbot_descr_simul/config/joystick.yaml | 14 ++++++ .../launch/joystick.launch.py | 45 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/ezbot_descr_simul/config/joystick.yaml create mode 100644 src/ezbot_descr_simul/launch/joystick.launch.py diff --git a/src/ezbot_descr_simul/config/joystick.yaml b/src/ezbot_descr_simul/config/joystick.yaml new file mode 100644 index 0000000..d80d497 --- /dev/null +++ b/src/ezbot_descr_simul/config/joystick.yaml @@ -0,0 +1,14 @@ +teleop_twist_joy_node: + ros__parameters: + axis_linear: + x: 1 + y: 0 + scale_linear: + x: 1.0 + y: -1.0 + axis_angular: + yaw: 3 + scale_angular: + yaw: 1.0 + enable_button: 5 + enable_turbo_button: 8 \ No newline at end of file diff --git a/src/ezbot_descr_simul/launch/joystick.launch.py b/src/ezbot_descr_simul/launch/joystick.launch.py new file mode 100644 index 0000000..e8c42b6 --- /dev/null +++ b/src/ezbot_descr_simul/launch/joystick.launch.py @@ -0,0 +1,45 @@ + +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.substitutions import LaunchConfiguration +from launch.actions import DeclareLaunchArgument + +import os +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + use_sim_time = LaunchConfiguration('use_sim_time') + + joy_params = os.path.join(get_package_share_directory('ezbot_descr_simul'),'config','joystick.yaml') + + joy_node = Node( + package='joy', + executable='joy_node', + parameters=[joy_params, {'use_sim_time': use_sim_time}], + ) + + teleop_node = Node( + package='teleop_twist_joy', + executable='teleop_twist_joy', + name='teleop_twist_joy', + parameters=[joy_params, {'use_sim_time': use_sim_time}] + ) + + # twist_stamper = Node( + # package='twist_stamper', + # executable='twist_stamper', + # parameters=[{'use_sim_time': use_sim_time}], + # remappings=[('/cmd_vel_in','/diff_cont/cmd_vel_unstamped'), + # ('/cmd_vel_out','/diff_cont/cmd_vel')] + # ) + + + return LaunchDescription([ + DeclareLaunchArgument( + 'use_sim_time', + default_value='true', + description='Use sim time if true'), + joy_node, + teleop_node, + # twist_stamper + ]) \ No newline at end of file