forked from xtdrone/XTDrone
update plotcanvas
This commit is contained in:
parent
b1e816b98a
commit
4b6bde22dc
Binary file not shown.
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 67 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -6,7 +6,7 @@ if __name__== '__main__':
|
|||
app = QApplication(sys.argv)
|
||||
ui = Gui2Ros()
|
||||
ui.show()
|
||||
sys.exit(app.exec_()) # main circulation
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,9 +6,8 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QSizePolicy
|
|||
|
||||
class PlotCanvas(FigureCanvas):
|
||||
|
||||
def __init__(self, parent=None, map='indoor1'):
|
||||
#fig = Figure()
|
||||
#self.Image_PreProcessing(map)
|
||||
def __init__(self, parent=None, Map='indoor1'):
|
||||
self.Image_PreProcessing(Map)
|
||||
img = plt.imread('./images/open.jpg')
|
||||
self.fig, self.ax = plt.subplots()
|
||||
self.ax.imshow(img, extent=[-50, 100, -50, 50])
|
||||
|
@ -25,6 +24,17 @@ class PlotCanvas(FigureCanvas):
|
|||
FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
FigureCanvas.updateGeometry(self)
|
||||
|
||||
#def Image_PreProcessing(self,map):
|
||||
# if map == 'robocup':
|
||||
# im = Image.open('/home/calt01-1302//xtdrone_pyqt5/images/robocup_world.jpg')
|
||||
def canvas_update(self, Map):
|
||||
self.Image_PreProcessing(Map)
|
||||
img = plt.imread('./images/open.jpg')
|
||||
self.ax.imshow(img, extent=[-50, 100, -50, 50])
|
||||
self.draw()
|
||||
|
||||
def Image_PreProcessing(self,Map):
|
||||
if Map == 'robocup':
|
||||
im = Image.open('./images/robocup_world.jpg')
|
||||
print('robocup')
|
||||
else:
|
||||
im = Image.open('./images/xt.jpg')
|
||||
imBackground = im.resize((876, 587)) #701 470 840 564
|
||||
imBackground.save('./images/open.jpg')
|
||||
|
|
|
@ -31,7 +31,6 @@ class Ros2Gui(QThread):
|
|||
self.multirotor_type + '_' + str(id_1) + "/mavros/local_position/pose", PoseStamped, self.local_pose_callback, id_1)
|
||||
self.local_vel_sub[id_1] = rospy.Subscriber(
|
||||
self.multirotor_type + '_' + str(id_1) + "/mavros/local_position/velocity_body", TwistStamped, self.local_vel_callback, id_1)
|
||||
self.leader_cmd_vel_sub = rospy.Subscriber('/xtdrone/' + self.multirotor_type + '_0' + '/cmd_vel_flu', Twist, self.hhhhhhh)
|
||||
|
||||
def run(self):
|
||||
print('RUN Thread')
|
||||
|
|
|
@ -18,7 +18,7 @@ class Gui2Ros(QMainWindow,xt_ui.Ui_MainWindow):
|
|||
super(Gui2Ros, self).__init__()
|
||||
self.setupUi(self)
|
||||
self.map = 'indoor1'
|
||||
# self.comboBox_maps.currentIndexChanged.connect(self.initplot)
|
||||
self.comboBox_maps.currentIndexChanged.connect(self.initplot)
|
||||
self.button_run.clicked.connect(self.startrun)
|
||||
self.cmd = ''
|
||||
self.ctrl_leader = True
|
||||
|
@ -26,20 +26,18 @@ class Gui2Ros(QMainWindow,xt_ui.Ui_MainWindow):
|
|||
self.close_flag = False
|
||||
self.local_pose = PoseStamped()
|
||||
self.local_vel = Twist()
|
||||
self.m = PlotCanvas(self, map=self.map)
|
||||
self.m = PlotCanvas(self, self.map)
|
||||
self.m.move(180, 0)
|
||||
self.x = [[]for i in range(self.multirotor_num)]
|
||||
self.y = [[] for i in range(self.multirotor_num)]
|
||||
|
||||
# def initplot(self):
|
||||
# self.map = self.comboBox_maps.currentText()
|
||||
# self.m = PlotCanvas(self, map=self.map)
|
||||
# self.m.move(180, 0)
|
||||
def initplot(self):
|
||||
self.map = self.comboBox_maps.currentText()
|
||||
self.m.canvas_update(self.map)
|
||||
|
||||
|
||||
def startrun(self):
|
||||
print 'start run!'
|
||||
# self.m = PlotCanvas(self, num=self.multirotor_num)
|
||||
# self.m.move(180, 0)
|
||||
self.pSend2ros = Process(target=self.run_process)
|
||||
self.pSend2ros.start()
|
||||
self.text_thread = Ros2Gui(self.multirotor_num, self.multirotor_type)
|
||||
|
|
Loading…
Reference in New Issue