学习DDPG机械手臂算法笔记

1.关于pyglet点击打开链接 一个实时刷新的做动画模块

    pyglet.gl.glClearColor(1, 1, 1, 1) 窗口背景颜色

    self.batch=pyglet.graphics.Batch()点击打开链接 pyglet.graphics.Batch()用于产生一个图形的数组,存储在batch中

    点击打开链接

    self.batch.draw()  将列表信息画出来

    pyglet.gl模型,用来绘制各种图形 点击打开链接

    self.point = self.batch.add(
			4, pyglet.gl.GL_QUADS, None, #4corners
			('v2f', [50, 50,    #x1,y1
					50, 100,   #x2,y2
					100, 100,  #x3,y3
					100, 50]), #x4,y4
			('c3B', (86, 109, 249) * 4)) #color

v2f表示4个点的位置坐标,c3B表示每个点的颜色(三原色表示)。

2.python 函数 super 点击打开链接 点击打开链接

class Viewer(pyglet.window.Window):
	bar_thc=5 #thin is 5

	def __init__(self, arm_info, goal):

		super(Viewer, self).__init__(width=400, height=400, resizable=False, caption='Arm',vsync=False)

关于类的继承,Viewer继承了pyglet.window.Window这个类?

3.dispatch_event('on_draw') dispatch_event是时间触发器?相当于触发了on_draw这个函数。

4.numpy.zeros(shape,dtype) 点击打开链接 要弄清楚每个矩阵的维度,代表意义。    

self.arm_info=np.zeros(
			2, dtype=[('l', np.float32), ('r', np.float32)]) #create a 2,2 matrix

self.arm_info 是一个 2x2 的表, self.arm_info['l'] 有两个信息, 都是两段手臂的长度,self.arm_info['r'] 记录的则是当前两段手臂的旋转角度. 之后手臂做动作时, 都只是这个旋转角度的变化.

self.arm_info是一个2*2的表,self.arm_info['l']有两个信息,都是两段手臂的长度,self.arm_info['r']记录两段手臂的旋转角度。

5.np.concatenate 点击打开链接 按行或列进行数组拼接

6.其他

了解一下OpenAIgym.

如果自己画的话应该使用pyglet

简介:pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. It supports windowing, user interface event handling, OpenGL graphics, loading images and videos, and playing sounds and music. pyglet works on Windows, OS X and Linux.

其中OpenGL的百度百科官网,是一个图形程序接口、调用方便的底层图形库。

API的百度百科

源代码

猜你喜欢

转载自blog.csdn.net/AndesStay/article/details/81086869