当前位置: 首页>>代码示例>>Python>>正文


Python pybullet.changeVisualShape方法代码示例

本文整理汇总了Python中pybullet.changeVisualShape方法的典型用法代码示例。如果您正苦于以下问题:Python pybullet.changeVisualShape方法的具体用法?Python pybullet.changeVisualShape怎么用?Python pybullet.changeVisualShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybullet的用法示例。


在下文中一共展示了pybullet.changeVisualShape方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_pr2

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def init_pr2(self, print_joints=False):
        if self.task == 'arm_manipulation':
            robot = p.loadURDF(os.path.join(self.directory, 'PR2', 'pr2_no_torso_lift_tall_arm_manipulation.urdf'), useFixedBase=True, basePosition=[0, 0, 0], physicsClientId=self.id)
            robot_right_arm_joint_indices = [42, 43, 44, 46, 47, 49, 50]
            robot_left_arm_joint_indices = [65, 66, 67, 69, 70, 72, 73]
        else:
            robot = p.loadURDF(os.path.join(self.directory, 'PR2', 'pr2_no_torso_lift_tall.urdf'), useFixedBase=True, basePosition=[0, 0, 0], flags=p.URDF_USE_INERTIA_FROM_FILE, physicsClientId=self.id)
            robot_right_arm_joint_indices = [42, 43, 44, 46, 47, 49, 50]
            robot_left_arm_joint_indices = [64, 65, 66, 68, 69, 71, 72]
        if print_joints:
            self.print_joint_info(robot, show_fixed=True)

        # Initialize and position PR2
        p.resetBasePositionAndOrientation(robot, [-2, -2, 0], [0, 0, 0, 1], physicsClientId=self.id)

        # Recolor PR2
        if self.task == 'arm_manipulation':
            for i in [19, 42, 65]:
                p.changeVisualShape(robot, i, rgbaColor=[1.0, 1.0, 1.0, 1.0], physicsClientId=self.id)
            for i in [43, 46, 49, 59, 61, 66, 69, 72, 82, 84]:
                p.changeVisualShape(robot, i, rgbaColor=[0.4, 0.4, 0.4, 1.0], physicsClientId=self.id)
            for i in [45, 51, 68, 74]:
                p.changeVisualShape(robot, i, rgbaColor=[0.7, 0.7, 0.7, 1.0], physicsClientId=self.id)
        else:
            for i in [19, 42, 64]:
                p.changeVisualShape(robot, i, rgbaColor=[1.0, 1.0, 1.0, 1.0], physicsClientId=self.id)
            for i in [43, 46, 49, 58, 60, 65, 68, 71, 80, 82]:
                p.changeVisualShape(robot, i, rgbaColor=[0.4, 0.4, 0.4, 1.0], physicsClientId=self.id)
            for i in [45, 51, 67, 73]:
                p.changeVisualShape(robot, i, rgbaColor=[0.7, 0.7, 0.7, 1.0], physicsClientId=self.id)
        p.changeVisualShape(robot, 20, rgbaColor=[0.8, 0.8, 0.8, 1.0], physicsClientId=self.id)
        p.changeVisualShape(robot, 40, rgbaColor=[0.6, 0.6, 0.6, 1.0], 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_right_arm_joint_indices, robot_left_arm_joint_indices 
开发者ID:Healthcare-Robotics,项目名称:assistive-gym,代码行数:39,代码来源:world_creation.py

示例2: init_baxter

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def init_baxter(self, print_joints=False):
        if self.task == 'arm_manipulation':
            robot = p.loadURDF(os.path.join(self.directory, 'baxter', 'baxter_custom_arm_manipulation.urdf'), useFixedBase=True, basePosition=[0, 0, 0], physicsClientId=self.id)
            robot_right_arm_joint_indices = [12, 13, 14, 15, 16, 18, 19]
            robot_left_arm_joint_indices = [35, 36, 37, 38, 39, 41, 42]
        else:
            robot = p.loadURDF(os.path.join(self.directory, 'baxter', 'baxter_custom.urdf'), useFixedBase=True, basePosition=[0, 0, 0], physicsClientId=self.id)
            robot_right_arm_joint_indices = [12, 13, 14, 15, 16, 18, 19]
            robot_left_arm_joint_indices = [34, 35, 36, 37, 38, 40, 41]
        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)

        if self.task == 'arm_manipulation':
            for i in [20, 21, 23, 32, 33, 43, 44, 46, 55, 56]:
                p.changeVisualShape(robot, i, rgbaColor=[1.0, 1.0, 1.0, 0.0], physicsClientId=self.id)
        else:
            for i in [20, 21, 23, 31, 32, 42, 43, 45, 53, 54]:
                p.changeVisualShape(robot, i, rgbaColor=[1.0, 1.0, 1.0, 0.0], 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_right_arm_joint_indices, robot_left_arm_joint_indices 
开发者ID:Healthcare-Robotics,项目名称:assistive-gym,代码行数:28,代码来源:world_creation.py

示例3: robot_specific_reset

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def robot_specific_reset(self):
        WalkerBase.robot_specific_reset(self)
        
        humanoidId = -1
        numBodies = p.getNumBodies()
        for i in range (numBodies):
            bodyInfo = p.getBodyInfo(i)
            if bodyInfo[1].decode("ascii") == 'humanoid':
                humanoidId = i
        ## Spherical radiance/glass shield to protect the robot's camera
        if self.glass_id is None:
            glass_id = p.loadMJCF(os.path.join(self.physics_model_dir, "glass.xml"))[0]
            #print("setting up glass", glass_id, humanoidId)
            p.changeVisualShape(glass_id, -1, rgbaColor=[0, 0, 0, 0])
            cid = p.createConstraint(humanoidId, -1, glass_id,-1,p.JOINT_FIXED,[0,0,0],[0,0,1.4],[0,0,1])

        self.motor_names  = ["abdomen_z", "abdomen_y", "abdomen_x"]
        self.motor_power  = [100, 100, 100]
        self.motor_names += ["right_hip_x", "right_hip_z", "right_hip_y", "right_knee"]
        self.motor_power += [100, 100, 300, 200]
        self.motor_names += ["left_hip_x", "left_hip_z", "left_hip_y", "left_knee"]
        self.motor_power += [100, 100, 300, 200]
        self.motor_names += ["right_shoulder1", "right_shoulder2", "right_elbow"]
        self.motor_power += [75, 75, 75]
        self.motor_names += ["left_shoulder1", "left_shoulder2", "left_elbow"]
        self.motor_power += [75, 75, 75]
        self.motors = [self.jdict[n] for n in self.motor_names] 
开发者ID:gkahn13,项目名称:GtS,代码行数:29,代码来源:robot_locomotors.py

示例4: step

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def step(self, action):
        obs, rew, env_done, info = SemanticRobotEnv.step(self,action=action)
        self.close_semantic_ids = self.get_close_semantic_pos(dist_max=1.0, orn_max=np.pi/5)
        for i in self.close_semantic_ids:
            flagId = self.semantic_flagIds[i]
            p.changeVisualShape(flagId, -1, rgbaColor=[0, 1, 0, 1])
        return obs,rew,env_done,info 
开发者ID:alexsax,项目名称:midlevel-reps,代码行数:9,代码来源:husky_env.py

示例5: _reset

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def _reset(self):
        CameraRobotEnv._reset(self)
        for flagId in self.semantic_flagIds:
            p.changeVisualShape(flagId, -1, rgbaColor=[1, 0, 0, 1]) 
开发者ID:alexsax,项目名称:midlevel-reps,代码行数:6,代码来源:husky_env.py

示例6: __init__

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def __init__(self, robot, gravity, timestep, frame_skip, env=None):
        Scene.__init__(self, gravity, timestep, frame_skip, env)

        filename = os.path.join(pybullet_data.getDataPath(), "stadium_no_collision.sdf")
        self.stadium = p.loadSDF(filename)
        planeName = os.path.join(pybullet_data.getDataPath(), "mjcf/ground_plane.xml")
        self.ground_plane_mjcf = p.loadMJCF(planeName)
        for i in self.ground_plane_mjcf:
            pos, orn = p.getBasePositionAndOrientation(i)
            p.resetBasePositionAndOrientation(i, [pos[0], pos[1], pos[2] - 0.005], orn)

        for i in self.ground_plane_mjcf:
            p.changeVisualShape(i, -1, rgbaColor=[1, 1, 1, 0.5])

        self.scene_obj_list = self.stadium 
开发者ID:alexsax,项目名称:midlevel-reps,代码行数:17,代码来源:scene_stadium.py

示例7: __init__

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [as 别名]
def __init__(self, robot, task,
                 gui=False,
                 opengl2=False,
                 ros=False,
                 features="",
                 ros_name="simulation",
                 option=None,
                 plot_task=False,
                 directory='.',
                 capture=False,
                 show_images=False,
                 randomize_color=False,
                 fast_reset=False,
                 agent=None,
                 *args, **kwargs):
        # Do not start the gui if we aren't going to do anything with it.
        self.gui = gui \
                and not plot_task \
                and agent is not None \
                and agent is not "null"
        self.opengl2 = opengl2 and not plot_task \
                and agent is not None \
                and agent is not "null"
        self.robot = GetRobotInterface(robot)
        features = GetFeatures(features)
        self.task = GetTaskDefinition(
            task, self.robot, features, *args, **kwargs)
        self.fast_reset = fast_reset

        # managed list of processes and other metadata
        self.procs = []
        self.ros = ros

        # saving
        self.capture = capture
        self.show_images = show_images
        self.directory = directory
        self.randomize_color = randomize_color
        # self.iterations = 0
        # self.max_iterations = 100

        if ros:
            # boot up ROS and open a connection to the simulation server
            self._start_ros(ros_name)

        self.open()

        if randomize_color:
            for i in xrange(pb.getNumJoints(self.robot.handle)):
                color = np.random.random((4,))
                color[3] = 1.
                pb.changeVisualShape(self.robot.handle, i, rgbaColor=color,
                                     physicsClientId=self.client)

        if plot_task:
            print("SHOWING TASK")
            showTask(self.task.task)
            print("DONE")
            sys.exit(0) 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:61,代码来源:client.py

示例8: __init__

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import changeVisualShape [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.changeVisualShape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。