Vehicle Interface
class UUVehicle
Main vehicle control interface for the Mini-UUV system.
from mini_uuv import UUVehicle
# Initialize vehicle connection
vehicle = UUVehicle(port="/dev/ttyUSB0", baudrate=115200)
# Arm the vehicle
vehicle.arm()
# Set control mode
vehicle.set_mode(UUVehicle.MODE_DEPTH_HOLD)
# Command velocity
vehicle.set_velocity(forward=0.5, lateral=0.0, vertical=0.0)
# Get current state
state = vehicle.get_state()
print(f"Depth: {state.depth}m, Heading: {state.heading}°")
Methods
arm() -> bool
Arms the vehicle for operation. Returns True on success.
disarm() -> bool
Disarms the vehicle and stops all thrusters.
set_mode(mode: int) -> bool
Sets the control mode. Available modes: MANUAL, DEPTH_HOLD, HEADING_HOLD, STATION_KEEP.
set_velocity(forward: float, lateral: float, vertical: float) -> None
Commands body-frame velocities in m/s.
Control
class PIDController
from mini_uuv.control import PIDController
# Create depth controller
depth_pid = PIDController(
kp=2.0, ki=0.5, kd=1.0,
output_limits=(-1.0, 1.0),
anti_windup=True
)
# Compute control output
control = depth_pid.update(
setpoint=target_depth,
measurement=current_depth,
dt=0.02
)
class ThrusterAllocator
from mini_uuv.control import ThrusterAllocator
# Initialize with thruster configuration
allocator = ThrusterAllocator(config="vectored_4dof.yaml")
# Compute thruster commands from desired forces
thruster_cmds = allocator.allocate(
force=[Fx, Fy, Fz],
torque=[Mx, My, Mz]
)
Sensors
IMU
from mini_uuv.sensors import IMU
imu = IMU(port="/dev/ttyIMU")
data = imu.read()
# data.accel, data.gyro, data.mag
DVL
from mini_uuv.sensors import DVL
dvl = DVL(port="/dev/ttyDVL")
velocity = dvl.get_velocity()
altitude = dvl.get_altitude()
Depth Sensor
from mini_uuv.sensors import DepthSensor
depth = DepthSensor(i2c_addr=0x76)
d = depth.read_depth()
t = depth.read_temperature()
Sonar
from mini_uuv.sensors import Sonar
sonar = Sonar(port="/dev/ttySonar")
ranges, angles = sonar.scan()
ROS2 Topics & Services
Published Topics
| Topic | Type | Rate | Description |
|---|---|---|---|
| /uuv/pose | geometry_msgs/PoseStamped | 50 Hz | Vehicle pose |
| /uuv/velocity | geometry_msgs/TwistStamped | 50 Hz | Body velocities |
| /uuv/imu | sensor_msgs/Imu | 100 Hz | IMU data |
| /uuv/depth | std_msgs/Float64 | 20 Hz | Depth measurement |
| /uuv/battery | sensor_msgs/BatteryState | 1 Hz | Battery status |
Subscribed Topics
| Topic | Type | Description |
|---|---|---|
| /uuv/cmd_vel | geometry_msgs/Twist | Velocity commands |
| /uuv/depth_setpoint | std_msgs/Float64 | Target depth |
| /uuv/heading_setpoint | std_msgs/Float64 | Target heading |
Services
| Service | Type | Description |
|---|---|---|
| /uuv/arm | std_srvs/SetBool | Arm/disarm vehicle |
| /uuv/set_mode | uuv_msgs/SetMode | Change control mode |
| /uuv/emergency_stop | std_srvs/Trigger | Emergency stop |