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


Python pybullet.DIRECT屬性代碼示例

本文整理匯總了Python中pybullet.DIRECT屬性的典型用法代碼示例。如果您正苦於以下問題:Python pybullet.DIRECT屬性的具體用法?Python pybullet.DIRECT怎麽用?Python pybullet.DIRECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pybullet的用法示例。


在下文中一共展示了pybullet.DIRECT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:22,代碼來源:bullet_client.py

示例2: open

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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() 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:21,代碼來源:client.py

示例3: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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) 
開發者ID:nicrusso7,項目名稱:rex-gym,代碼行數:22,代碼來源:bullet_client.py

示例4: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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 = {} 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:9,代碼來源:bullet_client.py

示例5: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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 = {} 
開發者ID:facebookresearch,項目名稱:pyrobot,代碼行數:9,代碼來源:bullet_client.py

示例6: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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))
        } 
開發者ID:benelot,項目名稱:bullet-gym,代碼行數:33,代碼來源:MJCFHopperv0Env.py

示例7: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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))
        } 
開發者ID:benelot,項目名稱:bullet-gym,代碼行數:33,代碼來源:MJCFReacherv0Env.py

示例8: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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))
        } 
開發者ID:benelot,項目名稱:bullet-gym,代碼行數:52,代碼來源:MJCFInvPendulumv0Env.py

示例9: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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))
        } 
開發者ID:benelot,項目名稱:bullet-gym,代碼行數:53,代碼來源:MJCF2InvPendulumv0Env.py

示例10: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import DIRECT [as 別名]
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) 
開發者ID:benelot,項目名稱:bullet-gym,代碼行數:63,代碼來源:Motionv0Env.py


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