本文整理汇总了Python中pybullet.DIRECT属性的典型用法代码示例。如果您正苦于以下问题:Python pybullet.DIRECT属性的具体用法?Python pybullet.DIRECT怎么用?Python pybullet.DIRECT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pybullet
的用法示例。
在下文中一共展示了pybullet.DIRECT属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, connection_mode=None):
"""Creates a Bullet client and connects to a simulation.
Args:
connection_mode:
`None` connects to an existing simulation or, if fails, creates a
new headless simulation,
`pybullet.GUI` creates a new simulation with a GUI,
`pybullet.DIRECT` creates a headless simulation,
`pybullet.SHARED_MEMORY` connects to an existing simulation.
"""
self._shapes = {}
if connection_mode is None:
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
if self._client >= 0:
return
else:
connection_mode = pybullet.DIRECT
self._client = pybullet.connect(connection_mode)
示例2: open
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def open(self):
'''
Decide how we will create our interface to the underlying simulation.
We can create a GUI connection or something else.
'''
options = ""
if self.opengl2:
connect_type = pb.GUI
options = "--opengl2"
elif self.gui:
connect_type = pb.GUI
else:
connect_type = pb.DIRECT
self.client = pb.connect(connect_type, options=options)
GRAVITY = (0,0,-9.8)
pb.setGravity(*GRAVITY)
# place the robot in the world and set up the task
self.task.setup()
示例3: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, connection_mode=None):
"""Creates a Bullet client and connects to a simulation.
Args:
connection_mode:
`None` connects to an existing simulation or, if fails, creates a
new headless simulation,
`pybullet.GUI` creates a new simulation with a GUI,
`pybullet.DIRECT` creates a headless simulation,
`pybullet.SHARED_MEMORY` connects to an existing simulation.
"""
self._shapes = {}
if connection_mode is None:
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
if self._client >= 0:
return
else:
connection_mode = pybullet.DIRECT
self._client = pybullet.connect(connection_mode)
示例4: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, connection_mode=pybullet.DIRECT, options=""):
"""Create a simulation and connect to it."""
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
if(self._client<0):
print("options=",options)
self._client = pybullet.connect(connection_mode,options=options)
self._shapes = {}
示例5: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, connection_mode=pybullet.DIRECT, options=""):
"""Create a simulation and connect to it."""
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
if self._client < 0:
print("options=", options)
self._client = pybullet.connect(connection_mode, options=options)
self._shapes = {}
示例6: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, opts):
self.gui = opts.gui
self.max_episode_len = opts.max_episode_len
self.delay = opts.delay if self.gui else 0.0
# do some parameter setting from your parser arguments and add other configurations
# how many time to repeat each action per step().
# and how many sim steps to do per state capture
# (total number of sim steps = action_repeats * steps_per_repeat
self.repeats = opts.action_repeats
self.steps_per_repeat = opts.steps_per_repeat
# setup bullet
p.connect(p.GUI if self.gui else p.DIRECT)
p.setGravity(0,0,-9.81)
PybulletMujocoEnv.__init__(self, "envs/models/mjcf/hopper.xml", "walker", 0.02, frame_skip=2, action_dim=3, obs_dim=8, repeats=self.repeats)
self.torso = self.parts["torso"]
self.foot = self.parts["foot"]
self.thigh_joint = self.joints["thigh_joint"]
self.leg_joint = self.joints["leg_joint"]
self.foot_joint = self.joints["foot_joint"]
self.metadata = {
'discrete_actions' : False,
'continuous_actions': True,
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip))
}
示例7: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, opts):
self.gui = opts.gui
self.max_episode_len = opts.max_episode_len
self.delay = opts.delay if self.gui else 0.0
# do some parameter setting from your parser arguments and add other configurations
# how many time to repeat each action per step().
# and how many sim steps to do per state capture
# (total number of sim steps = action_repeats * steps_per_repeat
self.repeats = opts.action_repeats
self.steps_per_repeat = opts.steps_per_repeat
# setup bullet
p.connect(p.GUI if self.gui else p.DIRECT)
PybulletMujocoEnv.__init__(self, "envs/models/mjcf/reacher.xml", "walker", 0.02, frame_skip=2, action_dim=2, obs_dim=9, repeats=self.repeats)
self.target_x = self.joints["target_x"]
self.target_y = self.joints["target_y"]
self.fingertip = self.parts["fingertip"]
self.target = self.parts["target"]
self.central_joint = self.joints["joint0"]
self.elbow_joint = self.joints["joint1"]
self.metadata = {
'discrete_actions' : False,
'continuous_actions': True,
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip))
}
示例8: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, opts):
self.gui = opts.gui
self.max_episode_len = opts.max_episode_len
self.delay = opts.delay if self.gui else 0.0
# do some parameter setting from your parser arguments and add other configurations
# threshold for angle from z-axis.
# if x or y > this value we finish episode.
self.angle_threshold = 0.26 # radians; ~= 15deg
# initial push force. this should be enough that taking no action will always
# result in pole falling after initial_force_steps but not so much that you
# can't recover. see also initial_force_steps.
self.initial_force = opts.initial_force
# number of sim steps initial force is applied.
# (see initial_force)
self.initial_force_steps = 30
# whether we do initial push in a random direction
# if false we always push with along x-axis (simplee problem, useful for debugging)
self.random_theta = not opts.no_random_theta
# how many time to repeat each action per step().
# and how many sim steps to do per state capture
# (total number of sim steps = action_repeats * steps_per_repeat
self.repeats = opts.action_repeats
self.steps_per_repeat = opts.steps_per_repeat
self.swingup = opts.swingup
self.reward_calc = opts.reward_calc
# setup bullet
p.connect(p.GUI if self.gui else p.DIRECT)
p.setGravity(0, 0, -9.81) # maybe you need gravity?
PybulletMujocoEnv.__init__(self, "envs/models/mjcf/inverted_pendulum.xml", "walker", 0.02, frame_skip=2, action_dim=1, obs_dim=5, repeats=self.repeats)
self.slider = self.joints["slider"]
self.polejoint = self.joints["hinge"]
self.metadata = {
'discrete_actions' : False,
'continuous_actions': True,
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip))
}
示例9: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, opts):
self.gui = opts.gui
self.max_episode_len = opts.max_episode_len
self.delay = opts.delay if self.gui else 0.0
# do some parameter setting from your parser arguments and add other configurations
# threshold for angle from z-axis.
# if x or y > this value we finish episode.
self.angle_threshold = 0.26 # radians; ~= 15deg
# initial push force. this should be enough that taking no action will always
# result in pole falling after initial_force_steps but not so much that you
# can't recover. see also initial_force_steps.
self.initial_force = opts.initial_force
# number of sim steps initial force is applied.
# (see initial_force)
self.initial_force_steps = 30
# whether we do initial push in a random direction
# if false we always push with along x-axis (simplee problem, useful for debugging)
self.random_theta = not opts.no_random_theta
# how many time to repeat each action per step().
# and how many sim steps to do per state capture
# (total number of sim steps = action_repeats * steps_per_repeat
self.repeats = opts.action_repeats
self.steps_per_repeat = opts.steps_per_repeat
self.swingup = opts.swingup
self.reward_calc = opts.reward_calc
# setup bullet
p.connect(p.GUI if self.gui else p.DIRECT)
p.setGravity(0, 0, -9.81) # maybe you need gravity?
PybulletMujocoEnv.__init__(self, "envs/models/mjcf/inverted_double_pendulum.xml", "walker", 0.02, frame_skip=2, action_dim=1, obs_dim=8, repeats=self.repeats)
self.slider = self.joints["slider"]
self.polejoint = self.joints["hinge"]
self.pole2joint = self.joints["hinge2"]
self.metadata = {
'discrete_actions' : False,
'continuous_actions': True,
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip))
}
示例10: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import DIRECT [as 别名]
def __init__(self, opts):
self.gui = opts.gui
self.max_episode_len = opts.max_episode_len
self.delay = opts.delay if self.gui else 0.0
self.metadata = {
'discrete_actions' : True,
'continuous_actions' : True,
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second' : int(np.round(1.0 / 25.0))
}
# do some parameter setting from your parser arguments and add other configurations
self.control_type = opts.control_type
# force to apply per action simulation step.
# in the discrete case this is the fixed gain applied
# in the continuous case each x/y is in range (-G, G)
self.action_gain = opts.action_gain # scale of control (position, velocity)
self.action_force = opts.action_force # Newton
# how many time to repeat each action per step().
# and how many sim steps to do per state capture
# (total number of sim steps = action_repeats * steps_per_repeat
self.repeats = opts.action_repeats
self.steps_per_repeat = opts.steps_per_repeat
self.random_initial_position = opts.random_initial_position
# setup bullet
p.connect(p.GUI if self.gui else p.DIRECT)
p.setGravity(0, 0, opts.gravity_force) # maybe you need gravity?
p.loadURDF("envs/models/ground.urdf", 0,0,0, 0,0,0,1)
# load your models
if opts.morphology_type == 1:
self.body = p.loadURDF("envs/models/simple-snakev0.urdf",0,0,2, 0,0,0,1)
elif opts.morphology_type == 2:
self.body = p.loadURDF("envs/models/springy-snakev0.urdf",0,0,2, 0,0,0,1)
elif opts.morphology_type == 3:
self.body = p.loadURDF("envs/models/phantomx/phantomx.urdf",0,0,2, 0,0,0,1)
self.initPosition, self.initOrientation = p.getBasePositionAndOrientation(self.body)
self.num_joints = p.getNumJoints(self.body)
self.velocityHelper = VelocityHelper(self.body)
self.reward = RewardFunction(self.body, RewardFunction.PositionReward, RewardFunction.XAxis) # velocity in X axis dimension gets rewarded
# in the low dimensional case obs space for problem is (R, num_links, 13)
# R = number of repeats
# num joints + 1 = number of links of snake
# 13d tuple for pos + orientation + velocities (angular velocity in euler)
self.state_shape = (self.repeats, p.getNumJoints(self.body)+1, 13)
# no state until reset.
self.state = np.empty(self.state_shape, dtype=np.float32)