Skip to content

Commit

Permalink
created py launchfiles for joystick_interface and pc.launch + minor r…
Browse files Browse the repository at this point in the history
…estructuring
  • Loading branch information
alekskl01 committed Oct 14, 2023
1 parent 3de5161 commit 879b487
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 54 deletions.
42 changes: 42 additions & 0 deletions asv_setup/launch/pc.launch.py
Original file line number Diff line number Diff line change
@@ -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
])
24 changes: 0 additions & 24 deletions asv_setup/launch/pc.launch.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions asv_setup/launch/tf.launch.yaml

This file was deleted.

8 changes: 7 additions & 1 deletion mission/joystick_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions mission/joystick_interface/launch/joystick_interface.launch.py
Original file line number Diff line number Diff line change
@@ -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
])

13 changes: 0 additions & 13 deletions mission/joystick_interface/launch/joystick_interface.launch.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion mission/joystick_interface/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<license>MIT</license>

<buildtool_depend>ament_cmake_python</buildtool_depend>
<buildtool_depend>ament_python</buildtool_depend>

<exec_depend>rclpy</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
Expand Down
File renamed without changes.

0 comments on commit 879b487

Please sign in to comment.