Skip to content

Commit

Permalink
Enable interactive mode in GUI MatPlotLib canvas (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass authored Oct 14, 2024
1 parent b8b8a88 commit 5736c29
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyrobosim/pyrobosim/gui/world_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import threading
import warnings
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg
from matplotlib.pyplot import Circle
Expand Down Expand Up @@ -126,6 +127,7 @@ def __init__(
self.fig = Figure(dpi=dpi, tight_layout=True)
self.axes = self.fig.add_subplot(111)
super(WorldCanvas, self).__init__(self.fig)
plt.ion()

self.main_window = main_window
self.world = world
Expand Down Expand Up @@ -417,14 +419,13 @@ def nav_animation_callback(self):
# Check if any robot is currently navigating.
nav_status = [robot.is_moving() for robot in world.robots]
if any(nav_status):
self.update_robots_plot()

# Show the state of the currently selected robot
cur_robot = world.gui.get_current_robot()
if cur_robot is not None and cur_robot.is_moving():
self.show_world_state(cur_robot)
world.gui.set_buttons_during_action(False)

self.update_robots_plot()
self.draw_and_sleep()

def update_robots_plot(self):
Expand Down

0 comments on commit 5736c29

Please sign in to comment.