当前位置: 首页>>代码示例>>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;未经允许,请勿转载。