當前位置: 首頁>>代碼示例>>Python>>正文


Python pybullet.changeDynamics方法代碼示例

本文整理匯總了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) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:19,代碼來源:saveRestoreStateTest.py

示例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() 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:21,代碼來源:unittests.py

示例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]) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:19,代碼來源:minitaur.py

示例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) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:14,代碼來源:saveRestoreState.py

示例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) 
開發者ID:Rhoban,項目名稱:onshape-to-robot,代碼行數:13,代碼來源:simulation.py

示例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) 
開發者ID:Rhoban,項目名稱:onshape-to-robot,代碼行數:12,代碼來源:simulation.py

示例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) 
開發者ID:Healthcare-Robotics,項目名稱:assistive-gym,代碼行數:37,代碼來源:world_creation.py

示例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) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:5,代碼來源:minitaur.py

示例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) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:12,代碼來源:minitaur.py

示例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 
開發者ID:robotology-playground,項目名稱:pybullet-robot-envs,代碼行數:9,代碼來源:panda_push_gym_env.py

示例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]) 
開發者ID:alexsax,項目名稱:midlevel-reps,代碼行數:49,代碼來源:scene_building.py


注:本文中的pybullet.changeDynamics方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。