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


Python pybullet.readUserDebugParameter方法代码示例

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


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

示例1: render

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import readUserDebugParameter [as 别名]
def render(self, mode='human', close=False):
        if mode != "rgb_array":
            return np.array([])
        camera_target_pos = self.camera_target_pos

        if self.debug:
            self._cam_dist = p.readUserDebugParameter(self.dist_slider)
            self._cam_yaw = p.readUserDebugParameter(self.yaw_slider)
            self._cam_pitch = p.readUserDebugParameter(self.pitch_slider)
            x = p.readUserDebugParameter(self.x_slider)
            y = p.readUserDebugParameter(self.y_slider)
            z = p.readUserDebugParameter(self.z_slider)
            camera_target_pos = (x, y, z)
            # self._cam_roll = p.readUserDebugParameter(self.roll_slider)

        # TODO: recompute view_matrix and proj_matrix only in debug mode
        view_matrix1 = p.computeViewMatrixFromYawPitchRoll(
            cameraTargetPosition=camera_target_pos,
            distance=self._cam_dist,
            yaw=self._cam_yaw,
            pitch=self._cam_pitch,
            roll=self._cam_roll,
            upAxisIndex=2)
        proj_matrix1 = p.computeProjectionMatrixFOV(
            fov=60, aspect=float(RENDER_WIDTH) / RENDER_HEIGHT,
            nearVal=0.1, farVal=100.0)
        (_, _, px1, _, _) = p.getCameraImage(
            width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix1,
            projectionMatrix=proj_matrix1, renderer=self.renderer)
        rgb_array1 = np.array(px1)

        if self.multi_view:
            # adding a second camera on the other side of the robot
            view_matrix2 = p.computeViewMatrixFromYawPitchRoll(
                cameraTargetPosition=(0.316, 0.316, -0.105),
                distance=1.05,
                yaw=32,
                pitch=-13,
                roll=0,
                upAxisIndex=2)
            proj_matrix2 = p.computeProjectionMatrixFOV(
                fov=60, aspect=float(RENDER_WIDTH) / RENDER_HEIGHT,
                nearVal=0.1, farVal=100.0)
            (_, _, px2, _, _) = p.getCameraImage(
                width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix2,
                projectionMatrix=proj_matrix2, renderer=self.renderer)
            rgb_array2 = np.array(px2)
            rgb_array_res = np.concatenate((rgb_array1[:, :, :3], rgb_array2[:, :, :3]), axis=2)
        else:
            rgb_array_res = rgb_array1[:, :, :3]
        return rgb_array_res 
开发者ID:araffin,项目名称:robotics-rl-srl,代码行数:53,代码来源:kuka_button_gym_env.py

示例2: render

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import readUserDebugParameter [as 别名]
def render(self, mode='human', close=False):
        if mode != "rgb_array":
            return np.array([])
        camera_target_pos = self.camera_target_pos

        if self.debug:
            self._cam_dist = p.readUserDebugParameter(self.dist_slider)
            self._cam_yaw = p.readUserDebugParameter(self.yaw_slider)
            self._cam_pitch = p.readUserDebugParameter(self.pitch_slider)
            x = p.readUserDebugParameter(self.x_slider)
            y = p.readUserDebugParameter(self.y_slider)
            z = p.readUserDebugParameter(self.z_slider)
            camera_target_pos = (x, y, z)

        # TODO: recompute view_matrix and proj_matrix only in debug mode
        view_matrix = p.computeViewMatrixFromYawPitchRoll(
            cameraTargetPosition=camera_target_pos,
            distance=self._cam_dist,
            yaw=self._cam_yaw,
            pitch=self._cam_pitch,
            roll=self._cam_roll,
            upAxisIndex=2)
        proj_matrix = p.computeProjectionMatrixFOV(
            fov=60, aspect=float(RENDER_WIDTH) / RENDER_HEIGHT,
            nearVal=0.1, farVal=100.0)
        (_, _, px1, _, _) = p.getCameraImage(
            width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix,
            projectionMatrix=proj_matrix, renderer=self.renderer)
        rgb_array = np.array(px1)

        rgb_array_res = rgb_array[:, :, :3]

        # if first person view, then stack the obersvation from the car camera
        if self.fpv:
            # move camera
            view_matrix = p.computeViewMatrixFromYawPitchRoll(
                cameraTargetPosition=(self.robot_pos[0]-0.25, self.robot_pos[1], 0.15),
                distance=0.3,
                yaw=self._cam_yaw,
                pitch=-17,
                roll=self._cam_roll,
                upAxisIndex=2)
            proj_matrix = p.computeProjectionMatrixFOV(
                fov=90, aspect=float(RENDER_WIDTH) / RENDER_HEIGHT,
                nearVal=0.1, farVal=100.0)
            # get and stack image
            (_, _, px1, _, _) = p.getCameraImage(
                width=RENDER_WIDTH, height=RENDER_HEIGHT, viewMatrix=view_matrix,
                projectionMatrix=proj_matrix, renderer=self.renderer)
            rgb_array = np.array(px1)
            rgb_array_res = np.dstack([rgb_array_res, rgb_array[:, :, :3]])

        return rgb_array_res 
开发者ID:araffin,项目名称:robotics-rl-srl,代码行数:55,代码来源:mobile_robot_env.py

示例3: main

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import readUserDebugParameter [as 别名]
def main(joint_control, arm, random_policy):

    use_IK = 0 if joint_control else 1

    env = iCubReachGymEnv(renders=True, control_arm=arm, use_IK=use_IK, control_orientation=1, obj_pose_rnd_std=0.05)
    env.reset()

    motorsIds = []

    if not random_policy:
        if use_IK:
            dv = 1
            motorsIds.append(p.addUserDebugParameter("lhPosX", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPosY", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPosZ", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhRollx", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPitchy", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhYawz", -dv, dv, 0.0))

        else:
            dv = 1
            joints_idx = env._robot._joints_to_control

            for j in joints_idx:
                info = p.getJointInfo(env._robot.robot_id, j)
                jointName = info[1]
                motorsIds.append(p.addUserDebugParameter(jointName.decode("utf-8"), -dv, dv, 0.0))

    done = False
    for t in range(10000000):
        # env.render()

        if not random_policy:
            action = []
            for motorId in motorsIds:
                action.append(p.readUserDebugParameter(motorId))

        else:
            action = env.action_space.sample()

        state, reward, done, info = env.step(action)

        if t % 100 == 0:
            print("reward ", reward)

        if done:
            print("done ", done)
            env.reset() 
开发者ID:robotology-playground,项目名称:pybullet-robot-envs,代码行数:50,代码来源:test_icub_push_gym_env.py

示例4: main

# 需要导入模块: import pybullet [as 别名]
# 或者: from pybullet import readUserDebugParameter [as 别名]
def main(cart_control, random_policy):

    use_IK = 1 if cart_control else 0

    env = pandaPushGymGoalEnv(renders=True, use_IK=use_IK, obj_pose_rnd_std=0.0)
    env.reset()

    motorsIds = []

    if not random_policy:
        if use_IK:
            dv = 1
            motorsIds.append(p.addUserDebugParameter("lhPosX", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPosY", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPosZ", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhRollx", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhPitchy", -dv, dv, 0.0))
            motorsIds.append(p.addUserDebugParameter("lhYawz", -dv, dv, 0.0))
        else:
            dv = 1
            joint_idxs = tuple(env._robot._joint_name_to_ids.values())

            for j in joint_idxs[:env._robot.joint_action_space]:
                info = p.getJointInfo(env._robot.robot_id, j)
                jointName = info[1]
                motorsIds.append(p.addUserDebugParameter(jointName.decode("utf-8"), -dv, dv, 0.0))

    done = False
    for t in range(10000000):
        # env.render()

        if not random_policy:
            action = []
            for motorId in motorsIds:
                action.append(p.readUserDebugParameter(motorId))

        else:
            action = env.action_space.sample()

        state, reward, done, info = env.step(action)

        if t % 100 == 0:
            print("reward ", reward)

        if done:
            print("done ", done)
            env.reset() 
开发者ID:robotology-playground,项目名称:pybullet-robot-envs,代码行数:49,代码来源:test_panda_push_gym_env.py


注:本文中的pybullet.readUserDebugParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。