本文整理汇总了Python中gym.envs.classic_control.rendering.Transform方法的典型用法代码示例。如果您正苦于以下问题:Python rendering.Transform方法的具体用法?Python rendering.Transform怎么用?Python rendering.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块gym.envs.classic_control.rendering的用法示例。
在下文中一共展示了rendering.Transform方法的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render
点赞 6
# 需要导入模块: from gym.envs.classic_control import rendering [as 别名]
# 或者: from gym.envs.classic_control.rendering import Transform [as 别名]
def render(self, mode='human'):
if self.viewer is None:
from gym.envs.classic_control import rendering
self.viewer = rendering.Viewer(500,500)
self.viewer.set_bounds(-2.2,2.2,-2.2,2.2)
rod = rendering.make_capsule(1, .2)
rod.set_color(.8, .3, .3)
self.pole_transform = rendering.Transform()
rod.add_attr(self.pole_transform)
self.viewer.add_geom(rod)
axle = rendering.make_circle(.05)
axle.set_color(0,0,0)
self.viewer.add_geom(axle)
fname = path.join(path.dirname(__file__), "assets/clockwise.png")
self.img = rendering.Image(fname, 1., 1.)
self.imgtrans = rendering.Transform()
self.img.add_attr(self.imgtrans)
self.viewer.add_onetime(self.img)
self.pole_transform.set_rotation(self.state[0] + np.pi/2)
if self.last_u:
self.imgtrans.scale = (-self.last_u/2, np.abs(self.last_u)/2)
return self.viewer.render(return_rgb_array = mode=='rgb_array')
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:27,
示例2: _render_human
点赞 6
# 需要导入模块: from gym.envs.classic_control import rendering [as 别名]
# 或者: from gym.envs.classic_control.rendering import Transform [as 别名]
def _render_human(self):
if self.viewer is None:
from gym.envs.classic_control import rendering
self.viewer = rendering.Viewer(600, 600)
self.viewer.set_bounds(-220, +220, -220, +220)
truck = rendering.make_capsule(8, 4)
truck.set_color(0.0, 0.0, 0.0)
self.truck_transform = rendering.Transform()
truck.add_attr(self.truck_transform)
self.viewer.add_geom(truck)
for node in self.policeman.map['nodes'].values():
circle = rendering.make_circle(2)
circle.set_color(0.6, 0.6, 0.6)
dot_transform = rendering.Transform((node['position']['x'], -node['position']['z']))
circle.add_attr(dot_transform)
self.viewer.add_geom(circle)
position, orientation = self.data.worldPlacement.position, self.data.worldPlacement.orientation
self.truck_transform.set_rotation(orientation.heading * math.pi * 2 - math.pi / 2)
self.truck_transform.set_translation(position.x, -position.z)
return self.viewer.render()
开发者ID:vojtamolda,项目名称:autodrome,代码行数:25,
示例3: render
点赞 6
# 需要导入模块: from gym.envs.classic_control import rendering [as 别名]
# 或者: from gym.envs.classic_control.rendering import Transform [as 别名]
def render(self, mode='human'):
if self.viewer is None:
from gym.envs.classic_control import rendering
self.viewer = rendering.Viewer(500, 500)
self.viewer.set_bounds(-2.2, 2.2, -2.2, 2.2)
rod = rendering.make_capsule(1, .2)
rod.set_color(.8, .3, .3)
self.pole_transform = rendering.Transform()
rod.add_attr(self.pole_transform)
self.viewer.add_geom(rod)
axle = rendering.make_circle(.05)
axle.set_color(0, 0, 0)
self.viewer.add_geom(axle)
fname = path.join(path.dirname(__file__), "assets/clockwise.png")
self.img = rendering.Image(fname, 1., 1.)
self.imgtrans = rendering.Transform()
self.img.add_attr(self.imgtrans)
self.viewer.add_onetime(self.img)
self.pole_transform.set_rotation(self.state[0] + np.pi/2)
if self.last_u:
self.imgtrans.scale = (-self.last_u/2, np.abs(self.last_u)/2)
return self.viewer.render(return_rgb_array=mode == 'rgb_array')
开发者ID:DeepX-inc,项目名称:machina,代码行数:27,
示例4: render
点赞 5
# 需要导入模块: from gym.envs.classic_control import rendering [as 别名]
# 或者: from gym.envs.classic_control.rendering import Transform [as 别名]
def render(self, mode='human'):
from gym.envs.classic_control import rendering
if self.viewer is None:
self.viewer = rendering.Viewer(VIEWPORT_W, VIEWPORT_H)
self.viewer.set_bounds(0, VIEWPORT_W/SCALE, 0, VIEWPORT_H/SCALE)
for obj in self.particles:
obj.ttl -= 0.15
obj.color1 = (max(0.2,0.2+obj.ttl), max(0.2,0.5*obj.ttl), max(0.2,0.5*obj.ttl))
obj.color2 = (max(0.2,0.2+obj.ttl), max(0.2,0.5*obj.ttl), max(0.2,0.5*obj.ttl))
self._clean_particles(False)
for p in self.sky_polys:
self.viewer.draw_polygon(p, color=(0,0,0))
for obj in self.particles + self.drawlist:
for f in obj.fixtures:
trans = f.body.transform
if type(f.shape) is circleShape:
t = rendering.Transform(translation=trans*f.shape.pos)
self.viewer.draw_circle(f.shape.radius, 20, color=obj.color1).add_attr(t)
self.viewer.draw_circle(f.shape.radius, 20, color=obj.color2, filled=False, linewidth=2).add_attr(t)
else:
path = [trans*v for v in f.shape.vertices]
self.viewer.draw_polygon(path, color=obj.color1)
path.append(path[0])
self.viewer.draw_polyline(path, color=obj.color2, linewidth=2)
for x in [self.helipad_x1, self.helipad_x2]:
flagy1 = self.helipad_y
flagy2 = flagy1 + 50/SCALE
self.viewer.draw_polyline( [(x, flagy1), (x, flagy2)], color=(1,1,1) )
self.viewer.draw_polygon( [(x, flagy2), (x, flagy2-10/SCALE), (x+25/SCALE, flagy2-5/SCALE)], color=(0.8,0.8,0) )
return self.viewer.render(return_rgb_array = mode=='rgb_array')
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:38,
示例5: render
点赞 5
# 需要导入模块: from gym.envs.classic_control import rendering [as 别名]
# 或者: from gym.envs.classic_control.rendering import Transform [as 别名]
def render(self, mode='human'):
from gym.envs.classic_control import rendering
s = self.state
if self.viewer is None:
self.viewer = rendering.Viewer(500,500)
self.viewer.set_bounds(-2.2,2.2,-2.2,2.2)
if s is None: return None
p1 = [-self.LINK_LENGTH_1 *
np.cos(s[0]), self.LINK_LENGTH_1 * np.sin(s[