UBCSailbot / sailbot_workspace

UBC Sailbot's monorepo
https://ubcsailbot.github.io/sailbot_workspace/main/
Apache License 2.0
3 stars 1 forks source link

Calculate physics engine data #401

Open eomielan opened 4 weeks ago

eomielan commented 4 weeks ago

Purpose

This purpose of this issue is to update the physics engine node to combine the fluid generation class with the boat state class in a timer callback to calculate real values for the physics engine.

Description

Create a method in the PhysicsEngineNode class that will:

  1. Generate new fluid vectors for wind and water.
  2. Update the boat's state using these fluid vectors.

Then call this method in __publish() before any of the other methods are called.

Take a look at the FluidGenerator class for simulating wind and current velocities and the BoatState class for tracking and updating the boat's state based on the fluid vectors.

Ressources

alberto-escobar commented 6 days ago

Created the following method in PhysicsEngineNode class:

 def __update_boat_state(self):
        """
        Generates the next vectors for wind_generator and current_generator and updates the
        boat_state with the new wind and current vectors along with the rudder_angle and
        sail_trim_tab_angle.
        """
        self.__boat_state(
            self.__wind_generator.next(),
            self.__current_generator.next(),
            self.__rudder_angle,
            self.__sail_trim_tab_angle,
        )

then called __update_boat_state() in __publish() method before anything else was called:

    # PUBLISHER CALLBACKS
    def __publish(self):
        self.__update_boat_state()
        """Synchronously publishes data to all publishers at once."""
        ...

did not implement tests as I am not sure how to go about testing this.