Skip to content

Commit

Permalink
Merge pull request #446 from pollen-robotics/445-check-core-mode
Browse files Browse the repository at this point in the history
445 check core mode
  • Loading branch information
cdussieux authored Nov 4, 2024
2 parents 69f42c6 + 9eb2a38 commit f878ffb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install_requires =
grpcio>=1.59.0, <=1.62.2
pyquaternion==0.9.9
opencv-python>=4.8.0, <4.9.0
reachy2-sdk-api>=1.0.9, <1.1.0
reachy2-sdk-api>=1.0.10, <1.1.0

[options.packages.find]
where = src
Expand Down
16 changes: 14 additions & 2 deletions src/reachy2_sdk/config/reachy_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing import Any, Dict, List, Optional

from reachy2_sdk_api.reachy_pb2 import Reachy
from reachy2_sdk_api.reachy_pb2 import Reachy, ReachyCoreMode

from ..parts.mobile_base import MobileBase

Expand Down Expand Up @@ -36,6 +36,8 @@ def __init__(self, reachy: Reachy) -> None:
self._disabled_parts: List[str] = []
self._mobile_base: Optional[MobileBase] = None

self._mode: ReachyCoreMode = reachy.info.core_mode

self._set_config(reachy)

def _set_config(self, msg: Reachy) -> None:
Expand Down Expand Up @@ -73,12 +75,14 @@ def _set_mobile_base(self, mobile_base: MobileBase) -> None:
def __repr__(self) -> str:
"""Clean representation of a ReachyInfo."""
repr_template = (
'<ReachyInfo robot_serial_number="{serial_number}" \n'
'<ReachyInfo mode="{mode}" \n'
' robot_serial_number="{serial_number}" \n'
' hardware_version="{hardware_version}" \n'
' core_software_version="{software_version}" \n'
" battery_voltage={battery_voltage} >"
)
return repr_template.format(
mode=self.mode,
serial_number=self.robot_serial_number,
hardware_version=self.hardware_version,
software_version=self.core_software_version,
Expand Down Expand Up @@ -112,3 +116,11 @@ def hardware_version(self) -> str:
def core_software_version(self) -> str:
"""Returns the robot's core software version."""
return self._core_software_version

@property
def mode(self) -> str:
"""Returns the robot's core mode.
Can be either "FAKE", "REAL" or "GAZEBO".
"""
return str(ReachyCoreMode.keys()[self._mode])

0 comments on commit f878ffb

Please sign in to comment.