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

Complete boat state class #404

Open
eomielan opened this issue Jun 10, 2024 · 0 comments · May be fixed by #432
Open

Complete boat state class #404

eomielan opened this issue Jun 10, 2024 · 0 comments · May be fixed by #432
Assignees
Labels
enhancement New feature or request sim Boat Simulator team

Comments

@eomielan
Copy link
Member

eomielan commented Jun 10, 2024

Purpose

The purpose is to finalize the implementation of the Python classes responsible for tracking the state of the boat. This encompasses kinematic information regarding the boat's position, velocity, and acceleration in both global and relative reference frames. For more detailed information on the reference frames utilized, please refer to this confluence page.

Description

You will accomplish the following tasks within boat_simulator/nodes/physics_engine/model.py.

  • Modify the BoatState constructor to include:

    • timestep: A scalar value representing the time interval used for calculations, expressed in seconds ($s$).
    • mass: The total mass of the boat, expressed in kilograms ($kg$).
    • inertia: The boat's inertia, expressed in kilograms-meters squared ($kg\cdot m^2$).
    • air_density: A scalar representing the density of air, expressed in kilograms per cubic meter $\left(\dfrac{kg}{m^3}\right)$.
    • water_density: A scalar representing the density of water, expressed in kilograms per cubic meter $\left(\dfrac{kg}{m^3}\right)$.
  • Add 2 instances of MediumForceComputation as attributes:

    1. For sail forces, using air density provided in constructor.
    2. For rudder forces, using water density provided in constructor.

    (You can find the necessary lift/drag coefficients and areas in boat_simulator/common/constants.py.)

  • Implement compute_net_force_and_torque to calculate the total force and torque:

    • Calculate apparent wind and water velocities by subtracting the boat's velocity from the respective true velocities.

      $\text{Apparent wind velocity = Relative wind velocity - Boat's relative velocity}$
      $\text{Apparent water velocity} = \text{Relative water velocity} - \text{Boat's relative velocity}$

    • Use the compute method from MediumForceComputation to obtain forces on the sail and rudder.

    • Calculate hull drag force as the product of boat velocity and hull drag factor (hull drag factor can be found in boat_simulator/common/constants.py).

    • Determine total torque by summing the moments produced by the sail and rudder forces, accounting for the respective distances from the pivot point and the angles.

      Torque from the Sail Force: $\tau_{sail} = F_{sail} \times d_{sail} \times \sin(\alpha_{sail})$
      Torque from the Rudder Force: $\tau_{rudder} = F_{rudder} \times d_{rudder} \times \sin(\alpha_{rudder})$
      Total Torque: $\tau_{total} = \tau_{sail} + \tau_{rudder}$

      Where:
      $F_{sail}$ and $F_{rudder}$: Magnitude of the lift and drag force on the sail and rudder respectively.
      $d_{sail}$ and $d_{rudder}$: Distance from the sail/rudder's centre of effort to the pivot point.
      $\alpha_{sail}$ and $\alpha_{rudder}$: Angle of attack of the sail and rudder respectively.

Tests

Add your unit tests to tests/unit/nodes/physics_engine/test_model.py. Utilize the pytest API for testing, which is already installed.

Resources

@eomielan eomielan added enhancement New feature or request sim Boat Simulator team labels Jun 10, 2024
@github-project-automation github-project-automation bot moved this to Backlog in SOFT Project Jun 10, 2024
@eomielan eomielan moved this from Backlog to Todo in SOFT Project Jun 10, 2024
@stevenxu27 stevenxu27 linked a pull request Sep 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sim Boat Simulator team
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants