Skip to content

Commit e2cc54b

Browse files
shawnblakesleyMichelle Sintov
authored andcommitted
Disable nav map rendering in proximity mapper view (anki#52)
1 parent 94ccf10 commit e2cc54b

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

anki_vector/robot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self,
9999
enable_camera_feed: bool = False,
100100
enable_audio_feed: bool = False,
101101
enable_custom_object_detection: bool = False,
102-
enable_nav_map_feed: bool = False,
102+
enable_nav_map_feed: bool = None,
103103
show_viewer: bool = False,
104104
show_3d_viewer: bool = False,
105105
requires_behavior_control: bool = True):
@@ -169,13 +169,16 @@ def __init__(self,
169169

170170
self._enable_camera_feed = enable_camera_feed
171171
self._enable_audio_feed = enable_audio_feed
172-
self._enable_nav_map_feed = enable_nav_map_feed
172+
if enable_nav_map_feed is not None:
173+
self._enable_nav_map_feed = enable_nav_map_feed
174+
else:
175+
self._enable_nav_map_feed = False
173176
self._show_viewer = show_viewer
174177
if show_viewer and not enable_camera_feed:
175178
self.logger.warning("enable_camera_feed should be True for viewer to render correctly.")
176179
self._enable_camera_feed = True
177180
self._show_3d_viewer = show_3d_viewer
178-
if show_3d_viewer and not enable_nav_map_feed:
181+
if show_3d_viewer and enable_nav_map_feed is None:
179182
self.logger.warning("enable_nav_map_feed should be True for 3d viewer to render correctly.")
180183
self._enable_nav_map_feed = True
181184

anki_vector/viewer.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ def _update(self):
358358
359359
:param robot: the robot being updated by this View Controller
360360
"""
361-
while not self._close_event.is_set():
361+
close_event = self._close_event
362+
while close_event and not close_event.is_set():
362363
try:
363364
input_intents = self._input_intent_queue.get(True, timeout=2) # type: RobotControlIntents
364365

@@ -383,6 +384,7 @@ def _update(self):
383384
self.robot.motors.set_head_motor(input_intents.head_speed, _return_future=True)
384385
except mp.queues.Empty:
385386
pass
387+
close_event = self._close_event
386388

387389
def _on_robot_state_update(self, *_):
388390
"""Called from SDK process whenever the robot state is updated (so i.e. every engine tick).
@@ -397,10 +399,12 @@ def _on_robot_state_update(self, *_):
397399
"""
398400
from .opengl import opengl_vector
399401
world_frame = opengl_vector.WorldRenderFrame(self.robot)
400-
try:
401-
self._world_frame_queue.put(world_frame, False)
402-
except mp.queues.Full:
403-
pass
402+
queue = self._world_frame_queue
403+
if queue:
404+
try:
405+
queue.put(world_frame, False)
406+
except mp.queues.Full:
407+
pass
404408
# self._view_controller.update(self.robot) # TODO: <- sounds like this has something to do with keyboard input...
405409

406410
def _on_nav_map_update(self, _, msg):
@@ -414,7 +418,9 @@ def _on_nav_map_update(self, _, msg):
414418
We can safely capture any robot and world state here, and push to OpenGL
415419
(main) process via a multiprocessing queue.
416420
"""
417-
try:
418-
self._nav_map_queue.put(msg, False)
419-
except mp.queues.Full:
420-
pass
421+
queue = self._nav_map_queue
422+
if queue:
423+
try:
424+
queue.put(msg, False)
425+
except mp.queues.Full:
426+
pass

examples/apps/proximity_mapper/proximity_mapper.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ def open_point_sort_func(position: Vector3):
304304
if __name__ == '__main__':
305305
# Connect to the robot
306306
args = parse_command_args()
307-
with anki_vector.Robot(args.serial, enable_camera_feed=True, show_viewer=True, show_3d_viewer=True) as robotInstance:
307+
with anki_vector.Robot(args.serial,
308+
enable_camera_feed=True,
309+
show_viewer=True,
310+
enable_nav_map_feed=False,
311+
show_3d_viewer=True) as robotInstance:
308312
robotInstance.behavior.drive_off_charger()
309313
loop = asyncio.get_event_loop()
310314
loop.run_until_complete(map_explorer(robotInstance))

0 commit comments

Comments
 (0)