Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[submodule "src/sub_sim/stonefish_ros2"]
path = src/sub_sim/stonefish_ros2
url = https://github.com/avbotz/stonefish_ros2
branch = claude-extra-features
branch = claude-extra-features-3
[submodule "src/sub_sim/stonefish_vendor/stonefish"]
path = src/sub_sim/stonefish_vendor/stonefish
url = https://github.com/avbotz/stonefish
branch = claude-extra-features
branch = claude-extra-features-3
[submodule "src/sub_drivers/waterlinked_dvl"]
path = src/sub_drivers/waterlinked_dvl
url = https://github.com/avbotz/waterlinked_dvl
Expand Down
6,309 changes: 3,284 additions & 3,025 deletions pixi.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ setuptools = "<80" # needed for colcon (see c

# Jazzy's launch_testing pytest plugins fail to load under pytest 9 (fixed in Rolling by ros2/launch#972).
pytest = ">=8,<9"
ros2-tf-transformations = ">=1.1.1,<2"
matplotlib = ">=3.11.2,<4"

[feature.dev.dependencies]
# ROS packages
Expand Down
1 change: 1 addition & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extraPaths": [
"build/sub_description",
"build/sub_sim",
"install/lib/python3.12/site-packages",
".pixi/envs/default/lib/python3.12/site-packages"
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ignore = [
]

[lint.isort]
known-first-party = ["sub_bringup", "sub_control", "sub_control_interfaces", "sub_driver_interfaces", "sub_serial_interfaces", "sub_mission", "sub_sim", "sub_sim_sensors", "sub_vision", "sub_vision_interfaces"]
known-first-party = ["sub_bringup", "sub_control", "sub_control_interfaces", "sub_description", "sub_driver_interfaces", "sub_serial_interfaces", "sub_mission", "sub_sim", "sub_sim_sensors", "sub_vision", "sub_vision_interfaces"]

[format]
docstring-code-format = true
110 changes: 51 additions & 59 deletions src/sub_bringup/config/control/gains.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,71 @@
/**:
ros__parameters:
control_rate_hz: 50.0
power_limit: 0.6

# Vehicle model
# [x, y, z, roll, pitch, yaw], base_link FLU (REP-103).
model:
# Rigid body plus added mass
mass: [50.0, 60.0, 70.0] # kg
# Rigid body plus added inertia
inertia: [1.5, 2.0, 2.0] # kg m^2
# Buoyancy minus weight
net_buoyancy: 0.0 # N
# For the righting moment
buoyancy: 0.0 # N
# Relative to base_link
center_of_gravity: [0.0, 0.0, 0.08] # m
center_of_buoyancy: [0.0, 0.0, 0.08] # m
linear_drag: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
quadratic_drag: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
mass: [50.0, 60.0, 70.0] # kg, rigid body + added, x y z
inertia: [1.5, 2.0, 2.0] # kg m^2, rigid body + added, roll pitch yaw
restoring:
net_buoyancy: 0.0 # N, buoyancy - weight (+ floats)
buoyancy: 0.0 # N, for the righting moment
center_of_gravity: [0.0, 0.0, 0.08] # m
center_of_buoyancy: [0.0, 0.0, 0.08] # m, above CG or there's no righting moment
drag: # force opposes motion: F = -(linear*v + quadratic*|v|*v)
linear: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # N/(m/s), N m/(rad/s)
quadratic: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # N/(m/s)^2, N m/(rad/s)^2

# Fraction of each feedforward term applied; bring them in one at a time.
feedforward:
feedforward: # fraction of each term applied
acceleration: 1.0
drag: 1.0
restoring: 1.0
drag: 0.0
restoring: 0.0

# Smooth reference: [max velocity, max acceleration, max jerk] per group,
# m and rad. Keep them inside what the thrusters can do at power_limit.
# [max velocity, max acceleration, max jerk]
trajectory:
horizontal: [0.5, 0.25, 0.5]
vertical: [0.3, 0.2, 0.4]
roll: [0.5, 1.0, 2.0]
pitch: [0.5, 1.0, 2.0]
yaw: [0.6, 0.8, 2.0]
translation_leash: 0.5 # m the reference may get ahead of the vehicle
rotation_leash: 0.5 # rad
horizontal: [0.3, 0.15, 0.3]
vertical: [0.25, 0.15, 0.3]
roll: [0.5, 0.5, 1.0]
pitch: [0.5, 0.5, 1.0]
yaw: [0.6, 0.5, 1.0]
translation_leash: 0.5
rotation_leash: 0.5

# Feedback, [kp, ki, kd] per axis, as accelerations: a = kp*e + ki*int(e) + kd*de/dt
# (1/s^2, 1/s^3, 1/s). Multiplied by model.mass/inertia these are exactly
# the pool-tuned cascade gains this replaced (position P into velocity PI,
# attitude P into rate P):
# kp = (Kv*Kp_pos + Ki_vel)/m, kd = Kv/m, ki = Ki_vel*Kp_pos/m
gains:
x: [7.14, 0.612, 10.2]
y: [5.95, 0.51, 8.5]
z: [8.6, 1.62, 10.29]
roll: [9.6, 0.0, 8.0]
pitch: [7.2, 0.0, 6.0]
yaw: [28.35, 0.9, 23.0]
integral_limit: [1.0, 1.0, 1.0, 6.0, 6.0, 6.0] # m/s^2, rad/s^2
anti_windup: 5.0 # 1/s, how fast integrators shed what the thrusters could not produce
anti_windup: 5.0 # 1/s
x: {kp: 7.14, ki: 0.612, kd: 10.2, integral_limit: 1.0}
y: {kp: 5.95, ki: 0.51, kd: 8.5, integral_limit: 1.0}
z: {kp: 8.6, ki: 1.62, kd: 10.29, integral_limit: 1.0}
roll: {kp: 9.6, ki: 0.0, kd: 8.0, integral_limit: 6.0}
pitch: {kp: 7.2, ki: 0.0, kd: 6.0, integral_limit: 6.0}
yaw: {kp: 28.35, ki: 0.9, kd: 23.0, integral_limit: 6.0}

# Disturbance observer bandwidth per axis [rad/s]; 0 is off. Turn it on
# once the model is identified (https://sw.avbotz.com/thalassic/control/#disturbance-observer).
# [rad/s] per axis; 0 is off. https://sw.avbotz.com/thalassic/control/#disturbance-observer
observer:
bandwidth: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

# What to keep when the wrench is out of reach (saturation, a failed
# thruster): heave and attitude, then heading, then surge and sway.
allocation:
power_limit: 0.6
axis_weights: [1.0, 1.0, 100.0, 100.0, 100.0, 10.0]
max_command_rate: 4.0 # 1/s on the normalized command: no current spikes from instant reversals
max_command_rate: 4.0 # 1/s on the normalized command

# Fraction of nominal thrust each thruster delivers; 0 marks it failed.
# failed_thrusters (e.g. "[3]") does the same at runtime:
# ros2 param set /<robot_name>/sub_control failed_thrusters "[3]"
thruster_health: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
# Names from sub_description's vehicle.yaml.
thrusters:
fwd_port_vert: {health: 1.0}
fwd_stbd_vert: {health: 1.0}
aft_port_vert: {health: 1.0}
aft_stbd_vert: {health: 1.0}
fwd_port_horiz: {health: 1.0}
fwd_stbd_horiz: {health: 1.0}
aft_port_horiz: {health: 1.0}
aft_stbd_horiz: {health: 1.0}

# Arming and watchdogs [s] (https://sw.avbotz.com/thalassic/control/#safety). Ages are by message stamp.
# Ages [s]; dvl and depth are odometry/filtered variances, reached after about 1.5 s and 1.0 s.
safety:
require_kill_cycle: true # arm only after the kill switch has been engaged since startup
state_timeout: 0.5 # no odometry: thrusters off
imu_timeout: 0.2 # rate feedback falls back to the EKF's
attitude_timeout: 1.0 # no IMU: thrusters off (the EKF's attitude would only drift)
dvl_timeout: 1.5 # x/y feedback off
depth_timeout: 1.0 # z feedback off, float up
altitude_timeout: 1.0 # altitude hold becomes depth hold
cmd_vel_timeout: 0.5 # cmd_vel stream stopped: stop
require_kill_cycle: true
max_stamp_lead: 0.05 # stamps further ahead of now are a fault
odometry: {thrusters_off_after: 0.5}
imu: {rate_from_ekf_after: 0.2, thrusters_off_after: 1.0}
dvl: {xy_feedback_off_above: 0.1} # m^2/s^2, x/y velocity
depth: {z_feedback_off_above: 0.07} # m^2, z; drops z feedforward too, so it floats
altitude: {depth_hold_after: 1.0}
cmd_vel: {stop_after: 0.5}
76 changes: 43 additions & 33 deletions src/sub_bringup/config/control/gains_sim.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
/**:
ros__parameters:
control_rate_hz: 50.0
power_limit: 0.6

# Vehicle sim model
# [x, y, z, roll, pitch, yaw], base_link FLU (REP-103).
# Identified from the simulator (identify_model), which does not read this.
model:
mass: [112.2, 94.1, 137.7] # kg; Stonefish's added mass is large
inertia: [12.24, 15.46, 13.99] # kg m^2
net_buoyancy: 20.8 # N
buoyancy: 401.0 # N, from the scene's volume
center_of_gravity: [0.0, 0.0, 0.08]
center_of_buoyancy: [0.0013, 0.0, 0.207] # 12.7 cm above the CG: 51 N m/rad of righting
linear_drag: [93.2, 69.0, 196.8, 3.90, 5.56, 6.69]
quadratic_drag: [149.7, 156.6, 0.0, 0.0, 0.0, 5.12]

feedforward:
mass: [88.1, 87.9, 237.5] # kg, rigid body + added, x y z
inertia: [11.88, 17.23, 11.73] # kg m^2, rigid body + added, roll pitch yaw
restoring:
net_buoyancy: 20.8 # N, buoyancy - weight (+ floats)
buoyancy: 389.7 # N, for the righting moment
center_of_gravity: [0.0, 0.0, 0.08] # m
center_of_buoyancy: [0.0004, 0.0001, 0.2212] # m, above CG or there's no righting moment
drag: # force opposes motion: F = -(linear*v + quadratic*|v|*v)
linear: [30.36, 21.41, 65.96, 0.0, 0.44, 0.48] # N/(m/s), N m/(rad/s)
quadratic: [154.41, 147.27, 0.0, 0.0, 0.0, 3.49] # N/(m/s)^2, N m/(rad/s)^2

feedforward: # fraction of each term applied
acceleration: 1.0
drag: 1.0
restoring: 1.0

# Surge thrust at power_limit 0.6 (54 N) only beats the drag up to about
# 0.36 m/s, so the reference stays under that.
# [max velocity, max acceleration, max jerk]
trajectory:
horizontal: [0.3, 0.15, 0.3]
vertical: [0.25, 0.15, 0.3]
Expand All @@ -30,33 +31,42 @@
translation_leash: 0.5
rotation_leash: 0.5

# Critically damped triple poles, [3w^2, w^3, 3w] at w = 0.8 rad/s on x/y
# (DVL-limited), 1.0 on z, 1.5 on roll/pitch and 1.2 on yaw.
gains:
x: [1.92, 0.512, 2.4]
y: [1.92, 0.512, 2.4]
z: [3.0, 1.0, 3.0]
roll: [6.75, 3.375, 4.5]
pitch: [6.75, 3.375, 4.5]
yaw: [4.32, 1.728, 3.6]
integral_limit: [1.0, 1.0, 1.0, 6.0, 6.0, 6.0]
anti_windup: 5.0
anti_windup: 5.0 # 1/s
x: {kp: 1.92, ki: 0.512, kd: 2.4, integral_limit: 1.0}
y: {kp: 1.92, ki: 0.512, kd: 2.4, integral_limit: 1.0}
z: {kp: 3.0, ki: 1.0, kd: 3.0, integral_limit: 1.0}
roll: {kp: 6.75, ki: 3.375, kd: 4.5, integral_limit: 6.0}
pitch: {kp: 6.75, ki: 3.375, kd: 4.5, integral_limit: 6.0}
yaw: {kp: 4.32, ki: 1.728, kd: 3.6, integral_limit: 6.0}

# [rad/s] per axis; 0 is off. https://sw.avbotz.com/thalassic/control/#disturbance-observer
observer:
bandwidth: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

allocation:
power_limit: 0.6
axis_weights: [1.0, 1.0, 100.0, 100.0, 100.0, 10.0]
max_command_rate: 4.0
max_command_rate: 4.0 # 1/s on the normalized command

thruster_health: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
# Names from sub_description's vehicle.yaml.
thrusters:
fwd_port_vert: {health: 1.0}
fwd_stbd_vert: {health: 1.0}
aft_port_vert: {health: 1.0}
aft_stbd_vert: {health: 1.0}
fwd_port_horiz: {health: 1.0}
fwd_stbd_horiz: {health: 1.0}
aft_port_horiz: {health: 1.0}
aft_stbd_horiz: {health: 1.0}

# Ages [s]; dvl and depth are odometry/filtered variances, reached after about 1.5 s and 1.0 s.
safety:
require_kill_cycle: true
state_timeout: 0.5
imu_timeout: 0.2
attitude_timeout: 1.0
dvl_timeout: 1.5
depth_timeout: 1.0
altitude_timeout: 1.0
cmd_vel_timeout: 0.5
max_stamp_lead: 0.25 # stamps further ahead of now are a fault
odometry: {thrusters_off_after: 0.5}
imu: {rate_from_ekf_after: 0.2, thrusters_off_after: 1.0}
dvl: {xy_feedback_off_above: 0.1} # m^2/s^2, x/y velocity
depth: {z_feedback_off_above: 0.07} # m^2, z; drops z feedforward too, so it floats
altitude: {depth_hold_after: 1.0}
cmd_vel: {stop_after: 0.5}
5 changes: 2 additions & 3 deletions src/sub_bringup/config/devices/flir_blackfly_s.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FLIR Blackfly S GigE, used as the down camera.
# The serial number is in the vehicle description (config/vehicles/<robot_name>.yaml).
# FLIR Blackfly S GigE, the down camera.
# Its serial number, frame_id and frame rate are in sub_description's vehicle.yaml.
/**:
ros__parameters:
buffer_queue_size: 1
Expand All @@ -11,7 +11,6 @@
exposure_time: 2000.0
trigger_mode: "Off"
frame_rate_enable: true
frame_rate: 5.0

# TODO: Try raising to 9000 (MTU set in deploy/jetson/files/60-thalassic-vehicle.yaml).
gev_scps_packet_size: 1500
8 changes: 2 additions & 6 deletions src/sub_bringup/config/devices/logitech_c922.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Logitech C922, used as front camera.
# The video_device and frame_id are in the vehicle description (config/vehicles/<robot_name>.yaml).
# Logitech C922, the front camera.
# Its video_device, frame_id, image size and frame rate are in sub_description's vehicle.yaml.
/**:
ros__parameters:
image_width: 1920
image_height: 1080
framerate: 24.0
# Decoded to rgb8 (usb_cam has no output encoding parameter).
pixel_format: "mjpeg2rgb"
io_method: "mmap"
camera_name: "logitech_c922_webcam"

# Camera Control Parameters
brightness: -1
contrast: -1
saturation: -1
Expand Down
37 changes: 7 additions & 30 deletions src/sub_bringup/config/devices/waterlinked_dvl_a50.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
# Descriptions for all DVL configurations can be found on the Water Linked
# Documentation: https://docs.waterlinked.com/dvl/dvl-protocol
# The DVL's static address and frame are in the vehicle description (config/vehicles/<robot_name>.yaml).
# Water Linked DVL-A50: https://docs.waterlinked.com/dvl/dvl-protocol
# Its address and frame are in sub_description's vehicle.yaml.
/**:
ros__parameters:

# Default port for the DVL-A50
port: 16171

# Timeout for the DVL connection
timeout: 5 # seconds

# All measurements from the DVL use the following coordinate
# convention:
# - x: Forward
# - y: Right
# - z: Down
# This can be rotated using the mounting_rotation_offset parameter.

speed_of_sound: 1481 # m/s

# Rotate the DVL measurements about the z-axis. This is useful if the DVL
# is mounted at an angle.
mounting_rotation_offset: 0 # degrees

# Turn on acoustic waves. Can be set to false to help keep temperatures down.
timeout: 5 # seconds
speed_of_sound: 1481 # m/s
mounting_rotation_offset: 0 # degrees, about z
acoustic_enabled: true

# Turn off dark mode (no LED).
dark_mode_enabled: false

# Set the range mode to auto
dark_mode_enabled: false # true turns the LED off
range_mode: "auto"

# Enable periodic cycling: the DVL periodically searches for a bottom lock shorter than the existing one.
# Periodically search for a shorter bottom lock.
periodic_cycling_enabled: true
13 changes: 6 additions & 7 deletions src/sub_bringup/config/diagnostics.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# diagnostic_aggregator's grouping of /diagnostics into /diagnostics_agg (and the
# overall level on /diagnostics_toplevel_state), for Foxglove's diagnostics panel
# and `ros2 run sub_bringup preflight`. An item that stops reporting for `timeout` seconds
# turns stale, so a dead driver shows up even though it can no longer say so.
# Names are "<node name>: <task>" (diagnostic_updater).
# diagnostics_vehicle.yaml adds the hardware drivers on the vehicle (an empty
# group would read as stale in the simulator).
# Groups /diagnostics into /diagnostics_agg. Items are named "<node name>: <task>".
/**:
ros__parameters:
path: Vehicle
Expand All @@ -24,3 +18,8 @@
path: Vision
startswith: ["sub_vision"]
timeout: 5.0
drivers:
type: diagnostic_aggregator/GenericAnalyzer
path: Drivers
startswith: ["sub_low", "naviguider_imu", "waterlinked_dvl", "down_camera", "logitech_c922"]
timeout: 3.0
9 changes: 0 additions & 9 deletions src/sub_bringup/config/diagnostics_vehicle.yaml

This file was deleted.

Loading