Skip to content

Commit 38a31da

Browse files
committed
added attention_transfer event and get_latest_attention_transfer method
1 parent f495468 commit 38a31da

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

anki_vector/events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Events(Enum):
3636
# Robot
3737
robot_state = "robot_state" #: Robot event containing changes to the robot's state.
3838
stimulation_info = "stimulation_info" #: Robot event containing information about the robot's stimulation.
39+
attention_transfer = "attention_transfer" #: Robot event triggered when an attention cannot be fullfilled
3940
mirror_mode_disabled = "mirror_mode_disabled" # : Robot event triggered when mirror mode (camera feed displayed on robot's face) is automatically disabled due to SDK no longer having control of the robot.
4041
vision_modes_auto_disabled = "vision_modes_auto_disabled" # : Robot event triggered when all vision modes are automatically disabled due to the SDK no longer having control of the robot.
4142

anki_vector/robot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,26 @@ async def get_battery_state(self) -> protocol.BatteryStateResponse:
796796
get_battery_state_request = protocol.BatteryStateRequest()
797797
return await self.conn.grpc_interface.BatteryState(get_battery_state_request)
798798

799+
@on_connection_thread(requires_control=False)
800+
async def get_latest_attention_transfer(self) -> protocol.LatestAttentionTransferResponse:
801+
"""Get the reason why the latest attention transfer failed, if any
802+
803+
Returns <AttentionTransfer> with the fields:
804+
- reason <AttentionTransferReason>
805+
- seconds_ago
806+
807+
.. testcode::
808+
809+
import anki_vector
810+
with anki_vector.Robot() as robot:
811+
att_trans = robot.get_latest_attention_transfer()
812+
if att_trans:
813+
print("Last attention transfer failed because of: {0}".format(att_trans.reason))
814+
"""
815+
latest_attention_transfer = protocol.LatestAttentionTransferRequest()
816+
return await self.conn.grpc_interface.GetLatestAttentionTransfer(latest_attention_transfer)
817+
818+
799819
@on_connection_thread(requires_control=False)
800820
async def get_version_state(self) -> protocol.VersionStateResponse:
801821
"""Get the versioning information for Vector, including Vector's os_version and engine_build_id.

0 commit comments

Comments
 (0)