Python pybullet.configureDebugVisualizer() Examples
The following are 9
code examples of pybullet.configureDebugVisualizer().
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: human_testing.py From assistive-gym with MIT License | 6 votes |
def reset(self, robot_base_offset=[0, 0, 0], task='scratch_itch_pr2'): self.human, self.wheelchair, self.robot, self.robot_lower_limits, self.robot_upper_limits, self.human_lower_limits, self.human_upper_limits, self.robot_right_arm_joint_indices, self.robot_left_arm_joint_indices, self.gender = self.world_creation.create_new_world(furniture_type=None, static_human_base=True, human_impairment='none', print_joints=False, gender='random') p.resetDebugVisualizerCamera(cameraDistance=1.2, cameraYaw=0, cameraPitch=-20, cameraTargetPosition=[0, 0, 1.0], physicsClientId=self.id) joints_positions = [] # self.human_controllable_joint_indices = [] self.human_controllable_joint_indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # self.human_controllable_joint_indices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] self.world_creation.setup_human_joints(self.human, joints_positions, self.human_controllable_joint_indices, use_static_joints=True, human_reactive_force=None) p.setGravity(0, 0, 0, physicsClientId=self.id) # Enable rendering p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1, physicsClientId=self.id) return []
Example #2
Source File: simulation_manager.py From qibullet with Apache License 2.0 | 6 votes |
def setLightPosition(self, physics_client, light_position): """ Set the position of the GUI's light (does not work in DIRECT mode) Parameters: light_position - List containing the 3D positions [x, y, z] along the X, Y, and Z axis in the world frame, in meters """ try: assert isinstance(light_position, list) assert len(light_position) == 3 pybullet.configureDebugVisualizer( lightPosition=light_position, physicsClientId=physics_client) except AssertionError: raise pybullet.error("Incorrect light position format")
Example #3
Source File: env_bases.py From GtS with MIT License | 5 votes |
def __init__(self, config, scene_type, tracking_camera): ## Properties already instantiated from SensorEnv/CameraEnv # @self.robot self.gui = config["mode"] == "gui" self.model_id = config["model_id"] self.timestep = 0.1 #internal gibson self.frame_skip = 1 #internal gibson self.resolution = config["resolution"] self.tracking_camera = tracking_camera self.robot = None # initial_orn, initial_pos = config["initial_orn"], self.config["initial_pos"] if config["display_ui"]: #self.physicsClientId = p.connect(p.DIRECT) self.physicsClientId = p.connect(p.GUI, "--opengl2") p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0) elif (self.gui): self.physicsClientId = p.connect(p.GUI, "--opengl2") else: self.physicsClientId = p.connect(p.DIRECT) self.camera = Camera() self._seed() self._cam_dist = 3 self._cam_yaw = 0 self._cam_pitch = -30 self.scene_type = scene_type self.scene = None
Example #4
Source File: env_bases.py From GtS with MIT License | 5 votes |
def _reset(self): assert self.robot is not None, "Pleases introduce robot to environment before resetting." p.configureDebugVisualizer(p.COV_ENABLE_GUI,0) p.configureDebugVisualizer(p.COV_ENABLE_KEYBOARD_SHORTCUTS, 0) p.configureDebugVisualizer(p.COV_ENABLE_MOUSE_PICKING, 1) p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, 1) p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1) self.frame = 0 self.done = 0 self.reward = 0 dump = 0 state = self.robot.reset() self.scene.episode_restart() return state
Example #5
Source File: env_bases.py From midlevel-reps with MIT License | 5 votes |
def __init__(self, config, scene_type, tracking_camera): ## Properties already instantiated from SensorEnv/CameraEnv # @self.robot self.gui = config["mode"] == "gui" if "model_id" in config: self.model_id = config["model_id"] self.timestep = config["speed"]["timestep"] self.frame_skip = config["speed"]["frameskip"] self.resolution = config["resolution"] self.tracking_camera = tracking_camera self.robot = None target_orn, target_pos = config["target_orn"], self.config["target_pos"] initial_orn, initial_pos = config["initial_orn"], self.config["initial_pos"] if config["display_ui"]: #self.physicsClientId = p.connect(p.DIRECT) self.physicsClientId = p.connect(p.GUI, "--opengl2") p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0) elif (self.gui): self.physicsClientId = p.connect(p.GUI, "--opengl2") else: self.physicsClientId = p.connect(p.DIRECT) self.camera = Camera() self._seed() self._cam_dist = 3 self._cam_yaw = 0 self._cam_pitch = -30 self.scene_type = scene_type self.scene = None
Example #6
Source File: env_bases.py From midlevel-reps with MIT License | 5 votes |
def _reset(self): assert self.robot is not None, "Pleases introduce robot to environment before resetting." p.configureDebugVisualizer(p.COV_ENABLE_GUI,0) p.configureDebugVisualizer(p.COV_ENABLE_KEYBOARD_SHORTCUTS, 0) p.configureDebugVisualizer(p.COV_ENABLE_MOUSE_PICKING, 1) p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, 1) p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1) self.frame = 0 self.done = 0 self.reward = 0 dump = 0 state = self.robot.reset() self.scene.episode_restart() return state
Example #7
Source File: scratch_itch.py From assistive-gym with MIT License | 4 votes |
def reset(self): self.setup_timing() self.task_success = 0 self.prev_target_contact_pos = np.zeros(3) self.human, self.wheelchair, self.robot, self.robot_lower_limits, self.robot_upper_limits, self.human_lower_limits, self.human_upper_limits, self.robot_right_arm_joint_indices, self.robot_left_arm_joint_indices, self.gender = self.world_creation.create_new_world(furniture_type='wheelchair', static_human_base=True, human_impairment='random', print_joints=False, gender='random') self.robot_lower_limits = self.robot_lower_limits[self.robot_left_arm_joint_indices] self.robot_upper_limits = self.robot_upper_limits[self.robot_left_arm_joint_indices] self.reset_robot_joints() if self.robot_type == 'jaco': wheelchair_pos, wheelchair_orient = p.getBasePositionAndOrientation(self.wheelchair, physicsClientId=self.id) p.resetBasePositionAndOrientation(self.robot, np.array(wheelchair_pos) + np.array([-0.35, -0.3, 0.3]), p.getQuaternionFromEuler([0, 0, -np.pi/2.0], physicsClientId=self.id), physicsClientId=self.id) joints_positions = [(3, np.deg2rad(30)), (6, np.deg2rad(-90)), (16, np.deg2rad(-90)), (28, np.deg2rad(-90)), (31, np.deg2rad(80)), (35, np.deg2rad(-90)), (38, np.deg2rad(80))] self.human_controllable_joint_indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] self.world_creation.setup_human_joints(self.human, joints_positions, self.human_controllable_joint_indices, use_static_joints=True, human_reactive_force=None if self.human_control else 1, human_reactive_gain=0.01) p.resetBasePositionAndOrientation(self.human, [0, 0.03, 0.89 if self.gender == 'male' else 0.86], [0, 0, 0, 1], physicsClientId=self.id) human_joint_states = p.getJointStates(self.human, jointIndices=self.human_controllable_joint_indices, physicsClientId=self.id) self.target_human_joint_positions = np.array([x[0] for x in human_joint_states]) self.human_lower_limits = self.human_lower_limits[self.human_controllable_joint_indices] self.human_upper_limits = self.human_upper_limits[self.human_controllable_joint_indices] shoulder_pos, shoulder_orient = p.getLinkState(self.human, 5, computeForwardKinematics=True, physicsClientId=self.id)[:2] elbow_pos, elbow_orient = p.getLinkState(self.human, 7, computeForwardKinematics=True, physicsClientId=self.id)[:2] wrist_pos, wrist_orient = p.getLinkState(self.human, 9, computeForwardKinematics=True, physicsClientId=self.id)[:2] if self.robot_type == 'pr2': target_pos = np.array([-0.55, 0, 0.8]) + self.np_random.uniform(-0.05, 0.05, size=3) target_orient = np.array(p.getQuaternionFromEuler(np.array([0, 0, 0]), physicsClientId=self.id)) self.position_robot_toc(self.robot, 76, [(target_pos, target_orient)], [(shoulder_pos, None), (elbow_pos, None), (wrist_pos, None)], self.robot_left_arm_joint_indices, self.robot_lower_limits, self.robot_upper_limits, ik_indices=range(29, 29+7), pos_offset=np.array([0.1, 0, 0]), max_ik_iterations=200, step_sim=True, check_env_collisions=False, human_joint_indices=self.human_controllable_joint_indices, human_joint_positions=self.target_human_joint_positions) self.world_creation.set_gripper_open_position(self.robot, position=0.25, left=True, set_instantly=True) self.tool = self.world_creation.init_tool(self.robot, mesh_scale=[0.001]*3, pos_offset=[0, 0, 0], orient_offset=p.getQuaternionFromEuler([0, 0, 0], physicsClientId=self.id), maximal=False) elif self.robot_type == 'jaco': target_pos = np.array([-0.5, 0, 0.8]) + self.np_random.uniform(-0.05, 0.05, size=3) target_orient = p.getQuaternionFromEuler(np.array([0, np.pi/2.0, 0]), physicsClientId=self.id) self.util.ik_random_restarts(self.robot, 8, target_pos, target_orient, self.world_creation, self.robot_left_arm_joint_indices, self.robot_lower_limits, self.robot_upper_limits, ik_indices=[0, 1, 2, 3, 4, 5, 6], max_iterations=1000, max_ik_random_restarts=40, random_restart_threshold=0.03, step_sim=True) self.world_creation.set_gripper_open_position(self.robot, position=1, left=True, set_instantly=True) self.tool = self.world_creation.init_tool(self.robot, mesh_scale=[0.001]*3, pos_offset=[0, 0, 0.02], orient_offset=p.getQuaternionFromEuler([0, -np.pi/2.0, 0], physicsClientId=self.id), maximal=False) else: target_pos = np.array([-0.55, 0, 0.8]) + self.np_random.uniform(-0.05, 0.05, size=3) target_orient = p.getQuaternionFromEuler(np.array([0, np.pi/2.0, 0]), physicsClientId=self.id) if self.robot_type == 'baxter': self.position_robot_toc(self.robot, 48, [(target_pos, target_orient)], [(shoulder_pos, None), (elbow_pos, None), (wrist_pos, None)], self.robot_left_arm_joint_indices, self.robot_lower_limits, self.robot_upper_limits, ik_indices=range(10, 17), pos_offset=np.array([0, 0, 0.975]), max_ik_iterations=200, step_sim=True, check_env_collisions=False, human_joint_indices=self.human_controllable_joint_indices, human_joint_positions=self.target_human_joint_positions) else: self.position_robot_toc(self.robot, 19, [(target_pos, target_orient)], [(shoulder_pos, None), (elbow_pos, None), (wrist_pos, None)], self.robot_left_arm_joint_indices, self.robot_lower_limits, self.robot_upper_limits, ik_indices=[0, 2, 3, 4, 5, 6, 7], pos_offset=np.array([-0.1, 0, 0.975]), max_ik_iterations=200, step_sim=True, check_env_collisions=False, human_joint_indices=self.human_controllable_joint_indices, human_joint_positions=self.target_human_joint_positions) self.world_creation.set_gripper_open_position(self.robot, position=0.015, left=True, set_instantly=True) self.tool = self.world_creation.init_tool(self.robot, mesh_scale=[0.001]*3, pos_offset=[0, 0.125, 0], orient_offset=p.getQuaternionFromEuler([0, 0, np.pi/2.0], physicsClientId=self.id), maximal=False) self.generate_target() p.setGravity(0, 0, 0, physicsClientId=self.id) p.setGravity(0, 0, -1, body=self.human, physicsClientId=self.id) # Enable rendering p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1, physicsClientId=self.id) return self._get_obs([0], [0, 0])
Example #8
Source File: simulation_manager.py From qibullet with Apache License 2.0 | 4 votes |
def launchSimulation(self, gui=True, use_shared_memory=False): """ Launches a simulation instance Parameters: gui - Boolean, if True the simulation is launched with a GUI, and with no GUI otherwise use_shared_memory - Experimental feature, only taken into account if gui=False, False by default. If True, the simulation will use the pybullet SHARED_MEMORY_SERVER mode to create an instance. If multiple simulation instances are created, this solution allows a multicore parallelisation of the bullet motion servers (one for each instance). In DIRECT mode, such a parallelisation is not possible and the motion servers are manually stepped using the _stepSimulation method. (More information in the setup section of the qiBullet wiki, and in the pybullet documentation) Returns: physics_client - The id of the simulation client created """ if gui: # pragma: no cover physics_client = pybullet.connect(pybullet.GUI) pybullet.setRealTimeSimulation(1, physicsClientId=physics_client) pybullet.configureDebugVisualizer( pybullet.COV_ENABLE_RGB_BUFFER_PREVIEW, 0, physicsClientId=physics_client) pybullet.configureDebugVisualizer( pybullet.COV_ENABLE_DEPTH_BUFFER_PREVIEW, 0, physicsClientId=physics_client) pybullet.configureDebugVisualizer( pybullet.COV_ENABLE_SEGMENTATION_MARK_PREVIEW, 0, physicsClientId=physics_client) else: if use_shared_memory: physics_client = pybullet.connect( pybullet.SHARED_MEMORY_SERVER) pybullet.setRealTimeSimulation( enableRealTimeSimulation=1, physicsClientId=physics_client) else: physics_client = pybullet.connect(pybullet.DIRECT) threading.Thread( target=self._stepSimulation, args=[physics_client]).start() pybullet.setGravity(0, 0, -9.81, physicsClientId=physics_client) return physics_client
Example #9
Source File: icub_reach_gym_env.py From pybullet-robot-envs with GNU Lesser General Public License v2.1 | 4 votes |
def __init__(self, action_repeat=1, use_IK=1, control_arm='l', control_orientation=0, obj_name=get_objects_list()[0], obj_pose_rnd_std=0, renders=False, max_steps=2000): self._time_step = 1. / 240. self._control_arm = control_arm self._use_IK = use_IK self._control_orientation = control_orientation self._action_repeat = action_repeat self._observation = [] self._hand_pose = [] self._env_step_counter = 0 self._renders = renders self._max_steps = max_steps self._last_frame_time = 0 self.terminated = 0 self._target_dist_min = 0.03 # Initialize PyBullet simulator self._p = p if self._renders: self._physics_client_id = p.connect(p.SHARED_MEMORY) if self._physics_client_id < 0: self._physics_client_id = p.connect(p.GUI) p.resetDebugVisualizerCamera(2.5, 90, -60, [0.0, -0.0, -0.0], physicsClientId=self._physics_client_id) p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, 0) else: self._physics_client_id = p.connect(p.DIRECT) # Load robot self._robot = iCubEnv(self._physics_client_id, use_IK=self._use_IK, control_arm=self._control_arm, control_orientation=self._control_orientation) # Load world environment self._world = WorldEnv(self._physics_client_id, obj_name=obj_name, obj_pose_rnd_std=obj_pose_rnd_std, workspace_lim=self._robot.get_workspace()) # limit iCub workspace to table plane workspace = self._robot.get_workspace() workspace[2][0] = self._world.get_table_height() self._robot.set_workspace(workspace) # Define spaces self.observation_space, self.action_space = self.create_gym_spaces() # initialize simulation environment self.seed() # self.reset()