Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code from the summer #194

Open
wants to merge 69 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0f9feb3
Added LQR and PID DP
Mokaz Apr 28, 2024
cff5d3c
Fixed topic names and initial tuning
Andeshog Apr 29, 2024
4a1110f
Made LQR and PID ready for testing
Andeshog Apr 29, 2024
539d025
Added QoS profile to seapath/odom subscription
Andeshog Apr 29, 2024
f9cc001
Added QoS profile
Andeshog Jun 23, 2024
e611e5c
Added yaw publisher
Andeshog Jul 5, 2024
7050c3b
.
Andeshog Jul 9, 2024
1cd14f8
Added way to reinitialize waypoints through service call
Andeshog Jul 11, 2024
09110fa
Enabled controller tuning of LQR and PID during runtime.
Andeshog Jul 13, 2024
19a7ff0
sitaw merge
jorgenfj Jul 13, 2024
18024e5
Committing clang-format changes
Jul 13, 2024
c204914
Working system after physical testing
Andeshog Jul 15, 2024
4f63bb1
Wall update
jorgenfj Jul 20, 2024
447125b
Committing clang-format changes
Jul 20, 2024
08afdba
qos fix
jorgenfj Jul 23, 2024
cfc4853
Committing clang-format changes
Jul 23, 2024
0131dcb
Add sim launch for freya
chrstrom Jul 25, 2024
3e3b7de
docking task
jorgenfj Jul 26, 2024
64b5b88
Committing clang-format changes
Jul 26, 2024
168772e
Add controller to sim launch
chrstrom Jul 26, 2024
d9c848c
dynamic buoy prediction
jorgenfj Jul 26, 2024
f406191
Committing clang-format changes
Jul 26, 2024
07cfa31
njord task structure
jorgenfj Jul 29, 2024
fa84fd0
Committing clang-format changes
Jul 29, 2024
5ff9ec4
auction algorithm fix
jorgenfj Jul 29, 2024
f5248f4
Committing clang-format changes
Jul 29, 2024
364d056
utility functions for task base
jorgenfj Jul 30, 2024
e7a71da
Committing clang-format changes
Jul 30, 2024
a09d4e5
navigation task test ready
jorgenfj Jul 30, 2024
d05125e
Committing clang-format changes
Jul 30, 2024
4de17fa
Concurrency setup change
jorgenfj Jul 31, 2024
1d5d522
Committing clang-format changes
Jul 31, 2024
06dec3e
bugfix in navigation, finished maneuvering
jorgenfj Jul 31, 2024
8407037
Committing clang-format changes
Jul 31, 2024
a6a61ac
Map manager sim setup
jorgenfj Aug 1, 2024
e974929
Committing clang-format changes
Aug 1, 2024
638f998
Controller wont publish forces if the killswitch is on or system not …
Andeshog Aug 5, 2024
591919a
Added comminication with joystick and ability to set desired yaw angl…
Andeshog Aug 5, 2024
7dd07c7
Removed spam, initialized y-button
Andeshog Aug 5, 2024
bced81a
Raised max and min thrust
Andeshog Aug 5, 2024
cfa6963
Minor adjustments to heading tuning
Andeshog Aug 5, 2024
783168d
improved logging and behaviour for stationkeeping
Andeshog Aug 5, 2024
6f6d8fc
Added ability to set stationkeeping pose by pressing Y
Andeshog Aug 5, 2024
b461023
visualization fix
jorgenfj Aug 5, 2024
b9f431c
Committing clang-format changes
Aug 5, 2024
b98b385
Set mu to zero such that the vessel can keep constant velocity more e…
Andeshog Aug 7, 2024
adf847a
Added new list to waypoint node collection. 40 meters straight east
Andeshog Aug 7, 2024
628fa19
Merge branch 'test/29.04' of https://github.com/vortexntnu/vortex-asv…
Andeshog Aug 7, 2024
70b32a1
colav task
jorgenfj Aug 8, 2024
5fb44bc
Committing clang-format changes
Aug 8, 2024
0310cd8
thrust force and mapping
vortexuser Aug 7, 2024
266ae94
fill landmark polygons
jorgenfj Aug 9, 2024
47ba8ab
Committing clang-format changes
Aug 9, 2024
d59023f
dock edge localization test
jorgenfj Aug 9, 2024
8a6aab5
Committing clang-format changes
Aug 9, 2024
fffa973
Update docstrings
Andeshog Aug 17, 2024
b423d55
Cleanup
Andeshog Aug 17, 2024
535df5b
Remove unused packages and files
Andeshog Aug 17, 2024
4a3e8b9
Remove unused files from install
Andeshog Aug 17, 2024
3d0e8b9
Updated waypoint service call example
Andeshog Aug 17, 2024
57ff9e6
Boolean value for when the built in heading reference for the path sh…
Andeshog Aug 17, 2024
cd33ea5
Removed commented code
Andeshog Aug 17, 2024
bcef888
Removed unncecessary if else
Andeshog Aug 17, 2024
883f88d
moved map-odom-tf to map_manager and added optional grid usage in lan…
jorgenfj Aug 17, 2024
b65b35a
Committing clang-format changes
Aug 17, 2024
04c0bcc
Add coriolis
Andeshog Aug 17, 2024
4229552
Remove old force mapping
Andeshog Aug 17, 2024
f8ee295
Merge branch 'test/29.04' of https://github.com/vortexntnu/vortex-asv…
Andeshog Aug 17, 2024
b7f6fab
build fix
jorgenfj Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions asv_setup/config/robots/freya.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
yaw: true
thrusters:
num: 4
min: -200
max: 200
min: -1000
max: 1000
configuration_matrix: #NED
[0.70711, 0.70711, 0.70711, 0.70711,
-0.70711, 0.70711, -0.70711, 0.70711,
Expand Down
6 changes: 6 additions & 0 deletions asv_setup/config/sitaw/landmark_server_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
landmark_server_node:
ros__parameters:
fixed_frame: map
target_frame: base_link
wall_width: 0.1
use_grid: false
25 changes: 25 additions & 0 deletions asv_setup/config/sitaw/map_manager_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
map_manager_node:
ros__parameters:
use_predef_landmask: true
landmask_file: "src/vortex-asv/asv_setup/config/sitaw/land_polygon_sim_maneuvering.yaml"
# landmask_file: "src/vortex-asv/asv_setup/config/sitaw/land_polygon_office.yaml"
map_resolution: 0.2
map_width: 1000
map_height: 1000
frame_id: "map"
# Map origin for office rosbag
# map_origin_lat: 63.414660884931976
# map_origin_lon: 10.398554661537544
# use_predef_map_origin: true
# Map origin for sim_navigation
# map_origin_lat: -33.72242824301795
# map_origin_lon: 150.6740063854522
# use_predef_map_origin: true
# Map origin for sim_maneuvering
# map_origin_lat: -33.72213985487166
# map_origin_lon: 150.67413507552098
# use_predef_map_origin: true
#colav
map_origin_lat: -33.72213988382845
map_origin_lon: 150.67413500672993
use_predef_map_origin: true
4 changes: 4 additions & 0 deletions asv_setup/config/sitaw/seapath_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
seapath_ros_driver_node:
ros__parameters:
UDP_IP: "10.0.1.10" # Source IP of the host sender
UDP_PORT: 31421 # Port at which to receive UDP segment
69 changes: 69 additions & 0 deletions asv_setup/launch/sim_freya.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from os import path
from launch_ros.actions import Node
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.actions import SetEnvironmentVariable, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
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}'
)


# Thruster Allocator launch
thruster_allocator_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
path.join(get_package_share_directory('thruster_allocator'), 'launch', 'thruster_allocator.launch.py')
)
)

# 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(
path.join(get_package_share_directory('joystick_interface'), 'launch', 'joystick_interface.launch.py')
)
)

# Vortex Sim Interface launch
vortex_sim_interface_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
path.join(get_package_share_directory('vortex_sim_interface'), 'launch', 'vortex_sim_interface.launch.py')
)
)

# Controller
controller_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
path.join(get_package_share_directory('asv_setup'), 'launch', 'hybridpath.launch.py')
)
)

# Return launch description
return LaunchDescription([
set_env_var,
thruster_allocator_launch,
joy_node,
joystick_interface_launch,
controller_launch,
vortex_sim_interface_launch,
])
60 changes: 60 additions & 0 deletions asv_setup/launch/sitaw.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch_ros.actions import Node
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
enable_tf = LaunchConfiguration('enable_tf')
enable_tf_arg = DeclareLaunchArgument(
'enable_tf',
default_value='True',
description='enable tf launch file',
)
enable_seapath = LaunchConfiguration('enable_seapath')
enable_seapath_arg = DeclareLaunchArgument(
'enable_seapath',
default_value='True',
description='enable seapath launch file',
)

seapath_ros_driver_node = Node(
package='seapath_ros_driver',
executable='seapath_ros_driver_node',
name='seapath_ros_driver_node',
parameters=[os.path.join(get_package_share_directory('asv_setup'),'config','sitaw','seapath_params.yaml')],
output='screen',
condition=IfCondition(enable_seapath),

)
map_manager_node = Node(
package='map_manager',
executable='map_manager_node',
name='map_manager_node',
parameters=[os.path.join(get_package_share_directory('asv_setup'),'config','sitaw','map_manager_params.yaml')],
output='screen',
)
landmark_server_node = Node(
package='landmark_server',
executable='landmark_server_node',
name='landmark_server_node',
parameters=[os.path.join(get_package_share_directory('asv_setup'),'config','sitaw','landmark_server_params.yaml')],
# arguments=['--ros-args', '--log-level', 'DEBUG'],
output='screen',
)
tf_launch = IncludeLaunchDescription(
launch_description_source=PythonLaunchDescriptionSource(os.path.join(get_package_share_directory('asv_setup'), 'launch', 'tf.launch.py')),
condition=IfCondition(enable_tf),
)
return LaunchDescription([
enable_tf_arg,
tf_launch,
enable_seapath_arg,
seapath_ros_driver_node,
map_manager_node,
landmark_server_node
])
21 changes: 18 additions & 3 deletions asv_setup/launch/tf.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def generate_launch_description():
)

# base_link (NED) to seapath_frame (NED) tf.
tf_base_link_to_seapath = Node(
tf_seapath_to_base_link = Node(
package='tf2_ros',
name='base_link_ned_to_seapath_frame',
name='seapath_to_base_link',
executable='static_transform_publisher',
arguments=['--x' , '0',
'--y' , '0',
Expand All @@ -50,8 +50,23 @@ def generate_launch_description():
'--child-frame-id' , 'base_link'],
)

os_sensor_to_os_lidar = Node(
package='tf2_ros',
name='os_sensor_to_os_lidar',
executable='static_transform_publisher',
arguments=['--x' , '0',
'--y' , '0',
'--z' , '0.036180000000000004',
'--roll' , '0',
'--pitch' , '0',
'--yaw' , str(math.pi),
'--frame-id' , 'os_sensor',
'--child-frame-id' , 'os_lidar'],
)

return LaunchDescription([
tf_base_link_to_lidar,
tf_base_link_to_zed_camera_link,
tf_base_link_to_seapath,
tf_seapath_to_base_link,
os_sensor_to_os_lidar,
])
1 change: 1 addition & 0 deletions guidance/hybridpath_guidance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(vortex_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(std_srvs REQUIRED)

ament_python_install_package(${PROJECT_NAME})

Expand Down
2 changes: 1 addition & 1 deletion guidance/hybridpath_guidance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Or alternatively, run it together with the hybridpath controller using the launc

To run with custom waypoints (replace example waypoints with actual waypoints, and add as many prefered):

`ros2 service call waypoint_list vortex_msgs/srv/Waypoint "waypoint: [{x: 0.0, y: 0.0, z: 0.0}, {x: 5.0, y: 5.0, z: 0.0}]"`
`ros2 service call waypoint_list vortex_msgs/srv/Waypoint "waypoint: [{x: 5.0, y: 5.0, z: 0.0}]"`

## Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
lambda_val: 0.15 # Curvature constant
path_generator_order: 1 # Differentiability order
dt: 0.1 # Time step
mu: 0.03 # Tuning parameter
mu: 0.25 # Tuning parameter, changes how much the path will wait for the vessel if it lags behind
96 changes: 82 additions & 14 deletions guidance/hybridpath_guidance/hybridpath_guidance/hybridpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,49 @@ class HybridPathGenerator:
path (Path): The path object.
"""
def __init__(self, WP: list[Point], r: int, lambda_val: float):
self.WP = WP
self.r = r
self.lambda_val = lambda_val
self.order = 2*r + 1

def create_path(self, WP: list[Point]) -> None:
"""
Create a path object.

Args:
WP (list[Point]): A list of waypoints.

Returns:
None
"""
self.update_waypoints(WP)
self._initialize_path()
self._calculate_subpaths()

def _initialize_path(self):
"""
Initialize the path object.
"""
self.path = Path()

self.path.coeff.a = []
self.path.coeff.b = []
self.path.coeff.a_der = []
self.path.coeff.b_der = []
self.path.LinSys.A = None
self.path.LinSys.bx = []
self.path.LinSys.by = []

self.path.NumSubpaths = len(self.WP) - 1
self.path.Order = self.order

def update_waypoints(self, WP: list[Point]) -> None:
"""
Updates the waypoints for the path.

Args:
WP (list[Point]): A list of waypoints.
"""
# Convert the waypoints to a numpy array
WP_arr = np.array([[wp.x, wp.y] for wp in WP])

Expand All @@ -77,13 +120,6 @@ def __init__(self, WP: list[Point], r: int, lambda_val: float):

else:
self.WP = WP_arr
self.r = r
self.lambda_val = lambda_val
self.order = 2*r + 1
self.path = Path()
self.path.NumSubpaths = len(self.WP) - 1
self.path.Order = self.order
self._calculate_subpaths()

def _construct_A_matrix(self) -> np.ndarray:
"""
Expand Down Expand Up @@ -280,6 +316,12 @@ def _calculate_subpaths(self) -> None:
for k, (a, b) in enumerate(zip(a_derivatives, b_derivatives)):
self._append_derivatives(k, a, b)

def get_path(self) -> Path:
"""
Get the hybrid path.
"""
return self.path

@staticmethod
def update_s(path: Path, dt: float, u_desired: float, s: float, w: float) -> float:
"""
Expand All @@ -295,7 +337,9 @@ def update_s(path: Path, dt: float, u_desired: float, s: float, w: float) -> flo
float: The updated position along the hybrid path.

"""
signals = HybridPathSignals(path, s)
signals = HybridPathSignals()
signals.update_path(path)
signals.update_s(s)
v_s = signals.get_vs(u_desired)
s_new = s + (v_s + w) * dt
return s_new
Expand All @@ -314,13 +358,12 @@ class HybridPathSignals:
Path (Path): The path object.
s (float): The path parameter.
"""
def __init__(self, path: Path, s: float):
if not isinstance(path, Path):
raise TypeError("path must be an instance of Path")
self.path = path
self.s = self._clamp_s(s, self.path.NumSubpaths)
def __init__(self):
self.path = None
self.s = None

def _clamp_s(self, s: float, num_subpaths: int) -> float:
@staticmethod
def _clamp_s(s: float, num_subpaths: int) -> float:
"""
Ensures s is within the valid range of [0, num_subpaths].

Expand Down Expand Up @@ -506,4 +549,29 @@ def get_w(self, mu: float, eta: np.ndarray) -> float:
w = (mu / np.linalg.norm(eta_d_s)) * np.dot(eta_d_s, error)

return w

def update_path(self, path: Path) -> None:
"""
Update the path object.

Args:
path (Path): The new path object.

Returns:
None
"""
self.path = path
self.update_s(0.)

def update_s(self, s: float) -> None:
"""
Update the path parameter.

Args:
s (float): The new path parameter.

Returns:
None
"""
self.s = self._clamp_s(s, self.path.NumSubpaths)

Loading
Loading