Python gym.envs.classic_control.rendering.make_capsule() Examples
The following are 7
code examples of gym.envs.classic_control.rendering.make_capsule().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gym.envs.classic_control.rendering
, or try the search function
.
Example #1
Source File: pendulum.py From DRL_DeliveryDuel with MIT License | 6 votes |
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')
Example #2
Source File: env.py From autodrome with MIT License | 6 votes |
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()
Example #3
Source File: pendulum.py From ia-course with MIT License | 6 votes |
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')
Example #4
Source File: env.py From machina with MIT License | 6 votes |
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')
Example #5
Source File: pendulum.py From DQN-DDPG_Stock_Trading with MIT License | 6 votes |
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')
Example #6
Source File: pendulum.py From Hierarchical-Actor-Critic-HAC-PyTorch with MIT License | 6 votes |
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')
Example #7
Source File: pendulum.py From Hierarchical-Actor-Critic-HAC-PyTorch with MIT License | 4 votes |
def render_goal(self, goal, end_goal, 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) ################ goal ################ rod1 = rendering.make_goal_circ(1, .1) rod1.set_color(.8, .8, .3) self.pole_transform1 = rendering.Transform() rod1.add_attr(self.pole_transform1) self.viewer.add_geom(rod1) ###################################### ############## End Goal ############## rod2 = rendering.make_goal_circ(1, .1) rod2.set_color(.3, .3, .8) self.pole_transform2 = rendering.Transform() rod2.add_attr(self.pole_transform2) self.viewer.add_geom(rod2) ###################################### 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) self.pole_transform1.set_rotation(goal[0] + np.pi/2) self.pole_transform2.set_rotation(end_goal[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')