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

445 check core mode #446

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])