Skip to content

Commit

Permalink
Merge branch 'main' into SPDonaghy/test-pybind11-simple
Browse files Browse the repository at this point in the history
  • Loading branch information
SPDonaghy authored Nov 3, 2024
2 parents a91d8a0 + 70ad254 commit 1be78b3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .devcontainer/base-dev/base-dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,6 @@ ENV DEBIAN_FRONTEND=
# install dev python3 dependencies
RUN pip3 install \
# for juypter notebooks
ipykernel
ipykernel \
# to generate ompl python bindings
pybind11
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class FluidGenerator:
"""This class provides functionality to generate velocity vectors representing fluid movements.
Attributes:
`generator` (VectorGenerator): The vector generator used to generate 3D fluid velocities.
`generator` (VectorGenerator): The vector generator used to generate 2D fluid velocities.
`velocity` (NDArray): The most recently generated fluid velocity vector, expressed in
meters per second (m/s). It is expected to be a 3D vector.
"""

def __init__(self, generator: VectorGenerator):
self.__generator = generator
self.__velocity = np.array(self.__generator.next())
assert self.__velocity.shape == (3,)
assert self.__velocity.shape == (2,)

def next(self) -> NDArray:
"""Generates the next velocity vector for the fluid simulation.
Expand Down
38 changes: 19 additions & 19 deletions src/boat_simulator/tests/unit/nodes/physics_engine/test_fluids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class TestFluidGenerator:
@pytest.mark.parametrize(
"vector",
[
(np.array([1, 0, 1])),
(np.array([0, 1, 0])),
(np.array([1, 0, 0])),
(np.array([1, 0])),
(np.array([0, 1])),
(np.array([1, 0])),
],
)
def test_velocity_constant(self, vector):
Expand All @@ -26,10 +26,10 @@ def test_velocity_constant(self, vector):
@pytest.mark.parametrize(
"mean, cov",
[
(np.array([1, 2, 0]), np.array([[2, 1, 1], [1, 2, 0.9], [1, 0.9, 1]])),
(np.array([4, 5, 3]), np.array([[3, 1, 1], [1, 3, 1], [1, 1, 2]])),
(np.array([100, 50, 20]), np.array([[10, 5, 5], [5, 10, 4.5], [5, 4.5, 5]])),
(np.array([120, 130, 40]), np.array([[10, 5, 1], [5, 10, 2], [1, 2, 5]])),
(np.array([1, 2]), np.array([[2, 1], [1, 2]])),
(np.array([4, 5]), np.array([[3, 1], [1, 3]])),
(np.array([100, 50]), np.array([[10, 5], [5, 10]])),
(np.array([120, 130]), np.array([[10, 5], [5, 10]])),
],
)
def test_velocity_random(self, mean, cov):
Expand All @@ -42,12 +42,12 @@ def test_velocity_random(self, mean, cov):
@pytest.mark.parametrize(
"vector",
[
(np.array([1, 0, 1])),
(np.array([0, 1, 0])),
(np.array([-1, 0, 1])),
(np.array([0, -1, 0])),
(np.array([1, 1, 1])),
(np.array([-1, -1, -1])),
(np.array([1, 0])),
(np.array([0, 1])),
(np.array([-1, 0])),
(np.array([0, -1])),
(np.array([1, 1])),
(np.array([-1, -1])),
],
)
def test_speed(self, vector):
Expand All @@ -60,12 +60,12 @@ def test_speed(self, vector):
@pytest.mark.parametrize(
"vector, expected_direction",
[
(np.array([1, 0, 1]), 0),
(np.array([0, 1, -3]), 90),
(np.array([-1, 0, -1]), -180),
(np.array([0, -1, 0]), -90),
(np.array([1, 1, 4]), 45),
(np.array([-1, -1, 6]), -135),
(np.array([1, 0]), 0),
(np.array([0, 1]), 90),
(np.array([-1, 0]), -180),
(np.array([0, -1]), -90),
(np.array([1, 1]), 45),
(np.array([-1, -1]), -135),
],
)
def test_direction(self, vector, expected_direction):
Expand Down
4 changes: 2 additions & 2 deletions src/global_launch/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ specified within an array: one for the `x` component, and one for the `y` compon

- _Description_: The mean value for the wind generated, expressed in kilometers per hour (km/h), for the multivariate
Gaussian generator.
- _Datatype_: `double` array, length 3
- _Datatype_: `double` array, length 2
- _Range_: `(0.0, MAX_DOUBLE)`

**`wind_generation.mvgaussian_params.cov`**
Expand All @@ -276,7 +276,7 @@ since ROS parameters do not support native 2D array types.

- _Description_: The mean value for the current generated, expressed in kilometers per hour (km/h), for the multivariate
Gaussian generator.
- _Datatype_: `double` array, length 3
- _Datatype_: `double` array, length 2
- _Range_: `(0.0, MAX_DOUBLE)`

**`current_generation.mvgaussian_params.cov`**
Expand Down
8 changes: 4 additions & 4 deletions src/global_launch/config/globals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ physics_engine_node:
value: [1.0, 0.0]
wind_generation:
mvgaussian_params:
mean: [5.0, 5.0, 0.0]
cov: "[[25.0, 10.0, 5.0], [10.0, 15.0, 2.0], [5.0, 2.0, 20.0]]"
mean: [5.0, 5.0]
cov: "[[25.0, 10.0], [10.0, 15.0]]"
current_generation:
mvgaussian_params:
mean: [1.0, 0.5, 0.0]
cov: "[[0.5, 0.1, 0.05], [0.1, 0.3, 0.02], [0.05, 0.02, 0.2]]"
mean: [1.0, 0.5]
cov: "[[0.5, 0.1], [0.1, 0.3]]"
data_collection_node:
ros__parameters:
file_name: 'ros_data_collection'
Expand Down

0 comments on commit 1be78b3

Please sign in to comment.