Python pybullet.changeDynamics() Examples
The following are 11
code examples of pybullet.changeDynamics().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pybullet
, or try the search function
.
Example #1
Source File: unittests.py From soccer-matlab with BSD 2-Clause "Simplified" License | 6 votes |
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()
Example #2
Source File: minitaur.py From midlevel-reps with MIT License | 6 votes |
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])
Example #3
Source File: saveRestoreStateTest.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #4
Source File: simulation.py From onshape-to-robot with MIT License | 5 votes |
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)
Example #5
Source File: simulation.py From onshape-to-robot with MIT License | 5 votes |
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)
Example #6
Source File: world_creation.py From assistive-gym with MIT License | 5 votes |
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)
Example #7
Source File: minitaur.py From midlevel-reps with MIT License | 5 votes |
def SetBaseMass(self, base_mass): p.changeDynamics( self.minitaur, self.BASE_LINK_ID, mass=base_mass)
Example #8
Source File: minitaur.py From midlevel-reps with MIT License | 5 votes |
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)
Example #9
Source File: panda_push_gym_env.py From pybullet-robot-envs with GNU Lesser General Public License v2.1 | 5 votes |
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
Example #10
Source File: saveRestoreState.py From soccer-matlab with BSD 2-Clause "Simplified" License | 4 votes |
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)
Example #11
Source File: scene_building.py From midlevel-reps with MIT License | 4 votes |
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])