本文整理匯總了Python中pybullet.setRealTimeSimulation方法的典型用法代碼示例。如果您正苦於以下問題:Python pybullet.setRealTimeSimulation方法的具體用法?Python pybullet.setRealTimeSimulation怎麽用?Python pybullet.setRealTimeSimulation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybullet
的用法示例。
在下文中一共展示了pybullet.setRealTimeSimulation方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _reset
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [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)
示例2: setup_inverse_kinematics
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [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)
示例3: setup_inverse_kinematics
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [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)
示例4: setup_inverse_kinematics
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [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)
示例5: start
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [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)
示例6: launchSimulation
# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import setRealTimeSimulation [as 別名]
def launchSimulation(self, gui=True, use_shared_memory=False):
"""
Launches a simulation instance
Parameters:
gui - Boolean, if True the simulation is launched with a GUI, and
with no GUI otherwise
use_shared_memory - Experimental feature, only taken into account
if gui=False, False by default. If True, the simulation will use
the pybullet SHARED_MEMORY_SERVER mode to create an instance. If
multiple simulation instances are created, this solution allows a
multicore parallelisation of the bullet motion servers (one for
each instance). In DIRECT mode, such a parallelisation is not
possible and the motion servers are manually stepped using the
_stepSimulation method. (More information in the setup section of
the qiBullet wiki, and in the pybullet documentation)
Returns:
physics_client - The id of the simulation client created
"""
if gui: # pragma: no cover
physics_client = pybullet.connect(pybullet.GUI)
pybullet.setRealTimeSimulation(1, physicsClientId=physics_client)
pybullet.configureDebugVisualizer(
pybullet.COV_ENABLE_RGB_BUFFER_PREVIEW,
0,
physicsClientId=physics_client)
pybullet.configureDebugVisualizer(
pybullet.COV_ENABLE_DEPTH_BUFFER_PREVIEW,
0,
physicsClientId=physics_client)
pybullet.configureDebugVisualizer(
pybullet.COV_ENABLE_SEGMENTATION_MARK_PREVIEW,
0,
physicsClientId=physics_client)
else:
if use_shared_memory:
physics_client = pybullet.connect(
pybullet.SHARED_MEMORY_SERVER)
pybullet.setRealTimeSimulation(
enableRealTimeSimulation=1,
physicsClientId=physics_client)
else:
physics_client = pybullet.connect(pybullet.DIRECT)
threading.Thread(
target=self._stepSimulation,
args=[physics_client]).start()
pybullet.setGravity(0, 0, -9.81, physicsClientId=physics_client)
return physics_client