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


Python pybullet.connect方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [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: setup_inverse_kinematics

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def setup_inverse_kinematics(self):
        """
        This function is responsible for doing any setup for inverse kinematics.
        Inverse Kinematics maps end effector (EEF) poses to joint angles that
        are necessary to achieve those poses. 
        """

        # Set up a connection to the PyBullet simulator.
        p.connect(p.DIRECT)
        p.resetSimulation()

        # get paths to urdfs
        self.robot_urdf = pjoin(
            self.bullet_data_path, "sawyer_description/urdf/sawyer_arm.urdf"
        )

        # load the urdfs
        self.ik_robot = p.loadURDF(self.robot_urdf, (0, 0, 0.9), useFixedBase=1)

        # Simulation will update as fast as it can in real time, instead of waiting for
        # step commands like in the non-realtime case.
        p.setRealTimeSimulation(1) 
開發者ID:StanfordVL,項目名稱:robosuite,代碼行數:24,代碼來源:sawyer_ik_controller.py

示例3: setup_inverse_kinematics

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def setup_inverse_kinematics(self):
        """
        This function is responsible for doing any setup for inverse kinematics.
        Inverse Kinematics maps end effector (EEF) poses to joint angles that
        are necessary to achieve those poses.
        """

        # Set up a connection to the PyBullet simulator.
        p.connect(p.DIRECT)
        p.resetSimulation()

        # get paths to urdfs
        self.robot_urdf = pjoin(
            self.bullet_data_path, "panda_description/urdf/panda_arm.urdf"
        )

        # load the urdfs
        self.ik_robot = p.loadURDF(self.robot_urdf, (0, 0, 0.9), useFixedBase=1)

        # Simulation will update as fast as it can in real time, instead of waiting for
        # step commands like in the non-realtime case.
        p.setRealTimeSimulation(1) 
開發者ID:StanfordVL,項目名稱:robosuite,代碼行數:24,代碼來源:panda_ik_controller.py

示例4: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def __init__(self, robot_name, print_debug, email_cred_file='', log_file='', control_rate=100, gripper_attached='default'):
        super(WidowXController, self).__init__(robot_name, print_debug, email_cred_file, log_file, control_rate, gripper_attached)
        self._redist_rate = rospy.Rate(50)

        self._arbotix = ArbotiX('/dev/ttyUSB0')
        assert self._arbotix.syncWrite(MAX_TORQUE_L, [[servo_id, 255, 0] for servo_id in SERVO_IDS]) != -1, "failure during servo configuring"
        assert self._arbotix.syncWrite(TORQUE_LIMIT, [[servo_id, 255, 0] for servo_id in SERVO_IDS]) != -1, "failure during servo configuring"

        self._joint_lock = Lock()
        self._angles, self._velocities = {}, {}
        rospy.Subscriber("/joint_states", JointState, self._joint_callback)
        time.sleep(1)        

        self._joint_pubs = [rospy.Publisher('/{}/command'.format(name), Float64, queue_size=1) for name in JOINT_NAMES[:-1]]
        self._gripper_pub = rospy.Publisher('/gripper_prismatic_joint/command', Float64, queue_size=1)

        p.connect(p.DIRECT)
        widow_x_urdf = '/'.join(__file__.split('/')[:-1]) + '/widowx/widowx.urdf'
        self._armID = p.loadURDF(widow_x_urdf, useFixedBase=True) 
        p.resetBasePositionAndOrientation(self._armID, [0, 0, 0], p.getQuaternionFromEuler([np.pi, np.pi, np.pi]))       
        self._n_errors = 0 
開發者ID:SudeepDasari,項目名稱:visual_foresight,代碼行數:23,代碼來源:widowx_controller.py

示例5: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def __init__(self,
               render_mode='DIRECT',
               hidden_drift=False,
               urdf_root=''):
    """Construct a Duck pose prediction task.

    Args:
      render_mode: Whether to render headless or with a GUI.
      hidden_drift: If True, each task will assign a hidden random drift where
        the rendered pose differs from the true pose. Requires meta-learning
        adaptation to solve.
      urdf_root: Path to URDF files.
    """
    if render_mode == 'GUI':
      self.cid = pybullet.connect(pybullet.GUI)
    elif render_mode == 'DIRECT':
      self.cid = pybullet.connect(pybullet.DIRECT)
    self._width, self._height = 64, 64
    self._urdf_root = urdf_root
    self._hidden_drift = hidden_drift
    self._hidden_drift_xyz = None
    self._setup()
    self.reset_task() 
開發者ID:google-research,項目名稱:tensor2robot,代碼行數:25,代碼來源:pose_env.py

示例6: _start_ros

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def _start_ros(self, name):
        '''
        Simple function to boot up a ROS core and make sure that we connect to
        it. The goal is to manage internal ROS stuff via this script to provide
        an easy and repeatable interface when running experiments.
        '''
        self._start_process(['roscore'], 1.)
        started = False
        tries = 0
        while not started:
            try:
                rospy.init_node(name)
                started = True
            except Exception, e:
                pass
            finally: 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:18,代碼來源:client.py

示例7: open

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [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

示例8: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [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

示例9: __init__

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def __init__(self, render=False):
        self._observation = []
        self.action_space = spaces.Discrete(9)
        self.observation_space = spaces.Box(np.array([-math.pi, -math.pi, -5]), 
                                            np.array([math.pi, math.pi, 5])) # pitch, gyro, com.sp.

        if (render):
            self.physicsClient = p.connect(p.GUI)
        else:
            self.physicsClient = p.connect(p.DIRECT)  # non-graphical version

        p.setAdditionalSearchPath(pybullet_data.getDataPath())  # used by loadURDF

        self._seed()
        
        # paramId = p.addUserDebugParameter("My Param", 0, 100, 50) 
開發者ID:yconst,項目名稱:balance-bot,代碼行數:18,代碼來源:balancebot_env.py

示例10: main

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def main(unused_args):
  timeStep = 0.01
  c = p.connect(p.SHARED_MEMORY)
  if (c<0):
      c = p.connect(p.GUI)

  params = [0.1903581461951056, 0.0006732219568880068, 0.05018085615283363, 3.219916795483583, 6.2406418167980595, 4.189869754607539]
  evaluate_func = 'evaluate_desired_motorAngle_2Amplitude4Phase'
  energy_weight = 0.01

  finalReturn = evaluate_params(evaluateFunc = evaluate_func, params=params, objectiveParams=[energy_weight], timeStep=timeStep, sleepTime=timeStep)

  print(finalReturn) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:15,代碼來源:minitaur_test.py

示例11: readLogFile

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def readLogFile(filename, verbose = True):
  f = open(filename, 'rb')
  
  print('Opened'),
  print(filename)

  keys = f.readline().decode('utf8').rstrip('\n').split(',')
  fmt = f.readline().decode('utf8').rstrip('\n')
  
  # The byte number of one record
  sz = struct.calcsize(fmt)
  # The type number of one record
  ncols = len(fmt)

  if verbose:
    print('Keys:'),
    print(keys)
    print('Format:'),
    print(fmt)
    print('Size:'),
    print(sz)
    print('Columns:'),
    print(ncols)

  # Read data
  wholeFile = f.read()
  # split by alignment word
  chunks = wholeFile.split(b'\xaa\xbb')
  log = list()
  for chunk in chunks:
    if len(chunk) == sz:
      values = struct.unpack(fmt, chunk)
      record = list()
      for i in range(ncols):
        record.append(values[i])
      log.append(record)

  return log

#clid = p.connect(p.SHARED_MEMORY) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:42,代碼來源:kuka_grasp_block_playback.py

示例12: test_connect_direct

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def test_connect_direct(self):
        import pybullet as p
        cid = p.connect(p.DIRECT)
        self.assertEqual(cid,0)
        p.disconnect() 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:7,代碼來源:unittests.py

示例13: test_loadurdf

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def test_loadurdf(self):
        import pybullet as p
        p.connect(p.DIRECT)
        ob = p.loadURDF("r2d2.urdf")
        self.assertEqual(ob,0)
        p.disconnect() 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:8,代碼來源:unittests.py

示例14: main

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def main():
    pybullet.connect(pybullet.DIRECT)
    env = gym.make("AntBulletEnv-v0")
    env.render(mode="human")
    
    pi = SmallReactivePolicy(env.observation_space, env.action_space)
    env.reset()

    while 1:
        frame = 0
        score = 0
        restart_delay = 0
        obs = env.reset()
        
        while 1:
            time.sleep(1./60.)
            a = pi.act(obs)
            obs, r, done, _ = env.step(a)
            #print("reward")
            #print(r)
            score += r
            frame += 1
            distance=5
            yaw = 0

            still_open = env.render("human")
            if still_open==False:
                return
            if not done: continue
            if restart_delay==0:
                print("score=%0.2f in %i frames" % (score, frame))
                restart_delay = 60*2  # 2 sec at 60 fps
            else:
                restart_delay -= 1
                if restart_delay==0: break 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:37,代碼來源:enjoy_TF_AntBulletEnv_v0_2017may.py

示例15: test

# 需要導入模塊: import pybullet [as 別名]
# 或者: from pybullet import connect [as 別名]
def test(args):	
	p.connect(p.GUI)
	p.setAdditionalSearchPath(pybullet_data.getDataPath())
	fileName = os.path.join("mjcf", args.mjcf)
	print("fileName")
	print(fileName)
	p.loadMJCF(fileName)
	while (1):
		p.stepSimulation()
		p.getCameraImage(320,240)
		time.sleep(0.01) 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:13,代碼來源:testMJCF.py


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