|
@@ -5,8 +5,8 @@ from PyGLWidget import PyGLWidget
|
|
|
from OpenGL.GL import *
|
|
|
import RobotData as RD
|
|
|
import message_pb2 as message
|
|
|
-
|
|
|
-
|
|
|
+from OpenGL.GLUT import glutStrokeCharacter
|
|
|
+from OpenGL import GLUT
|
|
|
class MapGLWidget(PyGLWidget):
|
|
|
|
|
|
nodes = {}
|
|
@@ -15,6 +15,9 @@ class MapGLWidget(PyGLWidget):
|
|
|
robot1_ = None
|
|
|
robot2_ = None
|
|
|
robotMain_ = None
|
|
|
+ def __init__(self):
|
|
|
+ PyGLWidget.__init__(self)
|
|
|
+ GLUT.glutInit()
|
|
|
def SetRobot1Instance(self, robot):
|
|
|
self.robot1_ = robot
|
|
|
def SetRobot2Instance(self, robot):
|
|
@@ -77,12 +80,27 @@ class MapGLWidget(PyGLWidget):
|
|
|
nx = math.cos(yaw) * x - y * math.sin(yaw)
|
|
|
ny = x * math.sin(yaw) + y * math.cos(yaw)
|
|
|
return [nx, ny]
|
|
|
- def Transform(self,point,yaw,dt):
|
|
|
+ @staticmethod
|
|
|
+ def Transform(point,yaw,dt):
|
|
|
[x,y]=point
|
|
|
[dx,dy]=dt
|
|
|
nx = math.cos(yaw) * x - y * math.sin(yaw)+dx
|
|
|
ny = x * math.sin(yaw) + y * math.cos(yaw)+dy
|
|
|
return [nx, ny]
|
|
|
+ def DrawText(self,pt,text,width,size,rgb):
|
|
|
+ glDisable(GL_TEXTURE_2D)
|
|
|
+ glLineWidth(width)
|
|
|
+ glPointSize(width)
|
|
|
+ r, g, b = rgb
|
|
|
+ glPushMatrix()
|
|
|
+ glColor3f(r, g, b)
|
|
|
+ glTranslatef(pt[0],pt[1],0)
|
|
|
+ s = size*0.005
|
|
|
+ glScalef(s, s, s)
|
|
|
+ for char in text:
|
|
|
+ GLUT.glutStrokeCharacter(GLUT.GLUT_STROKE_ROMAN, ord(char))
|
|
|
+ glPopMatrix()
|
|
|
+ glEnable(GL_TEXTURE_2D)
|
|
|
|
|
|
def drawAxis(self, pose, len, width):
|
|
|
[x, y, yaw] = pose
|
|
@@ -103,7 +121,7 @@ class MapGLWidget(PyGLWidget):
|
|
|
glVertex2d(x, y)
|
|
|
glVertex2d(y_source[0], y_source[1])
|
|
|
glEnd()
|
|
|
- def DrawAGV(self,pose,rgb):
|
|
|
+ def DrawAGV(self,pose,rgb,label=""):
|
|
|
[x,y,yaw]=pose
|
|
|
l=0.8 #轮长
|
|
|
L=1.3 #轴距
|
|
@@ -146,16 +164,20 @@ class MapGLWidget(PyGLWidget):
|
|
|
glVertex2d(pt7[0],pt7[1])
|
|
|
glEnd()
|
|
|
#绘制方向
|
|
|
- self.drawAxis(pose,1,5)
|
|
|
+ self.drawAxis(pose,1.2,5)
|
|
|
+ color=[1,1,1]
|
|
|
+ self.DrawText([x-W/2,y-l/2],label,3,1.5,color)
|
|
|
|
|
|
- def drawNode(self, node, size, color):
|
|
|
- [x, y] = node
|
|
|
+ def drawNode(self, pt, size, color,label=""):
|
|
|
+ [x, y] = pt
|
|
|
glPointSize(size)
|
|
|
glDepthMask(GL_FALSE)
|
|
|
glBegin(GL_POINTS)
|
|
|
glColor4f(color[0], color[1], color[2], 0.5)
|
|
|
glVertex2d(x, y)
|
|
|
glEnd()
|
|
|
+ l=len(label)
|
|
|
+ self.DrawText([x-l/8,y],label,size/10,1,[1,1,1])
|
|
|
'''glColor3f(1,1,1);
|
|
|
#glBegin(GL_TEXTURE)
|
|
|
glText'''
|
|
@@ -172,24 +194,19 @@ class MapGLWidget(PyGLWidget):
|
|
|
x = agv_statu.x
|
|
|
y = agv_statu.y
|
|
|
theta = agv_statu.theta
|
|
|
- self.DrawAGV([x, y, theta], robot.robotColor_)
|
|
|
+ self.DrawAGV([x, y, theta], robot.robotColor_,robot.name_)
|
|
|
|
|
|
if robot.timedNavStatu_.timeout() == False:
|
|
|
select_traj = robot.MpcSelectTraj()
|
|
|
predict_traj = robot.MpcPredictTraj()
|
|
|
self.drawTrajWithPoint(select_traj, 8, [1, 0, 1])
|
|
|
self.drawTrajWithPoint(predict_traj, 10, [0, 1, 1])
|
|
|
+
|
|
|
def paintGL(self):
|
|
|
PyGLWidget.paintGL(self)
|
|
|
- self.drawAxis([0, 0, 0], 5, 5)
|
|
|
+ self.drawAxis([0, 0, 0], 3, 2)
|
|
|
|
|
|
#绘制地图
|
|
|
- for node in self.nodes.items():
|
|
|
- [_, [type, point]] = node
|
|
|
- if type == "street_node":
|
|
|
- self.drawNode(point, 8, [0, 0, 1])
|
|
|
- if type == "space_node":
|
|
|
- self.drawNode(point, 8, [1, 1, 0])
|
|
|
for road in self.roads.items():
|
|
|
[_, value] = road
|
|
|
for nodeId in value:
|
|
@@ -197,7 +214,13 @@ class MapGLWidget(PyGLWidget):
|
|
|
if not nodeId == nextId:
|
|
|
[_, point1] = self.nodes[nodeId]
|
|
|
[_, point2] = self.nodes[nextId]
|
|
|
- self.drawEdge(point1, point2, 3., [0, 0.5, 0.5])
|
|
|
+ self.drawEdge(point1, point2, 7, [1,1,0])
|
|
|
+ for node in self.nodes.items():
|
|
|
+ [name, [type, point]] = node
|
|
|
+ if type == "street_node":
|
|
|
+ self.drawNode(point, 30, [0, 0.5, 0.5],name)
|
|
|
+ if type == "space_node":
|
|
|
+ self.drawNode(point, 20, [0.3, 0.8, 0.7],name)
|
|
|
|
|
|
#绘制agv相关数据,路径、轨迹、位姿
|
|
|
self.DrawRobotData(self.robot1_)
|