diff --git a/examples/server/v1/components.py b/examples/server/v1/components.py index fe8e72bca..2eac42377 100644 --- a/examples/server/v1/components.py +++ b/examples/server/v1/components.py @@ -184,7 +184,7 @@ def __init__(self, name: str): self.angular_pwr = Vector3(x=0, y=0, z=0) self.linear_vel = Vector3(x=0, y=0, z=0) self.angular_vel = Vector3(x=0, y=0, z=0) - self.props = Base.Properties(1.0, 1.0) + self.props = Base.Properties(1.0, 1.0, 1.0) super().__init__(name) async def move_straight(self, distance: int, velocity: float, extra: Optional[Dict[str, Any]] = None, **kwargs): diff --git a/src/viam/components/base/base.py b/src/viam/components/base/base.py index 6662c2f35..73a751770 100644 --- a/src/viam/components/base/base.py +++ b/src/viam/components/base/base.py @@ -23,6 +23,7 @@ class Base(ComponentBase): class Properties: width_meters: float turning_radius_meters: float + wheel_circumference_meters: float @abc.abstractmethod async def move_straight( diff --git a/src/viam/components/base/client.py b/src/viam/components/base/client.py index d05fdc71d..86992c1d5 100644 --- a/src/viam/components/base/client.py +++ b/src/viam/components/base/client.py @@ -119,7 +119,11 @@ async def get_properties(self, *, extra: Optional[Dict[str, Any]] = None, timeou extra = {} request = GetPropertiesRequest(name=self.name, extra=dict_to_struct(extra)) response: GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout) - return Base.Properties(width_meters=response.width_meters, turning_radius_meters=response.turning_radius_meters) + return Base.Properties( + width_meters=response.width_meters, + turning_radius_meters=response.turning_radius_meters, + wheel_circumference_meters=response.wheel_circumference_meters, + ) async def do_command( self, diff --git a/src/viam/components/base/service.py b/src/viam/components/base/service.py index 7b4ac06dc..ce73fc197 100644 --- a/src/viam/components/base/service.py +++ b/src/viam/components/base/service.py @@ -112,7 +112,11 @@ async def GetProperties(self, stream: Stream[GetPropertiesRequest, GetProperties base = self.get_resource(name) timeout = stream.deadline.time_remaining() if stream.deadline else None properties = await base.get_properties(timeout=timeout, metadata=stream.metadata) - response = GetPropertiesResponse(width_meters=properties.width_meters, turning_radius_meters=properties.turning_radius_meters) + response = GetPropertiesResponse( + width_meters=properties.width_meters, + turning_radius_meters=properties.turning_radius_meters, + wheel_circumference_meters=properties.wheel_circumference_meters, + ) await stream.send_message(response) async def DoCommand(self, stream: Stream[DoCommandRequest, DoCommandResponse]) -> None: diff --git a/tests/mocks/components.py b/tests/mocks/components.py index 46f67a49f..0d5dd0b6d 100644 --- a/tests/mocks/components.py +++ b/tests/mocks/components.py @@ -176,7 +176,7 @@ def __init__(self, name: str): self.geometries = GEOMETRIES self.extra: Optional[Dict[str, Any]] = None self.timeout: Optional[float] = None - self.props = Base.Properties(1.0, 1.0) + self.props = Base.Properties(1.0, 2.0, 3.0) super().__init__(name) async def move_straight( diff --git a/tests/test_base.py b/tests/test_base.py index 651f23d4b..3005f181c 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -107,6 +107,13 @@ async def test_is_moving(self, base: MockBase): assert base.stopped is True assert not await base.is_moving() + @pytest.mark.asyncio + async def test_get_properties(self, base: MockBase): + properties = await base.get_properties() + assert properties.width_meters == 1.0 + assert properties.turning_radius_meters == 2.0 + assert properties.wheel_circumference_meters == 3.0 + @pytest.mark.asyncio async def test_do(self, base: MockBase): command = {"command": "args"}