Python pybullet.DIRECT Examples
The following are 11
code examples of pybullet.DIRECT().
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: bullet_client.py From soccer-matlab with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, connection_mode=None): """Creates a Bullet client and connects to a simulation. Args: connection_mode: `None` connects to an existing simulation or, if fails, creates a new headless simulation, `pybullet.GUI` creates a new simulation with a GUI, `pybullet.DIRECT` creates a headless simulation, `pybullet.SHARED_MEMORY` connects to an existing simulation. """ self._shapes = {} if connection_mode is None: self._client = pybullet.connect(pybullet.SHARED_MEMORY) if self._client >= 0: return else: connection_mode = pybullet.DIRECT self._client = pybullet.connect(connection_mode)
Example #2
Source File: bullet_client.py From soccer-matlab with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, connection_mode=None): """Creates a Bullet client and connects to a simulation. Args: connection_mode: `None` connects to an existing simulation or, if fails, creates a new headless simulation, `pybullet.GUI` creates a new simulation with a GUI, `pybullet.DIRECT` creates a headless simulation, `pybullet.SHARED_MEMORY` connects to an existing simulation. """ self._shapes = {} if connection_mode is None: self._client = pybullet.connect(pybullet.SHARED_MEMORY) if self._client >= 0: return else: connection_mode = pybullet.DIRECT self._client = pybullet.connect(connection_mode)
Example #3
Source File: client.py From costar_plan with Apache License 2.0 | 6 votes |
def open(self): ''' Decide how we will create our interface to the underlying simulation. We can create a GUI connection or something else. ''' options = "" if self.opengl2: connect_type = pb.GUI options = "--opengl2" elif self.gui: connect_type = pb.GUI else: connect_type = pb.DIRECT self.client = pb.connect(connect_type, options=options) GRAVITY = (0,0,-9.8) pb.setGravity(*GRAVITY) # place the robot in the world and set up the task self.task.setup()
Example #4
Source File: bullet_client.py From rex-gym with Apache License 2.0 | 6 votes |
def __init__(self, connection_mode=None): """Creates a Bullet client and connects to a simulation. Args: connection_mode: `None` connects to an existing simulation or, if fails, creates a new headless simulation, `pybullet.GUI` creates a new simulation with a GUI, `pybullet.DIRECT` creates a headless simulation, `pybullet.SHARED_MEMORY` connects to an existing simulation. """ self._shapes = {} if connection_mode is None: self._client = pybullet.connect(pybullet.SHARED_MEMORY) if self._client >= 0: return else: connection_mode = pybullet.DIRECT self._client = pybullet.connect(connection_mode)
Example #5
Source File: bullet_client.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, connection_mode=pybullet.DIRECT, options=""): """Create a simulation and connect to it.""" self._client = pybullet.connect(pybullet.SHARED_MEMORY) if(self._client<0): print("options=",options) self._client = pybullet.connect(connection_mode,options=options) self._shapes = {}
Example #6
Source File: bullet_client.py From pyrobot with MIT License | 5 votes |
def __init__(self, connection_mode=pybullet.DIRECT, options=""): """Create a simulation and connect to it.""" self._client = pybullet.connect(pybullet.SHARED_MEMORY) if self._client < 0: print("options=", options) self._client = pybullet.connect(connection_mode, options=options) self._shapes = {}
Example #7
Source File: MJCFHopperv0Env.py From bullet-gym with MIT License | 5 votes |
def __init__(self, opts): self.gui = opts.gui self.max_episode_len = opts.max_episode_len self.delay = opts.delay if self.gui else 0.0 # do some parameter setting from your parser arguments and add other configurations # how many time to repeat each action per step(). # and how many sim steps to do per state capture # (total number of sim steps = action_repeats * steps_per_repeat self.repeats = opts.action_repeats self.steps_per_repeat = opts.steps_per_repeat # setup bullet p.connect(p.GUI if self.gui else p.DIRECT) p.setGravity(0,0,-9.81) PybulletMujocoEnv.__init__(self, "envs/models/mjcf/hopper.xml", "walker", 0.02, frame_skip=2, action_dim=3, obs_dim=8, repeats=self.repeats) self.torso = self.parts["torso"] self.foot = self.parts["foot"] self.thigh_joint = self.joints["thigh_joint"] self.leg_joint = self.joints["leg_joint"] self.foot_joint = self.joints["foot_joint"] self.metadata = { 'discrete_actions' : False, 'continuous_actions': True, 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip)) }
Example #8
Source File: MJCFReacherv0Env.py From bullet-gym with MIT License | 5 votes |
def __init__(self, opts): self.gui = opts.gui self.max_episode_len = opts.max_episode_len self.delay = opts.delay if self.gui else 0.0 # do some parameter setting from your parser arguments and add other configurations # how many time to repeat each action per step(). # and how many sim steps to do per state capture # (total number of sim steps = action_repeats * steps_per_repeat self.repeats = opts.action_repeats self.steps_per_repeat = opts.steps_per_repeat # setup bullet p.connect(p.GUI if self.gui else p.DIRECT) PybulletMujocoEnv.__init__(self, "envs/models/mjcf/reacher.xml", "walker", 0.02, frame_skip=2, action_dim=2, obs_dim=9, repeats=self.repeats) self.target_x = self.joints["target_x"] self.target_y = self.joints["target_y"] self.fingertip = self.parts["fingertip"] self.target = self.parts["target"] self.central_joint = self.joints["joint0"] self.elbow_joint = self.joints["joint1"] self.metadata = { 'discrete_actions' : False, 'continuous_actions': True, 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip)) }
Example #9
Source File: MJCFInvPendulumv0Env.py From bullet-gym with MIT License | 4 votes |
def __init__(self, opts): self.gui = opts.gui self.max_episode_len = opts.max_episode_len self.delay = opts.delay if self.gui else 0.0 # do some parameter setting from your parser arguments and add other configurations # threshold for angle from z-axis. # if x or y > this value we finish episode. self.angle_threshold = 0.26 # radians; ~= 15deg # initial push force. this should be enough that taking no action will always # result in pole falling after initial_force_steps but not so much that you # can't recover. see also initial_force_steps. self.initial_force = opts.initial_force # number of sim steps initial force is applied. # (see initial_force) self.initial_force_steps = 30 # whether we do initial push in a random direction # if false we always push with along x-axis (simplee problem, useful for debugging) self.random_theta = not opts.no_random_theta # how many time to repeat each action per step(). # and how many sim steps to do per state capture # (total number of sim steps = action_repeats * steps_per_repeat self.repeats = opts.action_repeats self.steps_per_repeat = opts.steps_per_repeat self.swingup = opts.swingup self.reward_calc = opts.reward_calc # setup bullet p.connect(p.GUI if self.gui else p.DIRECT) p.setGravity(0, 0, -9.81) # maybe you need gravity? PybulletMujocoEnv.__init__(self, "envs/models/mjcf/inverted_pendulum.xml", "walker", 0.02, frame_skip=2, action_dim=1, obs_dim=5, repeats=self.repeats) self.slider = self.joints["slider"] self.polejoint = self.joints["hinge"] self.metadata = { 'discrete_actions' : False, 'continuous_actions': True, 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip)) }
Example #10
Source File: MJCF2InvPendulumv0Env.py From bullet-gym with MIT License | 4 votes |
def __init__(self, opts): self.gui = opts.gui self.max_episode_len = opts.max_episode_len self.delay = opts.delay if self.gui else 0.0 # do some parameter setting from your parser arguments and add other configurations # threshold for angle from z-axis. # if x or y > this value we finish episode. self.angle_threshold = 0.26 # radians; ~= 15deg # initial push force. this should be enough that taking no action will always # result in pole falling after initial_force_steps but not so much that you # can't recover. see also initial_force_steps. self.initial_force = opts.initial_force # number of sim steps initial force is applied. # (see initial_force) self.initial_force_steps = 30 # whether we do initial push in a random direction # if false we always push with along x-axis (simplee problem, useful for debugging) self.random_theta = not opts.no_random_theta # how many time to repeat each action per step(). # and how many sim steps to do per state capture # (total number of sim steps = action_repeats * steps_per_repeat self.repeats = opts.action_repeats self.steps_per_repeat = opts.steps_per_repeat self.swingup = opts.swingup self.reward_calc = opts.reward_calc # setup bullet p.connect(p.GUI if self.gui else p.DIRECT) p.setGravity(0, 0, -9.81) # maybe you need gravity? PybulletMujocoEnv.__init__(self, "envs/models/mjcf/inverted_double_pendulum.xml", "walker", 0.02, frame_skip=2, action_dim=1, obs_dim=8, repeats=self.repeats) self.slider = self.joints["slider"] self.polejoint = self.joints["hinge"] self.pole2joint = self.joints["hinge2"] self.metadata = { 'discrete_actions' : False, 'continuous_actions': True, 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': int(np.round(1.0 / self.timestep / self.frame_skip)) }
Example #11
Source File: Motionv0Env.py From bullet-gym with MIT License | 4 votes |
def __init__(self, opts): self.gui = opts.gui self.max_episode_len = opts.max_episode_len self.delay = opts.delay if self.gui else 0.0 self.metadata = { 'discrete_actions' : True, 'continuous_actions' : True, 'render.modes': ['human', 'rgb_array'], 'video.frames_per_second' : int(np.round(1.0 / 25.0)) } # do some parameter setting from your parser arguments and add other configurations self.control_type = opts.control_type # force to apply per action simulation step. # in the discrete case this is the fixed gain applied # in the continuous case each x/y is in range (-G, G) self.action_gain = opts.action_gain # scale of control (position, velocity) self.action_force = opts.action_force # Newton # how many time to repeat each action per step(). # and how many sim steps to do per state capture # (total number of sim steps = action_repeats * steps_per_repeat self.repeats = opts.action_repeats self.steps_per_repeat = opts.steps_per_repeat self.random_initial_position = opts.random_initial_position # setup bullet p.connect(p.GUI if self.gui else p.DIRECT) p.setGravity(0, 0, opts.gravity_force) # maybe you need gravity? p.loadURDF("envs/models/ground.urdf", 0,0,0, 0,0,0,1) # load your models if opts.morphology_type == 1: self.body = p.loadURDF("envs/models/simple-snakev0.urdf",0,0,2, 0,0,0,1) elif opts.morphology_type == 2: self.body = p.loadURDF("envs/models/springy-snakev0.urdf",0,0,2, 0,0,0,1) elif opts.morphology_type == 3: self.body = p.loadURDF("envs/models/phantomx/phantomx.urdf",0,0,2, 0,0,0,1) self.initPosition, self.initOrientation = p.getBasePositionAndOrientation(self.body) self.num_joints = p.getNumJoints(self.body) self.velocityHelper = VelocityHelper(self.body) self.reward = RewardFunction(self.body, RewardFunction.PositionReward, RewardFunction.XAxis) # velocity in X axis dimension gets rewarded # in the low dimensional case obs space for problem is (R, num_links, 13) # R = number of repeats # num joints + 1 = number of links of snake # 13d tuple for pos + orientation + velocities (angular velocity in euler) self.state_shape = (self.repeats, p.getNumJoints(self.body)+1, 13) # no state until reset. self.state = np.empty(self.state_shape, dtype=np.float32)