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

id -1 on goto_singlejoint if part is off #460

Merged
merged 3 commits into from
Dec 9, 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
8 changes: 8 additions & 0 deletions src/reachy2_sdk/orbita/orbita.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ def is_on(self) -> bool:
"""
return not self._compliant

def is_off(self) -> bool:
"""Check if the actuator is currently compliant.

Returns:
`True` if the actuator is compliant (not stiff), `False` otherwise.
"""
return self._compliant

@property
def temperatures(self) -> Dict[str, float]:
"""Get the current temperatures of all the motors in the actuator.
Expand Down
4 changes: 4 additions & 0 deletions src/reachy2_sdk/orbita/orbita_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def goto(
Returns:
The GoToId associated with the movement command.
"""
if self._actuator._part.is_off():
self._actuator._logger.warning(f"{self._actuator._part._part_id.name} is off. No command sent.")
return GoToId(id=-1)

return self._actuator._part._goto_single_joint(
self._position_order_in_part,
goal_position=goal_position,
Expand Down
2 changes: 1 addition & 1 deletion src/reachy2_sdk/parts/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def look_at(
"""
if duration == 0:
raise ValueError("duration cannot be set to 0.")
if not self.neck.is_on():
if self.neck.is_off():
self._logger.warning("head.neck is off. No command sent.")
return GoToId(id=-1)

Expand Down
5 changes: 5 additions & 0 deletions tests/units/online/test_advanced_goto_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ def test_single_joint_goto(reachy_sdk_zeroed: ReachySDK) -> None:

assert np.allclose(reachy_sdk_zeroed.head.get_current_positions(), [15, 0, 10], atol=1e-01)

reachy_sdk_zeroed.turn_off()
assert reachy_sdk_zeroed.l_arm.shoulder.roll.goto(10).id == -1
assert reachy_sdk_zeroed.head.neck.roll.goto(10).id == -1
reachy_sdk_zeroed.turn_on()


@pytest.mark.online
def test_get_translation_by(reachy_sdk_zeroed: ReachySDK) -> None:
Expand Down