本文整理汇总了Python中pybullet.resetBasePositionAndOrientation方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.resetBasePositionAndOrientation方法的具体用法?Python pybullet.resetBasePositionAndOrientation怎么用?Python pybullet.resetBasePositionAndOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.resetBasePositionAndOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def __init__(self, robot_name, print_debug, email_cred_file='', log_file='', control_rate=100, gripper_attached='default'):
super(WidowXController, self).__init__(robot_name, print_debug, email_cred_file, log_file, control_rate, gripper_attached)
self._redist_rate = rospy.Rate(50)
self._arbotix = ArbotiX('/dev/ttyUSB0')
assert self._arbotix.syncWrite(MAX_TORQUE_L, [[servo_id, 255, 0] for servo_id in SERVO_IDS]) != -1, "failure during servo configuring"
assert self._arbotix.syncWrite(TORQUE_LIMIT, [[servo_id, 255, 0] for servo_id in SERVO_IDS]) != -1, "failure during servo configuring"
self._joint_lock = Lock()
self._angles, self._velocities = {}, {}
rospy.Subscriber("/joint_states", JointState, self._joint_callback)
time.sleep(1)
self._joint_pubs = [rospy.Publisher('/{}/command'.format(name), Float64, queue_size=1) for name in JOINT_NAMES[:-1]]
self._gripper_pub = rospy.Publisher('/gripper_prismatic_joint/command', Float64, queue_size=1)
p.connect(p.DIRECT)
widow_x_urdf = '/'.join(__file__.split('/')[:-1]) + '/widowx/widowx.urdf'
self._armID = p.loadURDF(widow_x_urdf, useFixedBase=True)
p.resetBasePositionAndOrientation(self._armID, [0, 0, 0], p.getQuaternionFromEuler([np.pi, np.pi, np.pi]))
self._n_errors = 0
示例2: init_jaco
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def init_jaco(self, print_joints=False):
# Enable self collisions to prevent the arm from going through the torso
if self.task == 'arm_manipulation':
robot = p.loadURDF(os.path.join(self.directory, 'jaco', 'j2s7s300_gym_arm_manipulation.urdf'), useFixedBase=True, basePosition=[0, 0, 0], flags=p.URDF_USE_SELF_COLLISION, physicsClientId=self.id)
# Disable collisions between the fingers and the tool
for i in range(10, 16):
p.setCollisionFilterPair(robot, robot, i, 9, 0, physicsClientId=self.id)
else:
robot = p.loadURDF(os.path.join(self.directory, 'jaco', 'j2s7s300_gym.urdf'), useFixedBase=True, basePosition=[0, 0, 0], flags=p.URDF_USE_SELF_COLLISION, physicsClientId=self.id)
robot_arm_joint_indices = [1, 2, 3, 4, 5, 6, 7]
if print_joints:
self.print_joint_info(robot, show_fixed=True)
# Initialize and position
p.resetBasePositionAndOrientation(robot, [-2, -2, 0.975], [0, 0, 0, 1], physicsClientId=self.id)
# Grab and enforce robot arm joint limits
lower_limits, upper_limits = self.enforce_joint_limits(robot)
return robot, lower_limits, upper_limits, robot_arm_joint_indices, robot_arm_joint_indices
示例3: _addTower
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _addTower(self, pos, blocks, urdf_dir):
'''
Helper function that generats a tower containing listed blocks at the
specific position
'''
z = 0.025
ids = []
for block in blocks:
urdf_filename = os.path.join(
urdf_dir, self.model, self.block_urdf % block)
obj_id = pb.loadURDF(urdf_filename)
pb.resetBasePositionAndOrientation(
obj_id,
(pos[0], pos[1], z),
(0, 0, 0, 1))
self.addObject("block", "%s_block" % block, obj_id)
z += 0.05
ids.append(obj_id)
return ids
示例4: _setup
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _setup(self):
'''
Create the mug at a random position on the ground, handle facing
roughly towards the robot. Robot's job is to grab and lift.
'''
rospack = rospkg.RosPack()
path = rospack.get_path('costar_objects')
sdf_dir = os.path.join(path, self.sdf_dir)
obj_to_add = os.path.join(sdf_dir, self.model, self.model_file_name)
identity_orientation = pb.getQuaternionFromEuler([0, 0, 0])
try:
obj_id_list = pb.loadSDF(obj_to_add)
for obj_id in obj_id_list:
random_position = np.random.rand(
3) * self.spawn_pos_delta + self.spawn_pos_min
pb.resetBasePositionAndOrientation(
obj_id, random_position, identity_orientation)
except Exception, e:
print e
示例5: _setup
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _setup(self):
'''
Create the mug at a random position on the ground, handle facing
roughly towards the robot. Robot's job is to grab and lift.
'''
rospack = rospkg.RosPack()
path = rospack.get_path('costar_simulation')
urdf_dir = os.path.join(path, self.urdf_dir)
tray_filename = os.path.join(urdf_dir, self.tray_dir, self.tray_urdf)
red_filename = os.path.join(urdf_dir, self.model, self.red_urdf)
blue_filename = os.path.join(urdf_dir, self.model, self.blue_urdf)
for position in self.tray_poses:
obj_id = pb.loadURDF(tray_filename)
pb.resetBasePositionAndOrientation(obj_id, position, (0, 0, 0, 1))
self._add_balls(self.num_red, red_filename, "red")
self._add_balls(self.num_blue, blue_filename, "blue")
示例6: _addTower
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _addTower(self, pos, blocks, urdf_dir):
'''
Helper function that generats a tower containing listed blocks at the
specific position
'''
z = 0.025
ids = []
for block in blocks:
urdf_filename = os.path.join(
urdf_dir, self.model, self.block_urdf % block)
obj_id = pb.loadURDF(urdf_filename)
r = self._sampleRotation()
block_pos = self._samplePos(pos[0], pos[1], z)
pb.resetBasePositionAndOrientation(
obj_id,
block_pos,
r)
self.addObject("block", "%s_block" % block, obj_id)
z += 0.05
ids.append(obj_id)
return ids
示例7: _addTower
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _addTower(self, pos, blocks, urdf_dir):
'''
Helper function that generats a tower containing listed blocks at the
specific position
'''
z = 0.025
ids = []
for block in blocks:
urdf_filename = os.path.join(urdf_dir, self.model, self.block_urdf%block)
obj_id = pb.loadURDF(urdf_filename)
pb.resetBasePositionAndOrientation(
obj_id,
(pos[0], pos[1], z),
(0,0,0,1))
self.addObject("block", "%s_block"%block, obj_id)
print "%s_block"%block
z += 0.05
ids.append(obj_id)
return ids
示例8: place
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def place(self, pos, rot, joints):
pb.resetBasePositionAndOrientation(self.handle, pos, rot)
pb.createConstraint(
self.handle, -1, -1, -1, pb.JOINT_FIXED, pos, [0, 0, 0], rot)
for i, q in enumerate(joints):
pb.resetJointState(self.handle, i, q)
# gripper
pb.resetJointState(self.handle, self.left_knuckle, 0)
pb.resetJointState(self.handle, self.right_knuckle, 0)
pb.resetJointState(self.handle, self.left_finger, 0)
pb.resetJointState(self.handle, self.right_finger, 0)
pb.resetJointState(self.handle, self.left_fingertip, 0)
pb.resetJointState(self.handle, self.right_fingertip, 0)
self.arm(joints,)
self.gripper(0)
示例9: _flag_reposition
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _flag_reposition(self):
self.walk_target_x = self.np_random.uniform(low=-self.scene.stadium_halflen,
high=+self.scene.stadium_halflen)
self.walk_target_y = self.np_random.uniform(low=-self.scene.stadium_halfwidth,
high=+self.scene.stadium_halfwidth)
more_compact = 0.5 # set to 1.0 whole football field
self.walk_target_x *= more_compact / self.robot.mjcf_scaling
self.walk_target_y *= more_compact / self.robot.mjcf_scaling
self.flag = None
#self.flag = self.scene.cpp_world.debug_sphere(self.walk_target_x, self.walk_target_y, 0.2, 0.2, 0xFF8080)
self.flag_timeout = 3000 / self.scene.frame_skip
#print('targetxy', self.flagid, self.walk_target_x, self.walk_target_y, p.getBasePositionAndOrientation(self.flagid))
#p.resetBasePositionAndOrientation(self.flagid, posObj = [self.walk_target_x, self.walk_target_y, 0.5], ornObj = [0,0,0,0])
if self.gui:
if self.lastid:
p.removeBody(self.lastid)
self.lastid = p.createMultiBody(baseVisualShapeIndex=self.visualid, baseCollisionShapeIndex=-1, basePosition=[self.walk_target_x, self.walk_target_y, 0.5])
self.robot.walk_target_x = self.walk_target_x
self.robot.walk_target_y = self.walk_target_y
示例10: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _reset(self):
# reset state
self.steps = 0
self.done = False
# reset pole on cart in starting poses
p.resetBasePositionAndOrientation(self.cartpole, (0,0,0.08), (0,0,0,1)) # reset cart position and orientation
p.resetJointState(self.cartpole, 0, 0) # reset joint position of pole
for _ in xrange(100): p.stepSimulation()
# give a fixed force push in a random direction to get things going...
theta = (np.random.random()*2-1) if self.random_theta else 0.0
for _ in xrange(self.initial_force_steps):
p.stepSimulation()
p.applyExternalForce(self.cartpole, 0, (theta, 0 , 0), (0, 0, 0), p.WORLD_FRAME)
if self.delay > 0:
time.sleep(self.delay)
# bootstrap state by running for all repeats
for i in xrange(self.repeats):
self.set_state_element_for_repeat(i)
# return this state
return np.copy(self.state)
示例11: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _reset(self):
# reset your environment
# reset state
self.steps = 0
self.done = False
# reset morphology
p.resetBasePositionAndOrientation(self.body, self.initPosition, self.initOrientation) # reset body position and orientation
resetPosition = 0
for joint in xrange(self.num_joints):
if self.random_initial_position:
resetPosition = np.random.random() * 2 * np.pi - np.pi
p.resetJointState(self.body, joint, resetPosition) # reset joint position of joints
for _ in xrange(100): p.stepSimulation()
# bootstrap state by running for all repeats
for i in xrange(self.repeats):
self.set_state_element_for_repeat(i)
# return this state
return np.copy(self.state)
示例12: _reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def _reset(self):
# reset state
self.steps = 0
self.done = False
# reset pole on cart in starting poses
p.resetBasePositionAndOrientation(self.cart, (0,0,0.08), (0,0,0,1))
p.resetBasePositionAndOrientation(self.pole, (0,0,0.35), (0,0,0,1))
for _ in xrange(100): p.stepSimulation()
# give a fixed force push in a random direction to get things going...
theta = np.multiply(np.multiply((np.random.random(), np.random.random(), 0),2) - (1,1,0),5) if self.random_theta else (1,0,0)
for _ in xrange(self.initial_force_steps):
p.stepSimulation()
p.applyExternalForce(self.pole, -1, theta, (0, 0, 0), p.WORLD_FRAME)
if self.delay > 0:
time.sleep(self.delay)
# bootstrap state by running for all repeats
for i in xrange(self.repeats):
self.set_state_element_for_repeat(i)
# return this state
return np.copy(self.state)
示例13: Step
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def Step(stepIndex):
for objectId in range(objectNum):
record = log[stepIndex*objectNum+objectId]
Id = record[2]
pos = [record[3],record[4],record[5]]
orn = [record[6],record[7],record[8],record[9]]
p.resetBasePositionAndOrientation(Id,pos,orn)
numJoints = p.getNumJoints(Id)
for i in range (numJoints):
jointInfo = p.getJointInfo(Id,i)
qIndex = jointInfo[3]
if qIndex > -1:
p.resetJointState(Id,i,record[qIndex-7+17])
示例14: reset
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def reset(self):
objects = p.loadSDF(os.path.join(self.urdfRootPath,"kuka_iiwa/kuka_with_gripper2.sdf"))
self.kukaUid = objects[0]
#for i in range (p.getNumJoints(self.kukaUid)):
# print(p.getJointInfo(self.kukaUid,i))
p.resetBasePositionAndOrientation(self.kukaUid,[-0.100000,0.000000,0.070000],[0.000000,0.000000,0.000000,1.000000])
self.jointPositions=[ 0.006418, 0.413184, -0.011401, -1.589317, 0.005379, 1.137684, -0.006539, 0.000048, -0.299912, 0.000000, -0.000043, 0.299960, 0.000000, -0.000200 ]
self.numJoints = p.getNumJoints(self.kukaUid)
for jointIndex in range (self.numJoints):
p.resetJointState(self.kukaUid,jointIndex,self.jointPositions[jointIndex])
p.setJointMotorControl2(self.kukaUid,jointIndex,p.POSITION_CONTROL,targetPosition=self.jointPositions[jointIndex],force=self.maxForce)
self.trayUid = p.loadURDF(os.path.join(self.urdfRootPath,"tray/tray.urdf"), 0.640000,0.075000,-0.190000,0.000000,0.000000,1.000000,0.000000)
self.endEffectorPos = [0.537,0.0,0.5]
self.endEffectorAngle = 0
self.motorNames = []
self.motorIndices = []
for i in range (self.numJoints):
jointInfo = p.getJointInfo(self.kukaUid,i)
qIndex = jointInfo[3]
if qIndex > -1:
#print("motorname")
#print(jointInfo[1])
self.motorNames.append(str(jointInfo[1]))
self.motorIndices.append(i)
示例15: setRobotPose
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import resetBasePositionAndOrientation [as 别名]
def setRobotPose(self, pos, orn):
"""Sets the robot (origin) pose
Arguments:
pos {tuple} -- (x,y,z) position
orn {tuple} -- (x,y,z,w) quaternions
"""
p.resetBasePositionAndOrientation(self.robot, pos, orn)