Skip to content

Commit

Permalink
Updated auv_setup to ros2
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldokan committed Feb 7, 2024
1 parent 77f190f commit 1824f8f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 13 deletions.
24 changes: 23 additions & 1 deletion auv_setup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.8)
project(auv_setup)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

# Install launch files.
install(DIRECTORY
config
launch
DESTINATION share/${PROJECT_NAME}/
)

ament_package()
42 changes: 42 additions & 0 deletions auv_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.0},
],
remappings=[
('/joy', '/joystick/joy'),
],
)

# Joystick interface launch
joystick_interface_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(get_package_share_directory('joystick_interface_auv'), 'launch/joystick_interface_auv.launch.py')
)
)

# Return launch description
return LaunchDescription([
set_env_var,
joy_node,
joystick_interface_launch
])
15 changes: 11 additions & 4 deletions auv_setup/package.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>auv_setup</name>
<version>0.0.0</version>
<description>The auv_setup package</description>
<maintainer email="[email protected]">christopher</maintainer>
<maintainer email="[email protected]">alekskl01</maintainer>
<license>MIT</license>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend>ament_cmake</buildtool_depend>

</package>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,12 @@ def joystick_cb(self, msg: Joy):
left_shoulder = buttons["LB"]
right_shoulder = buttons["RB"]

<<<<<<< HEAD
surge = axes[
"vertical_axis_left_stick"] * self.joystick_surge_scaling_
sway = axes[
"horizontal_axis_left_stick"] * self.joystick_sway_scaling_
heave = -(left_trigger - right_trigger)/2 * self.joystick_heave_scaling_
roll = (right_shoulder - left_shoulder) * self.joystick_roll_scaling_
=======
surge = axes["vertical_axis_left_stick"] * self.joystick_surge_scaling_
sway = axes["horizontal_axis_left_stick"] * self.joystick_sway_scaling_
heave = -(axes[["RT"] - axes["LT"]]) / 2 * self.joystick_heave_scaling_
roll = axes[self.buttons["RB"] -
self.buttons["LB"]] * self.joystick_roll_scaling_
>>>>>>> refs/remotes/origin/feature/joystick_interface_in_ros2
pitch = -axes[
"vertical_axis_right_stick"] * self.joystick_pitch_scaling_
yaw = axes["horizontal_axis_right_stick"] * self.joystick_yaw_scaling_
Expand Down

0 comments on commit 1824f8f

Please sign in to comment.