本文整理汇总了Python中pybullet.setTimeStep方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.setTimeStep方法的具体用法?Python pybullet.setTimeStep怎么用?Python pybullet.setTimeStep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.setTimeStep方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def _reset(self):
#print("KukaGymEnv _reset")
self.terminated = 0
p.resetSimulation()
p.setPhysicsEngineParameter(numSolverIterations=150)
p.setTimeStep(self._timeStep)
p.loadURDF(os.path.join(self._urdfRoot,"plane.urdf"),[0,0,-1])
p.loadURDF(os.path.join(self._urdfRoot,"table/table.urdf"), 0.5000000,0.00000,-.820000,0.000000,0.000000,0.0,1.0)
xpos = 0.55 +0.12*random.random()
ypos = 0 +0.2*random.random()
ang = 3.14*0.5+3.1415925438*random.random()
orn = p.getQuaternionFromEuler([0,0,ang])
self.blockUid =p.loadURDF(os.path.join(self._urdfRoot,"block.urdf"), xpos,ypos,-0.15,orn[0],orn[1],orn[2],orn[3])
p.setGravity(0,0,-10)
self._kuka = kuka.Kuka(urdfRootPath=self._urdfRoot, timeStep=self._timeStep)
self._envStepCounter = 0
p.stepSimulation()
self._observation = self.getExtendedObservation()
return np.array(self._observation)
示例2: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def _reset(self):
# print("-----------reset simulation---------------")
p.resetSimulation()
self.cartpole = p.loadURDF(os.path.join(pybullet_data.getDataPath(),"cartpole.urdf"),[0,0,0])
self.timeStep = 0.01
p.setJointMotorControl2(self.cartpole, 1, p.VELOCITY_CONTROL, force=0)
p.setGravity(0,0, -10)
p.setTimeStep(self.timeStep)
p.setRealTimeSimulation(0)
initialCartPos = self.np_random.uniform(low=-0.5, high=0.5, size=(1,))
initialAngle = self.np_random.uniform(low=-0.5, high=0.5, size=(1,))
p.resetJointState(self.cartpole, 1, initialAngle)
p.resetJointState(self.cartpole, 0, initialCartPos)
self.state = p.getJointState(self.cartpole, 1)[0:2] + p.getJointState(self.cartpole, 0)[0:2]
return np.array(self.state)
示例3: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def _reset(self):
self.terminated = 0
p.resetSimulation()
p.setPhysicsEngineParameter(numSolverIterations=150)
p.setTimeStep(self._timeStep)
p.loadURDF(os.path.join(self._urdfRoot,"plane.urdf"),[0,0,-1])
p.loadURDF(os.path.join(self._urdfRoot,"table/table.urdf"), 0.5000000,0.00000,-.820000,0.000000,0.000000,0.0,1.0)
xpos = 0.5 +0.2*random.random()
ypos = 0 +0.25*random.random()
ang = 3.1415925438*random.random()
orn = p.getQuaternionFromEuler([0,0,ang])
self.blockUid =p.loadURDF(os.path.join(self._urdfRoot,"block.urdf"), xpos,ypos,-0.1,orn[0],orn[1],orn[2],orn[3])
p.setGravity(0,0,-10)
self._kuka = kuka.Kuka(urdfRootPath=self._urdfRoot, timeStep=self._timeStep)
self._envStepCounter = 0
p.stepSimulation()
self._observation = self.getExtendedObservation()
return np.array(self._observation)
示例4: _setup
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def _setup(self):
"""Sets up the robot + tray + objects.
"""
pybullet.resetSimulation(physicsClientId=self.cid)
pybullet.setPhysicsEngineParameter(numSolverIterations=150,
physicsClientId=self.cid)
# pybullet.setTimeStep(self._time_step, physicsClientId=self.cid)
pybullet.setGravity(0, 0, -10, physicsClientId=self.cid)
plane_path = os.path.join(self._urdf_root, 'plane.urdf')
pybullet.loadURDF(plane_path, [0, 0, -1],
physicsClientId=self.cid)
table_path = os.path.join(self._urdf_root, 'table/table.urdf')
pybullet.loadURDF(table_path, [0.0, 0.0, -.65],
[0., 0., 0., 1.], physicsClientId=self.cid)
# Load the target object
duck_path = os.path.join(self._urdf_root, 'duck_vhacd.urdf')
pos = [0]*3
orn = [0., 0., 0., 1.]
self._target_uid = pybullet.loadURDF(
duck_path, pos, orn, physicsClientId=self.cid)
示例5: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def _reset(self):
# reset is called once at initialization of simulation
self.vt = 0
self.vd = 0
self.maxV = 24.6 # 235RPM = 24,609142453 rad/sec
self._envStepCounter = 0
p.resetSimulation()
p.setGravity(0,0,-10) # m/s^2
p.setTimeStep(0.01) # sec
planeId = p.loadURDF("plane.urdf")
cubeStartPos = [0,0,0.001]
cubeStartOrientation = p.getQuaternionFromEuler([0,0,0])
path = os.path.abspath(os.path.dirname(__file__))
self.botId = p.loadURDF(os.path.join(path, "balancebot_simple.xml"),
cubeStartPos,
cubeStartOrientation)
# you *have* to compute and return the observation from reset()
self._observation = self._compute_observation()
return np.array(self._observation)
示例6: evaluate_params
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def evaluate_params(evaluateFunc, params, objectiveParams, urdfRoot='', timeStep=0.01, maxNumSteps=10000, sleepTime=0):
print('start evaluation')
beforeTime = time.time()
p.resetSimulation()
p.setTimeStep(timeStep)
p.loadURDF("%s/plane.urdf" % urdfRoot)
p.setGravity(0,0,-10)
global minitaur
minitaur = Minitaur(urdfRoot)
start_position = current_position()
last_position = None # for tracing line
total_energy = 0
for i in range(maxNumSteps):
torques = minitaur.getMotorTorques()
velocities = minitaur.getMotorVelocities()
total_energy += np.dot(np.fabs(torques), np.fabs(velocities)) * timeStep
joint_values = evaluate_func_map[evaluateFunc](i, params)
minitaur.applyAction(joint_values)
p.stepSimulation()
if (is_fallen()):
break
if i % 100 == 0:
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(sleepTime)
print(' ')
alpha = objectiveParams[0]
final_distance = np.linalg.norm(start_position - current_position())
finalReturn = final_distance - alpha * total_energy
elapsedTime = time.time() - beforeTime
print ("trial for ", params, " final_distance", final_distance, "total_energy", total_energy, "finalReturn", finalReturn, "elapsed_time", elapsedTime)
return finalReturn
示例7: start
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def start(self, time_step=None):
"""Start the simulation."""
if time_step:
self._time_step = time_step
# Choose real time or step simulation
if self._time_step is None:
p.setRealTimeSimulation(1)
else:
p.setRealTimeSimulation(0)
p.setTimeStep(self._time_step)
示例8: reset_simulation
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def reset_simulation(self):
self.terminated = 0
# --- reset simulation --- #
p.resetSimulation(physicsClientId=self._physics_client_id)
p.setPhysicsEngineParameter(numSolverIterations=150, physicsClientId=self._physics_client_id)
p.setTimeStep(self._time_step, physicsClientId=self._physics_client_id)
self._env_step_counter = 0
p.setGravity(0, 0, -9.8, physicsClientId=self._physics_client_id)
# --- reset robot --- #
self._robot.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
# --- reset world --- #
self._world.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
# --- draw some reference frames in the simulation for debugging --- #
self._robot.debug_gui()
self._world.debug_gui()
p.stepSimulation(physicsClientId=self._physics_client_id)
示例9: reset_simulation
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def reset_simulation(self):
self.terminated = 0
# --- reset simulation --- #
p.resetSimulation(physicsClientId=self._physics_client_id)
p.setPhysicsEngineParameter(numSolverIterations=150, physicsClientId=self._physics_client_id)
p.setTimeStep(self._time_step, physicsClientId=self._physics_client_id)
self._env_step_counter = 0
p.setGravity(0, 0, -9.8, physicsClientId=self._physics_client_id)
# --- reset robot --- #
self._robot.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
# --- reset world --- #
self._world.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
if self._use_IK:
self._hand_pose = self._robot._home_hand_pose
# --- draw some reference frames in the simulation for debugging --- #
self._robot.debug_gui()
self._world.debug_gui()
p.stepSimulation(physicsClientId=self._physics_client_id)
示例10: reset_simulation
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def reset_simulation(self):
self.terminated = 0
# --- reset simulation --- #
p.resetSimulation(physicsClientId=self._physics_client_id)
p.setPhysicsEngineParameter(numSolverIterations=150, physicsClientId=self._physics_client_id)
p.setTimeStep(self._timeStep, physicsClientId=self._physics_client_id)
self._env_step_counter = 0
p.setGravity(0, 0, -9.8, physicsClientId=self._physics_client_id)
# --- reset robot --- #
self._robot.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
# --- reset world --- #
self._world.reset()
# Let the world run for a bit
for _ in range(100):
p.stepSimulation(physicsClientId=self._physics_client_id)
if self._use_IK:
self._hand_pose = self._robot._home_hand_pose
# --- draw some reference frames in the simulation for debugging --- #
self._robot.debug_gui()
self._world.debug_gui()
p.stepSimulation(physicsClientId=self._physics_client_id)
示例11: testJacobian
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def testJacobian(self):
import pybullet as p
clid = p.connect(p.SHARED_MEMORY)
if (clid<0):
p.connect(p.DIRECT)
time_step = 0.001
gravity_constant = -9.81
urdfs = ["TwoJointRobot_w_fixedJoints.urdf",
"TwoJointRobot_w_fixedJoints.urdf",
"kuka_iiwa/model.urdf",
"kuka_lwr/kuka.urdf"]
for urdf in urdfs:
p.resetSimulation()
p.setTimeStep(time_step)
p.setGravity(0.0, 0.0, gravity_constant)
robotId = p.loadURDF(urdf, useFixedBase=True)
p.resetBasePositionAndOrientation(robotId,[0,0,0],[0,0,0,1])
numJoints = p.getNumJoints(robotId)
endEffectorIndex = numJoints - 1
# Set a joint target for the position control and step the sim.
self.setJointPosition(robotId, [0.1 * (i % 3)
for i in range(numJoints)])
p.stepSimulation()
# Get the joint and link state directly from Bullet.
mpos, mvel, mtorq = self.getMotorJointStates(robotId)
result = p.getLinkState(robotId, endEffectorIndex,
computeLinkVelocity=1, computeForwardKinematics=1)
link_trn, link_rot, com_trn, com_rot, frame_pos, frame_rot, link_vt, link_vr = result
# Get the Jacobians for the CoM of the end-effector link.
# Note that in this example com_rot = identity, and we would need to use com_rot.T * com_trn.
# The localPosition is always defined in terms of the link frame coordinates.
zero_vec = [0.0] * len(mpos)
jac_t, jac_r = p.calculateJacobian(robotId, endEffectorIndex,
com_trn, mpos, zero_vec, zero_vec)
assert(allclose(dot(jac_t, mvel), link_vt))
assert(allclose(dot(jac_r, mvel), link_vr))
p.disconnect()
示例12: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import setTimeStep [as 别名]
def __init__(self, config, gpu_count=0):
"""Initialize the minitaur gym environment.
Args:
distance_weight: The weight of the distance term in the reward.
energy_weight: The weight of the energy term in the reward.
shake_weight: The weight of the vertical shakiness term in the reward.
drift_weight: The weight of the sideways drift term in the reward.
distance_limit: The maximum distance to terminate the episode.
observation_noise_stdev: The standard deviation of observation noise.
leg_model_enabled: Whether to use a leg motor to reparameterize the action
space.
hard_reset: Whether to wipe the simulation and load everything when reset
is called. If set to false, reset just place the minitaur back to start
position and set its pose to initial configuration.
env_randomizer: An EnvRandomizer to randomize the physical properties
during reset().
"""
self.config = self.parse_config(config)
assert(self.config["envname"] == self.__class__.__name__ or self.config["envname"] == "TestEnv")
CameraRobotEnv.__init__(self, self.config, gpu_count,
scene_type="building",
tracking_camera=tracking_camera)
self.robot_introduce(Minitaur(self.config, env=self,
pd_control_enabled=self.pd_control_enabled,
accurate_motor_model_enabled=self.accurate_motor_model_enabled))
self.scene_introduce()
self.gui = self.config["mode"] == "gui"
self.total_reward = 0
self.total_frame = 0
self.action_repeat = 1
## Important: PD controller needs more accuracy
'''if self.pd_control_enabled or self.accurate_motor_model_enabled:
self.time_step = self.config["speed"]["timestep"]
self.time_step /= self.NUM_SUBSTEPS
self.num_bullet_solver_iterations /= self.NUM_SUBSTEPS
self.action_repeat *= self.NUM_SUBSTEPS
pybullet.setPhysicsEngineParameter(physicsClientId=self.physicsClientId,
numSolverIterations=int(self.num_bullet_solver_iterations))
pybullet.setTimeStep(self.time_step, physicsClientId=self.physicsClientId)
'''
pybullet.setPhysicsEngineParameter(physicsClientId=self.physicsClientId,
numSolverIterations=int(self.num_bullet_solver_iterations))
self._observation = []
self._last_base_position = [0, 0, 0]
self._action_bound = self.action_bound
self._env_randomizer = self.env_randomizer
if self._env_randomizer is not None:
self._env_randomizer.randomize_env(self)
self._objectives = []
self.viewer = None
self.Amax = [0] * 8