本文整理汇总了Python中pybullet.resetSimulation方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.resetSimulation方法的具体用法?Python pybullet.resetSimulation怎么用?Python pybullet.resetSimulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.resetSimulation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupWorld
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def setupWorld(self):
numObjects = 50
maximalCoordinates = False
p.resetSimulation()
p.setPhysicsEngineParameter(deterministicOverlappingPairs=1)
p.loadURDF("planeMesh.urdf",useMaximalCoordinates=maximalCoordinates)
kukaId = p.loadURDF("kuka_iiwa/model_free_base.urdf",[0,0,10], useMaximalCoordinates=maximalCoordinates)
for i in range (p.getNumJoints(kukaId)):
p.setJointMotorControl2(kukaId,i,p.POSITION_CONTROL,force=0)
for i in range (numObjects):
cube = p.loadURDF("cube_small.urdf",[0,i*0.02,(i+1)*0.2])
#p.changeDynamics(cube,-1,mass=100)
p.stepSimulation()
p.setGravity(0,0,-10)
示例2: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [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)
示例3: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [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_inverse_kinematics
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def setup_inverse_kinematics(self):
"""
This function is responsible for doing any setup for inverse kinematics.
Inverse Kinematics maps end effector (EEF) poses to joint angles that
are necessary to achieve those poses.
"""
# Set up a connection to the PyBullet simulator.
p.connect(p.DIRECT)
p.resetSimulation()
# get paths to urdfs
self.robot_urdf = pjoin(
self.bullet_data_path, "sawyer_description/urdf/sawyer_arm.urdf"
)
# load the urdfs
self.ik_robot = p.loadURDF(self.robot_urdf, (0, 0, 0.9), useFixedBase=1)
# Simulation will update as fast as it can in real time, instead of waiting for
# step commands like in the non-realtime case.
p.setRealTimeSimulation(1)
示例5: setup_inverse_kinematics
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def setup_inverse_kinematics(self):
"""
This function is responsible for doing any setup for inverse kinematics.
Inverse Kinematics maps end effector (EEF) poses to joint angles that
are necessary to achieve those poses.
"""
# Set up a connection to the PyBullet simulator.
p.connect(p.DIRECT)
p.resetSimulation()
# get paths to urdfs
self.robot_urdf = pjoin(
self.bullet_data_path, "panda_description/urdf/panda_arm.urdf"
)
# load the urdfs
self.ik_robot = p.loadURDF(self.robot_urdf, (0, 0, 0.9), useFixedBase=1)
# Simulation will update as fast as it can in real time, instead of waiting for
# step commands like in the non-realtime case.
p.setRealTimeSimulation(1)
示例6: _setup
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [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)
示例7: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [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)
示例8: setupWorld
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def setupWorld():
p.resetSimulation()
p.setPhysicsEngineParameter(deterministicOverlappingPairs=1)
p.loadURDF("planeMesh.urdf")
kukaId = p.loadURDF("kuka_iiwa/model_free_base.urdf",[0,0,10])
for i in range (p.getNumJoints(kukaId)):
p.setJointMotorControl2(kukaId,i,p.POSITION_CONTROL,force=0)
for i in range (numObjects):
cube = p.loadURDF("cube_small.urdf",[0,i*0.02,(i+1)*0.2])
#p.changeDynamics(cube,-1,mass=100)
p.stepSimulation()
p.setGravity(0,0,-10)
示例9: evaluate_params
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [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
示例10: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def _reset(self):
"""Environment reset called at the beginning of an episode.
"""
# Set the camera settings.
look = [0.23, 0.2, 0.54]
distance = 1.
pitch = -56 + self._cameraRandom*np.random.uniform(-3, 3)
yaw = 245 + self._cameraRandom*np.random.uniform(-3, 3)
roll = 0
self._view_matrix = p.computeViewMatrixFromYawPitchRoll(
look, distance, yaw, pitch, roll, 2)
fov = 20. + self._cameraRandom*np.random.uniform(-2, 2)
aspect = self._width / self._height
near = 0.01
far = 10
self._proj_matrix = p.computeProjectionMatrixFOV(
fov, aspect, near, far)
self._attempted_grasp = False
self._env_step = 0
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)
p.setGravity(0,0,-10)
self._kuka = kuka.Kuka(urdfRootPath=self._urdfRoot, timeStep=self._timeStep)
self._envStepCounter = 0
p.stepSimulation()
# Choose the objects in the bin.
urdfList = self._get_random_object(
self._numObjects, self._isTest)
self._objectUids = self._randomly_place_objects(urdfList)
self._observation = self._get_observation()
return np.array(self._observation)
示例11: setup_inverse_kinematics
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def setup_inverse_kinematics(self, urdf_path):
"""
This function is responsible for doing any setup for inverse kinematics.
Inverse Kinematics maps end effector (EEF) poses to joint angles that
are necessary to achieve those poses.
"""
# These indices come from the urdf file we're using
self.effector_right = 27
self.effector_left = 45
# Use PyBullet to handle inverse kinematics.
# Set up a connection to the PyBullet simulator.
p.connect(p.DIRECT)
p.resetSimulation()
self.ik_robot = p.loadURDF(urdf_path, (0, 0, 0), useFixedBase=1)
# Relevant joints we care about. Many of the joints are fixed and don't count, so
# we need this second map to use the right ones.
self.actual = [13, 14, 15, 16, 17, 19, 20, 31, 32, 33, 34, 35, 37, 38]
self.num_joints = p.getNumJoints(self.ik_robot)
n = p.getNumJoints(self.ik_robot)
self.rest = []
self.lower = []
self.upper = []
self.ranges = []
for i in range(n):
info = p.getJointInfo(self.ik_robot, i)
# Retrieve lower and upper ranges for each relevant joint
if info[3] > -1:
self.rest.append(p.getJointState(self.ik_robot, i)[0])
self.lower.append(info[8])
self.upper.append(info[9])
self.ranges.append(info[9] - info[8])
# Simulation will update as fast as it can in real time, instead of waiting for
# step commands like in the non-realtime case.
p.setRealTimeSimulation(1)
示例12: restart
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def restart(self):
"""Restart the simulation"""
# Reset
p.resetSimulation()
self.load()
self.start()
示例13: reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def reset(self):
'''
Reset the robot and task
'''
if not self.fast_reset:
pb.resetSimulation()
self.task.clear()
self.task.setup()
self.task.reset()
self.task.world.reset()
# tick for a half second to make sure the world makes sense
action = self.task.world.zeroAction()
for _ in range(5):
self.task.world.tick(action)
示例14: clean_everything
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def clean_everything(self):
#p.resetSimulation()
p.setGravity(0, 0, -self.gravity)
#p.setDefaultContactERP(0.9)
p.setPhysicsEngineParameter(fixedTimeStep=self.timestep*self.frame_skip, numSolverIterations=50, numSubSteps=(self.frame_skip-1))
示例15: clean_everything
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetSimulation [as 别名]
def clean_everything(self):
p.resetSimulation()
p.setGravity(0, 0, -self.gravity)
p.setPhysicsEngineParameter(fixedTimeStep=self.timestep, numSolverIterations=5, numSubSteps=2)