Skip to content

Commit d5d76c9

Browse files
author
Michelle Sintov
committed
Fix object sample code (#59)
* Update instructions to run the sample code testing * Update object property tests so they actually show data
1 parent 8bf74e6 commit d5d76c9

1 file changed

Lines changed: 165 additions & 44 deletions

File tree

anki_vector/objects.py

Lines changed: 165 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,24 @@ def last_tapped_time(self) -> float:
531531
532532
.. testcode::
533533
534+
import time
534535
import anki_vector
535536
536537
with anki_vector.Robot() as robot:
537-
robot.world.connect_cube()
538-
if robot.world.connected_light_cube:
539-
cube = robot.world.connected_light_cube
540-
print(f"{cube.last_tapped_time}")
538+
print("disconnecting from any connected cube...")
539+
robot.world.disconnect_cube()
540+
541+
time.sleep(2)
542+
543+
print("connect to a cube...")
544+
connectionResult = robot.world.connect_cube()
545+
546+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
547+
for _ in range(16):
548+
connected_cube = robot.world.connected_light_cube
549+
if connected_cube:
550+
print(f'last_tapped_time: {connected_cube.last_tapped_time}')
551+
time.sleep(0.5)
541552
"""
542553
return self._last_tapped_time
543554

@@ -547,13 +558,24 @@ def last_tapped_robot_timestamp(self) -> float:
547558
548559
.. testcode::
549560
561+
import time
550562
import anki_vector
551563
552564
with anki_vector.Robot() as robot:
553-
robot.world.connect_cube()
554-
if robot.world.connected_light_cube:
555-
cube = robot.world.connected_light_cube
556-
print(f"{cube.last_tapped_robot_timestamp}")
565+
print("disconnecting from any connected cube...")
566+
robot.world.disconnect_cube()
567+
568+
time.sleep(2)
569+
570+
print("connect to a cube...")
571+
connectionResult = robot.world.connect_cube()
572+
573+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
574+
for _ in range(16):
575+
connected_cube = robot.world.connected_light_cube
576+
if connected_cube:
577+
print(f'last_tapped_robot_timestamp: {connected_cube.last_tapped_robot_timestamp}')
578+
time.sleep(0.5)
557579
"""
558580
return self._last_tapped_robot_timestamp
559581

@@ -563,13 +585,24 @@ def last_moved_time(self) -> float:
563585
564586
.. testcode::
565587
588+
import time
566589
import anki_vector
567590
568591
with anki_vector.Robot() as robot:
569-
robot.world.connect_cube()
570-
if robot.world.connected_light_cube:
571-
cube = robot.world.connected_light_cube
572-
print(f"{cube.last_moved_time}")
592+
print("disconnecting from any connected cube...")
593+
robot.world.disconnect_cube()
594+
595+
time.sleep(2)
596+
597+
print("connect to a cube...")
598+
connectionResult = robot.world.connect_cube()
599+
600+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
601+
for _ in range(16):
602+
connected_cube = robot.world.connected_light_cube
603+
if connected_cube:
604+
print(f'last_moved_time: {connected_cube.last_moved_time}')
605+
time.sleep(0.5)
573606
"""
574607
return self._last_moved_time
575608

@@ -579,13 +612,24 @@ def last_moved_robot_timestamp(self) -> float:
579612
580613
.. testcode::
581614
615+
import time
582616
import anki_vector
583617
584618
with anki_vector.Robot() as robot:
585-
robot.world.connect_cube()
586-
if robot.world.connected_light_cube:
587-
cube = robot.world.connected_light_cube
588-
print(f"{cube.last_moved_robot_timestamp}")
619+
print("disconnecting from any connected cube...")
620+
robot.world.disconnect_cube()
621+
622+
time.sleep(2)
623+
624+
print("connect to a cube...")
625+
connectionResult = robot.world.connect_cube()
626+
627+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
628+
for _ in range(16):
629+
connected_cube = robot.world.connected_light_cube
630+
if connected_cube:
631+
print(f'last_moved_robot_timestamp: {connected_cube.last_moved_robot_timestamp}')
632+
time.sleep(0.5)
589633
"""
590634
return self._last_moved_robot_timestamp
591635

@@ -595,13 +639,24 @@ def last_moved_start_time(self) -> float:
595639
596640
.. testcode::
597641
642+
import time
598643
import anki_vector
599644
600645
with anki_vector.Robot() as robot:
601-
robot.world.connect_cube()
602-
if robot.world.connected_light_cube:
603-
cube = robot.world.connected_light_cube
604-
print(f"{cube.last_moved_start_time}")
646+
print("disconnecting from any connected cube...")
647+
robot.world.disconnect_cube()
648+
649+
time.sleep(2)
650+
651+
print("connect to a cube...")
652+
connectionResult = robot.world.connect_cube()
653+
654+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
655+
for _ in range(16):
656+
connected_cube = robot.world.connected_light_cube
657+
if connected_cube:
658+
print(f'last_moved_start_time: {connected_cube.last_moved_start_time}')
659+
time.sleep(0.5)
605660
"""
606661
return self._last_moved_start_time
607662

@@ -611,13 +666,24 @@ def last_moved_start_robot_timestamp(self) -> float:
611666
612667
.. testcode::
613668
669+
import time
614670
import anki_vector
615671
616672
with anki_vector.Robot() as robot:
617-
robot.world.connect_cube()
618-
if robot.world.connected_light_cube:
619-
cube = robot.world.connected_light_cube
620-
print(f"{cube.last_moved_start_robot_timestamp}")
673+
print("disconnecting from any connected cube...")
674+
robot.world.disconnect_cube()
675+
676+
time.sleep(2)
677+
678+
print("connect to a cube...")
679+
connectionResult = robot.world.connect_cube()
680+
681+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
682+
for _ in range(16):
683+
connected_cube = robot.world.connected_light_cube
684+
if connected_cube:
685+
print(f'last_moved_start_robot_timestamp: {connected_cube.last_moved_start_robot_timestamp}')
686+
time.sleep(0.5)
621687
"""
622688
return self._last_moved_start_robot_timestamp
623689

@@ -627,13 +693,24 @@ def last_up_axis_changed_time(self) -> float:
627693
628694
.. testcode::
629695
696+
import time
630697
import anki_vector
631698
632699
with anki_vector.Robot() as robot:
633-
robot.world.connect_cube()
634-
if robot.world.connected_light_cube:
635-
cube = robot.world.connected_light_cube
636-
print(f"{cube.last_up_axis_changed_time}")
700+
print("disconnecting from any connected cube...")
701+
robot.world.disconnect_cube()
702+
703+
time.sleep(2)
704+
705+
print("connect to a cube...")
706+
connectionResult = robot.world.connect_cube()
707+
708+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
709+
for _ in range(16):
710+
connected_cube = robot.world.connected_light_cube
711+
if connected_cube:
712+
print(f'last_up_axis_changed_time: {connected_cube.last_up_axis_changed_time}')
713+
time.sleep(0.5)
637714
"""
638715
return self._last_up_axis_changed_time
639716

@@ -643,13 +720,24 @@ def last_up_axis_changed_robot_timestamp(self) -> float:
643720
644721
.. testcode::
645722
723+
import time
646724
import anki_vector
647725
648726
with anki_vector.Robot() as robot:
649-
robot.world.connect_cube()
650-
if robot.world.connected_light_cube:
651-
cube = robot.world.connected_light_cube
652-
print(f"{cube.last_up_axis_changed_robot_timestamp}")
727+
print("disconnecting from any connected cube...")
728+
robot.world.disconnect_cube()
729+
730+
time.sleep(2)
731+
732+
print("connect to a cube...")
733+
connectionResult = robot.world.connect_cube()
734+
735+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
736+
for _ in range(16):
737+
connected_cube = robot.world.connected_light_cube
738+
if connected_cube:
739+
print(f'last_up_axis_changed_robot_timestamp: {connected_cube.last_up_axis_changed_robot_timestamp}')
740+
time.sleep(0.5)
653741
"""
654742
return self._last_up_axis_changed_robot_timestamp
655743

@@ -659,13 +747,24 @@ def up_axis(self) -> protocol.UpAxis:
659747
660748
.. testcode::
661749
750+
import time
662751
import anki_vector
663752
664753
with anki_vector.Robot() as robot:
665-
robot.world.connect_cube()
666-
if robot.world.connected_light_cube:
667-
cube = robot.world.connected_light_cube
668-
print(f"{cube.up_axis}")
754+
print("disconnecting from any connected cube...")
755+
robot.world.disconnect_cube()
756+
757+
time.sleep(2)
758+
759+
print("connect to a cube...")
760+
connectionResult = robot.world.connect_cube()
761+
762+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
763+
for _ in range(16):
764+
connected_cube = robot.world.connected_light_cube
765+
if connected_cube:
766+
print(f'up_axis: {connected_cube.up_axis}')
767+
time.sleep(0.5)
669768
"""
670769
return self._up_axis
671770

@@ -675,13 +774,24 @@ def is_moving(self) -> bool:
675774
676775
.. testcode::
677776
777+
import time
678778
import anki_vector
679779
680780
with anki_vector.Robot() as robot:
681-
robot.world.connect_cube()
682-
if robot.world.connected_light_cube:
683-
cube = robot.world.connected_light_cube
684-
print(f"{cube.is_moving}")
781+
print("disconnecting from any connected cube...")
782+
robot.world.disconnect_cube()
783+
784+
time.sleep(2)
785+
786+
print("connect to a cube...")
787+
connectionResult = robot.world.connect_cube()
788+
789+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
790+
for _ in range(16):
791+
connected_cube = robot.world.connected_light_cube
792+
if connected_cube:
793+
print(f'is_moving: {connected_cube.is_moving}')
794+
time.sleep(0.5)
685795
"""
686796
return self._is_moving
687797

@@ -707,13 +817,24 @@ def top_face_orientation_rad(self) -> float:
707817
708818
.. testcode::
709819
820+
import time
710821
import anki_vector
711822
712823
with anki_vector.Robot() as robot:
713-
robot.world.connect_cube()
714-
if robot.world.connected_light_cube:
715-
cube = robot.world.connected_light_cube
716-
print(f"{cube.top_face_orientation_rad}")
824+
print("disconnecting from any connected cube...")
825+
robot.world.disconnect_cube()
826+
827+
time.sleep(2)
828+
829+
print("connect to a cube...")
830+
connectionResult = robot.world.connect_cube()
831+
832+
print("For the next 8 seconds, please tap and move the cube. Cube properties will be logged to console.")
833+
for _ in range(16):
834+
connected_cube = robot.world.connected_light_cube
835+
if connected_cube:
836+
print(f'top_face_orientation_rad: {connected_cube.top_face_orientation_rad}')
837+
time.sleep(0.5)
717838
"""
718839
return self._top_face_orientation_rad
719840

0 commit comments

Comments
 (0)