Skip to content

Source code

The source code for Boat Simulator can be found in src/boat_simulator. Its README has been copied below.

UBC Sailbot Boat Simulator

UBC Sailbot's boat simulator for the new project. This repository contains a ROS package boat_simulator. This README contains only setup and run instructions. Further information on the boat simulator can be found on the

software team's docs website.

Setup

The boat simulator is meant to be ran inside the Sailbot Workspace development environment. Follow the setup instructions for the Sailbot Workspace

here to get started and build all the necessary ROS packages.

Run

The launch/ folder contains a ROS 2 launch file responsible for starting up the boat simulator. To run the boat simulator standalone, execute the launch file after building the boat_simulator package:

ros2 launch boat_simulator main_launch.py [OPTIONS]...

To see a list of options for simulator configuration, add the -s flag at the end of the above command.

Regenerating airfoil coefficient data

The simulator's lift and drag forces depend on each foil's coefficients, which vary with both the angle of attack, the Reynolds number (Re = |v| * chord / kinematic_viscosity) and the mach number. For our calculations, we will consider the Reynolds number and angle of attack Rather than a single hand-tuned curve per foil, the coefficients live in common/airfoil_polars.py as a set of real airfoil polars — one per Reynolds number — that the force computation selects from at runtime by picking the closest tabulated Reynolds number.

That module is generated, not edited by hand. The scripts/build_airfoil_polars.py script downloads XFOIL polars from airfoiltools.com for each foil's NACA section (keel and rudder use NACA 0012; wingsail and trim tab use NACA 0018) at Reynolds numbers 50k–1M, resamples the pre-stall branch to whole-degree angles of attack, and extends each polar out to 90° with the Viterna–Corrigan post-stall model (More details on Viterna extrapolation) (a sail sits near 90° when running dead downwind, well beyond XFOIL's ~±18° range).

Regenerate the data module after changing which foils, sections, Reynolds numbers, or aspect ratios are modeled (all configured near the top of the script). It requires network access and is never imported at runtime:

python3 src/boat_simulator/scripts/build_airfoil_polars.py

Test

Run the test task in the Sailbot Workspace. See

here on how to run vscode tasks.