当前位置: 首页>>代码示例>>Python>>正文


Python pybullet.connect函数代码示例

本文整理汇总了Python中pybullet.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self,
              urdfRoot=pybullet_data.getDataPath(),
              actionRepeat=1,
              isEnableSelfCollision=True,
              renders=True):
   print("init")
   self._timeStep = 1./240.
   self._urdfRoot = urdfRoot
   self._actionRepeat = actionRepeat
   self._isEnableSelfCollision = isEnableSelfCollision
   self._observation = []
   self._envStepCounter = 0
   self._renders = renders
   self._width = 341
   self._height = 256
   self.terminated = 0
   self._p = p
   if self._renders:
     cid = p.connect(p.SHARED_MEMORY)
     if (cid<0):
        p.connect(p.GUI)
     p.resetDebugVisualizerCamera(1.3,180,-41,[0.52,-0.2,-0.33])
   else:
     p.connect(p.DIRECT)
   #timinglog = p.startStateLogging(p.STATE_LOGGING_PROFILE_TIMINGS, "kukaTimings.json")
   self._seed()
   self.reset()
   observationDim = len(self.getExtendedObservation())
   #print("observationDim")
   #print(observationDim)
   
   observation_high = np.array([np.finfo(np.float32).max] * observationDim)    
   self.action_space = spaces.Discrete(7)
   self.observation_space = spaces.Box(low=0, high=255, shape=(self._height, self._width, 4))
   self.viewer = None
开发者ID:bingjeff,项目名称:bullet3,代码行数:35,代码来源:kukaCamGymEnv.py

示例2: __init__

 def __init__(self,
              urdfRoot=pybullet_data.getDataPath(),
              actionRepeat=50,
              isEnableSelfCollision=True,
              renders=True):
   print("init")
   self._timeStep = 0.01
   self._urdfRoot = urdfRoot
   self._actionRepeat = actionRepeat
   self._isEnableSelfCollision = isEnableSelfCollision
   self._observation = []
   self._envStepCounter = 0
   self._renders = renders
   self._p = p
   if self._renders:
     p.connect(p.GUI)
   else:
     p.connect(p.DIRECT)
   self._seed()
   self.reset()
   observationDim = len(self.getExtendedObservation())
   #print("observationDim")
   #print(observationDim)
   
   observation_high = np.array([np.finfo(np.float32).max] * observationDim)    
   self.action_space = spaces.Discrete(9)
   self.observation_space = spaces.Box(-observation_high, observation_high)
   self.viewer = None
开发者ID:Valentactive,项目名称:bullet3,代码行数:28,代码来源:simpleHumanoidGymEnv.py

示例3: __init__

 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:bulletphysics,项目名称:bullet3,代码行数:7,代码来源:bullet_client.py

示例4: _reset

	def _reset(self):
		if (self.physicsClientId<0):
			conInfo = p.getConnectionInfo()
			if (conInfo['isConnected']):
				self.ownsPhysicsClient = False
				
				self.physicsClientId = 0
			else:
				self.ownsPhysicsClient = True
				self.physicsClientId = p.connect(p.SHARED_MEMORY)
				if (self.physicsClientId<0):
					if (self.isRender):
						self.physicsClientId = p.connect(p.GUI)
					else:
						self.physicsClientId = p.connect(p.DIRECT)
				p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)

		if self.scene is None:
			self.scene = self.create_single_player_scene()
		if not self.scene.multiplayer and self.ownsPhysicsClient:
			self.scene.episode_restart()

		self.robot.scene = self.scene

		self.frame = 0
		self.done = 0
		self.reward = 0
		dump = 0
		s = self.robot.reset()
		self.potential = self.robot.calc_potential()
		return s
开发者ID:antarespilot,项目名称:bullet3,代码行数:31,代码来源:env_bases.py

示例5: __init__

	def __init__(self):
		# initialize random seed
		np.random.seed(int(time.time()))

		cid = p.connect(p.SHARED_MEMORY) # only show graphics if the browser is already running....
		self.visualize = (cid >= 0)
		if cid < 0:
			cid = p.connect(p.DIRECT)  # If no shared memory browser is active, we switch to headless mode (DIRECT is much faster)
开发者ID:AndrewMeadows,项目名称:bullet3,代码行数:8,代码来源:Trainer.py

示例6: test

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:AndrewMeadows,项目名称:bullet3,代码行数:11,代码来源:testMJCF.py

示例7: main

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:AndrewMeadows,项目名称:bullet3,代码行数:13,代码来源:minitaur_test.py

示例8: __init__

  def __init__(self,
               urdfRoot=pybullet_data.getDataPath(),
               actionRepeat=1,
               isEnableSelfCollision=True,
               renders=False,
               isDiscrete=False,
               maxSteps = 1000):
    #print("KukaGymEnv __init__")
    self._isDiscrete = isDiscrete
    self._timeStep = 1./240.
    self._urdfRoot = urdfRoot
    self._actionRepeat = actionRepeat
    self._isEnableSelfCollision = isEnableSelfCollision
    self._observation = []
    self._envStepCounter = 0
    self._renders = renders
    self._maxSteps = maxSteps
    self.terminated = 0
    self._cam_dist = 1.3
    self._cam_yaw = 180
    self._cam_pitch = -40

    self._p = p
    if self._renders:
      cid = p.connect(p.SHARED_MEMORY)
      if (cid<0):
         cid = p.connect(p.GUI)
      p.resetDebugVisualizerCamera(1.3,180,-41,[0.52,-0.2,-0.33])
    else:
      p.connect(p.DIRECT)
    #timinglog = p.startStateLogging(p.STATE_LOGGING_PROFILE_TIMINGS, "kukaTimings.json")
    self.seed()
    self.reset()
    observationDim = len(self.getExtendedObservation())
    #print("observationDim")
    #print(observationDim)

    observation_high = np.array([largeValObservation] * observationDim)
    if (self._isDiscrete):
      self.action_space = spaces.Discrete(7)
    else:
       action_dim = 3
       self._action_bound = 1
       action_high = np.array([self._action_bound] * action_dim)
       self.action_space = spaces.Box(-action_high, action_high)
    self.observation_space = spaces.Box(-observation_high, observation_high)
    self.viewer = None
开发者ID:jiapei100,项目名称:bullet3,代码行数:47,代码来源:kukaGymEnv.py

示例9: testJacobian

  def testJacobian(self):
    import pybullet as p

    clid = p.connect(p.SHARED_MEMORY)
    if (clid < 0):
      p.connect(p.DIRECT)

    time_step = 0.001
    gravity_constant = -9.81

    urdfs = [
        "TwoJointRobot_w_fixedJoints.urdf", "TwoJointRobot_w_fixedJoints.urdf",
        "kuka_iiwa/model.urdf", "kuka_lwr/kuka.urdf"
    ]
    for urdf in urdfs:
      p.resetSimulation()
      p.setTimeStep(time_step)
      p.setGravity(0.0, 0.0, gravity_constant)

      robotId = p.loadURDF(urdf, useFixedBase=True)
      p.resetBasePositionAndOrientation(robotId, [0, 0, 0], [0, 0, 0, 1])
      numJoints = p.getNumJoints(robotId)
      endEffectorIndex = numJoints - 1

      # Set a joint target for the position control and step the sim.
      self.setJointPosition(robotId, [0.1 * (i % 3) for i in range(numJoints)])
      p.stepSimulation()

      # Get the joint and link state directly from Bullet.
      mpos, mvel, mtorq = self.getMotorJointStates(robotId)

      result = p.getLinkState(robotId,
                              endEffectorIndex,
                              computeLinkVelocity=1,
                              computeForwardKinematics=1)
      link_trn, link_rot, com_trn, com_rot, frame_pos, frame_rot, link_vt, link_vr = result
      # Get the Jacobians for the CoM of the end-effector link.
      # Note that in this example com_rot = identity, and we would need to use com_rot.T * com_trn.
      # The localPosition is always defined in terms of the link frame coordinates.

      zero_vec = [0.0] * len(mpos)
      jac_t, jac_r = p.calculateJacobian(robotId, endEffectorIndex, com_trn, mpos, zero_vec,
                                         zero_vec)

      assert (allclose(dot(jac_t, mvel), link_vt))
      assert (allclose(dot(jac_r, mvel), link_vr))
    p.disconnect()
开发者ID:bulletphysics,项目名称:bullet3,代码行数:47,代码来源:unittests.py

示例10: __init__

  def __init__(
      self,
      renderer='tiny',  # ('tiny', 'egl', 'debug')
  ):
    self.action_space = spaces.Discrete(2)
    self.iter = cycle(range(0, 360, 10))

    # how we want to show
    assert renderer in ('tiny', 'egl', 'debug', 'plugin')
    self._renderer = renderer
    self._render_width = 84
    self._render_height = 84
    # connecting
    if self._renderer == "tiny" or self._renderer == "plugin":
      optionstring = '--width={} --height={}'.format(self._render_width, self._render_height)
      p.connect(p.DIRECT, options=optionstring)

      if self._renderer == "plugin":
        plugin_fn = os.path.join(
            p.__file__.split("bullet3")[0],
            "bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so")
        plugin = p.loadPlugin(plugin_fn, "_tinyRendererPlugin")
        if plugin < 0:
          print("\nPlugin Failed to load! Try installing via `pip install -e .`\n")
          sys.exit()
        print("plugin =", plugin)

    elif self._renderer == "egl":
      optionstring = '--width={} --height={}'.format(self._render_width, self._render_height)
      optionstring += ' --window_backend=2 --render_device=0'
      p.connect(p.GUI, options=optionstring)

    elif self._renderer == "debug":
      #print("Connection: SHARED_MEMORY")
      #cid = p.connect(p.SHARED_MEMORY)
      #if (cid<0):
      cid = p.connect(p.GUI)
      p.resetDebugVisualizerCamera(1.3, 180, -41, [0.52, -0.2, -0.33])

    p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
    p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW, 0)
    p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW, 0)
    p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW, 0)
开发者ID:bulletphysics,项目名称:bullet3,代码行数:43,代码来源:rendertest_sync.py

示例11: test_rolling_friction

 def test_rolling_friction(self):
   import pybullet as p
   p.connect(p.DIRECT)
   p.loadURDF("plane.urdf")
   sphere = p.loadURDF("sphere2.urdf", [0, 0, 1])
   p.resetBaseVelocity(sphere, linearVelocity=[1, 0, 0])
   p.changeDynamics(sphere, -1, linearDamping=0, angularDamping=0)
   #p.changeDynamics(sphere,-1,rollingFriction=0)
   p.setGravity(0, 0, -10)
   for i in range(1000):
     p.stepSimulation()
   vel = p.getBaseVelocity(sphere)
   self.assertLess(vel[0][0], 1e-10)
   self.assertLess(vel[0][1], 1e-10)
   self.assertLess(vel[0][2], 1e-10)
   self.assertLess(vel[1][0], 1e-10)
   self.assertLess(vel[1][1], 1e-10)
   self.assertLess(vel[1][2], 1e-10)
   p.disconnect()
开发者ID:bulletphysics,项目名称:bullet3,代码行数:19,代码来源:unittests.py

示例12: __init__

  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:AndrewMeadows,项目名称:bullet3,代码行数:20,代码来源:bullet_client.py

示例13: __init__

  def __init__(self):
    # start the bullet physics server
    p.connect(p.GUI)
#    p.connect(p.DIRECT)
    observation_high = np.array([
          np.finfo(np.float32).max,
          np.finfo(np.float32).max,
          np.finfo(np.float32).max,
          np.finfo(np.float32).max])
    action_high = np.array([0.1])

    self.action_space = spaces.Box(-action_high, action_high)
    self.observation_space = spaces.Box(-observation_high, observation_high)

    self.theta_threshold_radians = 1
    self.x_threshold = 2.4
    self._seed()
#    self.reset()
    self.viewer = None
    self._configure()
开发者ID:mrcrr8614,项目名称:bullet3,代码行数:20,代码来源:cartpole_bullet.py

示例14: __init__

  def __init__(self, renders=True):
    # start the bullet physics server
    self._renders = renders
    if (renders):
	    p.connect(p.GUI)
    else:
    	p.connect(p.DIRECT)
    self.theta_threshold_radians = 12 * 2 * math.pi / 360 
    self.x_threshold = 0.4 #2.4   
    high = np.array([
         self.x_threshold * 2,
         np.finfo(np.float32).max,
         self.theta_threshold_radians * 2,
         np.finfo(np.float32).max])

    self.force_mag = 10

    self.action_space = spaces.Discrete(2)
    self.observation_space = spaces.Box(-high, high, dtype=np.float32)

    self._seed()
    #    self.reset()
    self.viewer = None
    self._configure()
开发者ID:simo-11,项目名称:bullet3,代码行数:24,代码来源:cartpole_bullet.py

示例15: __init__

  def __init__(self, renders=True):
    # start the bullet physics server
    self._renders = renders
    if (renders):
	    p.connect(p.GUI)
    else:
    	p.connect(p.DIRECT)

    observation_high = np.array([
          np.finfo(np.float32).max,
          np.finfo(np.float32).max,
          np.finfo(np.float32).max,
          np.finfo(np.float32).max])
    action_high = np.array([0.1])

    self.action_space = spaces.Discrete(9)
    self.observation_space = spaces.Box(-observation_high, observation_high)

    self.theta_threshold_radians = 1
    self.x_threshold = 2.4
    self._seed()
#    self.reset()
    self.viewer = None
    self._configure()
开发者ID:Valentactive,项目名称:bullet3,代码行数:24,代码来源:cartpole_bullet.py


注:本文中的pybullet.connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。