本文整理汇总了Python中pybullet.changeDynamics方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.changeDynamics方法的具体用法?Python pybullet.changeDynamics怎么用?Python pybullet.changeDynamics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybullet
的用法示例。
在下文中一共展示了pybullet.changeDynamics方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupWorld
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [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: test_rolling_friction
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def test_rolling_friction(self):
import pybullet as p
p.connect(p.DIRECT)
p.loadURDF("plane.urdf")
sphere = p.loadURDF("sphere2.urdf",[0,0,1])
p.resetBaseVelocity(sphere,linearVelocity=[1,0,0])
p.changeDynamics(sphere,-1,linearDamping=0,angularDamping=0)
#p.changeDynamics(sphere,-1,rollingFriction=0)
p.setGravity(0,0,-10)
for i in range (1000):
p.stepSimulation()
vel = p.getBaseVelocity(sphere)
self.assertLess(vel[0][0],1e-10)
self.assertLess(vel[0][1],1e-10)
self.assertLess(vel[0][2],1e-10)
self.assertLess(vel[1][0],1e-10)
self.assertLess(vel[1][1],1e-10)
self.assertLess(vel[1][2],1e-10)
p.disconnect()
示例3: SetLegMasses
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def SetLegMasses(self, leg_masses):
"""Set the mass of the legs.
A leg includes leg_link and motor. All four leg_links have the same mass,
which is leg_masses[0]. All four motors have the same mass, which is
leg_mass[1].
Args:
leg_masses: The leg masses. leg_masses[0] is the mass of the leg link.
leg_masses[1] is the mass of the motor.
"""
for link_id in self.LEG_LINK_ID:
p.changeDynamics(
self.minitaur, link_id, mass=leg_masses[0])
for link_id in self.MOTOR_LINK_ID:
p.changeDynamics(
self.minitaur, link_id, mass=leg_masses[1])
示例4: setupWorld
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [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)
示例5: setFloorFrictions
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def setFloorFrictions(self, lateral=1, spinning=-1, rolling=-1):
"""Sets the frictions with the plane object
Keyword Arguments:
lateral {float} -- lateral friction (default: {1.0})
spinning {float} -- spinning friction (default: {-1.0})
rolling {float} -- rolling friction (default: {-1.0})
"""
if self.floor is not None:
p.changeDynamics(self.floor, -1, lateralFriction=lateral,
spinningFriction=spinning, rollingFriction=rolling)
示例6: setBallPos
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def setBallPos(self, x, y):
"""Sets the ball position on the field"""
if self.ball is not None:
# Putting the ball on the ground at given position
p.resetBasePositionAndOrientation(
self.ball, [x, y, 0.06], p.getQuaternionFromEuler([0, 0, 0]))
# Stopping the ball speed
p.changeDynamics(self.ball, 0,
linearDamping=0, angularDamping=0.1)
示例7: setup_human_joints
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def setup_human_joints(self, human, joints_positions, controllable_joints, use_static_joints=True, human_reactive_force=None, human_reactive_gain=0.05):
if self.human_impairment != 'tremor':
self.human_tremors = np.zeros(len(controllable_joints))
elif len(controllable_joints) == 4:
self.human_tremors = self.np_random.uniform(np.deg2rad(-20), np.deg2rad(20), size=len(controllable_joints))
else:
self.human_tremors = self.np_random.uniform(np.deg2rad(-10), np.deg2rad(10), size=len(controllable_joints))
# Set starting joint positions
human_joint_states = p.getJointStates(human, jointIndices=list(range(p.getNumJoints(human, physicsClientId=self.id))), physicsClientId=self.id)
human_joint_positions = np.array([x[0] for x in human_joint_states])
for j in range(p.getNumJoints(human, physicsClientId=self.id)):
set_position = None
for j_index, j_angle in joints_positions:
if j == j_index:
p.resetJointState(human, jointIndex=j, targetValue=j_angle, targetVelocity=0, physicsClientId=self.id)
set_position = j_angle
break
if use_static_joints and j not in controllable_joints:
# Make all non controllable joints on the person static by setting mass of each link (joint) to 0
p.changeDynamics(human, j, mass=0, physicsClientId=self.id)
# Set velocities to 0
p.resetJointState(human, jointIndex=j, targetValue=human_joint_positions[j] if set_position is None else set_position, targetVelocity=0, physicsClientId=self.id)
# By default, all joints have motors enabled by default that prevent free motion. Disable these motors in human
for j in range(p.getNumJoints(human, physicsClientId=self.id)):
p.setJointMotorControl2(human, jointIndex=j, controlMode=p.VELOCITY_CONTROL, force=0, physicsClientId=self.id)
self.enforce_joint_limits(human)
if human_reactive_force is not None:
# NOTE: This runs a Position / Velocity PD controller for each joint motor on the human
human_joint_states = p.getJointStates(human, jointIndices=controllable_joints, physicsClientId=self.id)
target_human_joint_positions = np.array([x[0] for x in human_joint_states])
forces = [human_reactive_force * self.human_strength] * len(target_human_joint_positions)
p.setJointMotorControlArray(human, jointIndices=controllable_joints, controlMode=p.POSITION_CONTROL, targetPositions=target_human_joint_positions, positionGains=np.array([human_reactive_gain]*len(forces)), forces=forces, physicsClientId=self.id)
示例8: SetBaseMass
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def SetBaseMass(self, base_mass):
p.changeDynamics(
self.minitaur, self.BASE_LINK_ID, mass=base_mass)
示例9: SetFootFriction
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def SetFootFriction(self, foot_friction):
"""Set the lateral friction of the feet.
Args:
foot_friction: The lateral friction coefficient of the foot. This value is
shared by all four feet.
"""
for link_id in self.FOOT_LINK_ID:
p.changeDynamics(
self.minitaur, link_id, lateralFriction=foot_friction)
示例10: change_physics_params
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def change_physics_params(self, obj_mass, obj_friction, obj_dumping, robot_damping):
p.changeDynamics(self._world.obj_id, linkIndex=-1, mass=obj_mass, lateralFriction=obj_friction,
linearDamping=obj_dumping)
for i in range(self._robot._num_dof_no_fingers):
p.changeDynamics(self._robot.robot_id, linkIndex=i, linearDamping=robot_damping)
return 0
示例11: __init__
# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeDynamics [as 别名]
def __init__(self, robot, model_id, gravity, timestep, frame_skip, env = None):
Scene.__init__(self, gravity, timestep, frame_skip, env)
# contains cpp_world.clean_everything()
# stadium_pose = cpp_household.Pose()
# if self.zero_at_running_strip_start_line:
# stadium_pose.set_xyz(27, 21, 0) # see RUN_STARTLINE, RUN_RAD constants
filename = os.path.join(get_model_path(model_id), "mesh_z_up.obj")
#filename = os.path.join(get_model_path(model_id), "3d", "blender.obj")
#textureID = p.loadTexture(os.path.join(get_model_path(model_id), "3d", "rgb.mtl"))
if robot.model_type == "MJCF":
MJCF_SCALING = robot.mjcf_scaling
scaling = [1.0/MJCF_SCALING, 1.0/MJCF_SCALING, 0.6/MJCF_SCALING]
else:
scaling = [1, 1, 1]
magnified = [2, 2, 2]
collisionId = p.createCollisionShape(p.GEOM_MESH, fileName=filename, meshScale=scaling, flags=p.GEOM_FORCE_CONCAVE_TRIMESH)
view_only_mesh = os.path.join(get_model_path(model_id), "mesh_view_only_z_up.obj")
if os.path.exists(view_only_mesh):
visualId = p.createVisualShape(p.GEOM_MESH,
fileName=view_only_mesh,
meshScale=scaling, flags=p.GEOM_FORCE_CONCAVE_TRIMESH)
else:
visualId = -1
boundaryUid = p.createMultiBody(baseCollisionShapeIndex = collisionId, baseVisualShapeIndex = visualId)
p.changeDynamics(boundaryUid, -1, lateralFriction=1)
#print(p.getDynamicsInfo(boundaryUid, -1))
self.scene_obj_list = [(boundaryUid, -1)] # baselink index -1
planeName = os.path.join(pybullet_data.getDataPath(), "mjcf/ground_plane.xml")
self.ground_plane_mjcf = p.loadMJCF(planeName)
if "z_offset" in self.env.config:
z_offset = self.env.config["z_offset"]
else:
z_offset = -10 #with hole filling, we don't need ground plane to be the same height as actual floors
p.resetBasePositionAndOrientation(self.ground_plane_mjcf[0], posObj = [0,0,z_offset], ornObj = [0,0,0,1])
p.changeVisualShape(boundaryUid, -1, rgbaColor=[168 / 255.0, 164 / 255.0, 92 / 255.0, 1.0],
specularColor=[0.5, 0.5, 0.5])