From 879b4877c62a1a6c37e1a51ee4d56c4323f5b430 Mon Sep 17 00:00:00 2001 From: alekskl01 Date: Sat, 14 Oct 2023 16:43:28 +0200 Subject: [PATCH] created py launchfiles for joystick_interface and pc.launch + minor restructuring --- asv_setup/launch/pc.launch.py | 42 +++++++++++++++++++ asv_setup/launch/pc.launch.yaml | 24 ----------- asv_setup/launch/tf.launch.yaml | 12 ------ mission/joystick_interface/CMakeLists.txt | 8 +++- ...ams.yaml => param_joystick_interface.yaml} | 0 .../joystick_interface/joystick_interface.py | 6 +-- .../launch/joystick_interface.launch.py | 21 ++++++++++ .../launch/joystick_interface.launch.yaml | 13 ------ mission/joystick_interface/package.xml | 2 +- .../{joystick_interface => }/test/__init__.py | 0 .../test/test_joystick_interface.py | 0 11 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 asv_setup/launch/pc.launch.py delete mode 100644 asv_setup/launch/pc.launch.yaml delete mode 100644 asv_setup/launch/tf.launch.yaml rename mission/joystick_interface/config/{params.yaml => param_joystick_interface.yaml} (100%) create mode 100644 mission/joystick_interface/launch/joystick_interface.launch.py delete mode 100644 mission/joystick_interface/launch/joystick_interface.launch.yaml rename mission/joystick_interface/{joystick_interface => }/test/__init__.py (100%) rename mission/joystick_interface/{joystick_interface => }/test/test_joystick_interface.py (100%) diff --git a/asv_setup/launch/pc.launch.py b/asv_setup/launch/pc.launch.py new file mode 100644 index 00000000..1248ae25 --- /dev/null +++ b/asv_setup/launch/pc.launch.py @@ -0,0 +1,42 @@ +import os +from launch import LaunchDescription +from launch.actions import SetEnvironmentVariable, IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch_ros.actions import Node +from ament_index_python.packages import get_package_share_directory + +def generate_launch_description(): + # Set environment variable + set_env_var = SetEnvironmentVariable( + name='ROSCONSOLE_FORMAT', + value='[${severity}] [${time}] [${node}]: ${message}' + ) + + # Joystick node + joy_node = Node( + package='joy', + executable='joy_node', + name='joystick_driver', + output='screen', + parameters=[ + {'_deadzone': 0.15}, + {'_autorepeat_rate': 100}, + ], + remappings=[ + ('/joy', '/joystick/joy'), + ], + ) + + # Joystick interface launch + joystick_interface_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(get_package_share_directory('joystick_interface'), 'launch/joystick_interface.launch.py') + ) + ) + + # Return launch description + return LaunchDescription([ + set_env_var, + joy_node, + joystick_interface_launch + ]) diff --git a/asv_setup/launch/pc.launch.yaml b/asv_setup/launch/pc.launch.yaml deleted file mode 100644 index 680bcb3a..00000000 --- a/asv_setup/launch/pc.launch.yaml +++ /dev/null @@ -1,24 +0,0 @@ -launch: - - set_env: - name: ROSCONSOLE_FORMAT - value: "[${severity}] [${time}] [${node}]: ${message}" - - - group: - - node: - pkg: joy - exec: joy_node - name: joystick_driver - output: screen - param: - - name: _deadzone - value: 0.15 - - name: _autorepeat_rate - value: 100 - remap: - - - from: "/joy" - to: "/joystick/joy" - - - include: - file: "src/vortex-asv/mission/joystick_interface/launch/joystick_interface.launch.yaml" - diff --git a/asv_setup/launch/tf.launch.yaml b/asv_setup/launch/tf.launch.yaml deleted file mode 100644 index f4dac986..00000000 --- a/asv_setup/launch/tf.launch.yaml +++ /dev/null @@ -1,12 +0,0 @@ -launch: - - node: - pkg: tf2_ros - exec: static_transform_publisher - name: base_link_to_lidar - args: --frame-id base_link --child-frame-id os_lidar --x -0.0145 --y 0 --z -0.392425 --roll 3.14159 --pitch 0 --yaw 0 - - - node: - pkg: tf2_ros - exec: static_transform_publisher - name: base_link_to_zed2_camera_center - args: --frame-id base_link --child-frame-id zed2i_camera_center --x 0.3005 --y 0 --z -0.22036 --roll 3.14159 --pitch 0 --yaw 0 \ No newline at end of file diff --git a/mission/joystick_interface/CMakeLists.txt b/mission/joystick_interface/CMakeLists.txt index 0f5262d4..e58d5013 100644 --- a/mission/joystick_interface/CMakeLists.txt +++ b/mission/joystick_interface/CMakeLists.txt @@ -12,6 +12,12 @@ find_package(geometry_msgs REQUIRED) ament_python_install_package(${PROJECT_NAME}) +# Install launch files. +install(DIRECTORY + launch + DESTINATION share/${PROJECT_NAME} +) + install(PROGRAMS joystick_interface/joystick_interface.py DESTINATION lib/${PROJECT_NAME} @@ -20,7 +26,7 @@ install(PROGRAMS if(BUILD_TESTING) find_package(ament_cmake_pytest REQUIRED) set(_pytest_tests - joystick_interface/test/test_joystick_interface.py + test/test_joystick_interface.py ) foreach(_test_path ${_pytest_tests}) get_filename_component(_test_name ${_test_path} NAME_WE) diff --git a/mission/joystick_interface/config/params.yaml b/mission/joystick_interface/config/param_joystick_interface.yaml similarity index 100% rename from mission/joystick_interface/config/params.yaml rename to mission/joystick_interface/config/param_joystick_interface.yaml diff --git a/mission/joystick_interface/joystick_interface/joystick_interface.py b/mission/joystick_interface/joystick_interface/joystick_interface.py index 5640b02e..d76f4555 100755 --- a/mission/joystick_interface/joystick_interface/joystick_interface.py +++ b/mission/joystick_interface/joystick_interface/joystick_interface.py @@ -53,9 +53,9 @@ def __init__(self): "thrust/wrench_input", 1) - self.declare_parameter('surge_scale_factor', 100.0) - self.declare_parameter('sway_scale_factor', 100.0) - self.declare_parameter('yaw_scale_factor', 100.0) + self.declare_parameter('surge_scale_factor', 50.0) + self.declare_parameter('sway_scale_factor', 50.0) + self.declare_parameter('yaw_scale_factor', 50.0) #Gets the scaling factors from the yaml file self.joystick_surge_scaling = self.get_parameter('surge_scale_factor').value diff --git a/mission/joystick_interface/launch/joystick_interface.launch.py b/mission/joystick_interface/launch/joystick_interface.launch.py new file mode 100644 index 00000000..53d7c6a8 --- /dev/null +++ b/mission/joystick_interface/launch/joystick_interface.launch.py @@ -0,0 +1,21 @@ +import os +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.substitutions import LaunchConfiguration +from ament_index_python.packages import get_package_share_directory + + +def generate_launch_description(): + + joystick_interface_node = Node( + package='joystick_interface', + executable='joystick_interface.py', + name='joystick_interface', + output='screen', + parameters=[os.path.join(get_package_share_directory('joystick_interface'), 'config/param_joystick_interface.yaml')] + ) + + return LaunchDescription([ + joystick_interface_node + ]) + diff --git a/mission/joystick_interface/launch/joystick_interface.launch.yaml b/mission/joystick_interface/launch/joystick_interface.launch.yaml deleted file mode 100644 index 61aac95f..00000000 --- a/mission/joystick_interface/launch/joystick_interface.launch.yaml +++ /dev/null @@ -1,13 +0,0 @@ -launch: -- node: - pkg: joystick_interface - exec: joystick_interface.py - name: joystick_interface - output: screen - param: - - from: src/vortex-asv/mission/joystick_interface/config/params.yaml - - - - - diff --git a/mission/joystick_interface/package.xml b/mission/joystick_interface/package.xml index 50d62ad2..721e0441 100644 --- a/mission/joystick_interface/package.xml +++ b/mission/joystick_interface/package.xml @@ -9,7 +9,7 @@ MIT - ament_cmake_python + ament_python rclpy geometry_msgs diff --git a/mission/joystick_interface/joystick_interface/test/__init__.py b/mission/joystick_interface/test/__init__.py similarity index 100% rename from mission/joystick_interface/joystick_interface/test/__init__.py rename to mission/joystick_interface/test/__init__.py diff --git a/mission/joystick_interface/joystick_interface/test/test_joystick_interface.py b/mission/joystick_interface/test/test_joystick_interface.py similarity index 100% rename from mission/joystick_interface/joystick_interface/test/test_joystick_interface.py rename to mission/joystick_interface/test/test_joystick_interface.py