• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pybullet.connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

def main(unused_args):
  timeStep = 0.01
  c = p.connect(p.SHARED_MEMORY)
  if (c<0):
      c = p.connect(p.GUI)
  p.resetSimulation()
  p.setTimeStep(timeStep)
  p.loadURDF("plane.urdf")
  p.setGravity(0,0,-10)

  minitaur = Minitaur()
  amplitude = 0.24795664427
  speed = 0.2860877729434
  for i in range(1000):
    a1 = math.sin(i*speed)*amplitude+1.57
    a2 = math.sin(i*speed+3.14)*amplitude+1.57
    joint_values = [a1, -1.57, a1, -1.57, a2, -1.57, a2, -1.57]
    minitaur.applyAction(joint_values)

    p.stepSimulation()
#    print(minitaur.getBasePosition())
    time.sleep(timeStep)
  final_distance = np.linalg.norm(np.asarray(minitaur.getBasePosition()))
  print(final_distance)
开发者ID:MixerMovies,项目名称:RedShadow,代码行数:24,代码来源:minitaur_test.py


示例17: __enter__

    def __enter__(self):
        print("connecting")
        optionstring='--width={} --height={}'.format(pixelWidth,pixelHeight)
        optionstring += ' --window_backend=2 --render_device=0'

        print(self.connection_mode, optionstring,*self.argv)
        cid = pybullet.connect(self.connection_mode, options=optionstring,*self.argv)
        if cid < 0:
            raise ValueError
        print("connected")
        pybullet.configureDebugVisualizer(pybullet.COV_ENABLE_GUI,0)
        pybullet.configureDebugVisualizer(pybullet.COV_ENABLE_SEGMENTATION_MARK_PREVIEW,0)
        pybullet.configureDebugVisualizer(pybullet.COV_ENABLE_DEPTH_BUFFER_PREVIEW,0)
        pybullet.configureDebugVisualizer(pybullet.COV_ENABLE_RGB_BUFFER_PREVIEW,0)

        pybullet.resetSimulation()
        pybullet.loadURDF("plane.urdf",[0,0,-1])
        pybullet.loadURDF("r2d2.urdf")
        pybullet.loadURDF("duck_vhacd.urdf")
        pybullet.setGravity(0,0,-10)
开发者ID:jiapei100,项目名称:bullet3,代码行数:20,代码来源:rendertest.py


示例18: drawAABB

import pybullet as p
draw = 1
printtext = 0

if (draw):
  p.connect(p.GUI)
else:
  p.connect(p.DIRECT)
r2d2 = p.loadURDF("r2d2.urdf")


def drawAABB(aabb):
  f = [aabbMin[0], aabbMin[1], aabbMin[2]]
  t = [aabbMax[0], aabbMin[1], aabbMin[2]]
  p.addUserDebugLine(f, t, [1, 0, 0])
  f = [aabbMin[0], aabbMin[1], aabbMin[2]]
  t = [aabbMin[0], aabbMax[1], aabbMin[2]]
  p.addUserDebugLine(f, t, [0, 1, 0])
  f = [aabbMin[0], aabbMin[1], aabbMin[2]]
  t = [aabbMin[0], aabbMin[1], aabbMax[2]]
  p.addUserDebugLine(f, t, [0, 0, 1])

  f = [aabbMin[0], aabbMin[1], aabbMax[2]]
  t = [aabbMin[0], aabbMax[1], aabbMax[2]]
  p.addUserDebugLine(f, t, [1, 1, 1])

  f = [aabbMin[0], aabbMin[1], aabbMax[2]]
  t = [aabbMax[0], aabbMin[1], aabbMax[2]]
  p.addUserDebugLine(f, t, [1, 1, 1])

  f = [aabbMax[0], aabbMin[1], aabbMin[2]]
开发者ID:bulletphysics,项目名称:bullet3,代码行数:31,代码来源:getAABB.py


示例19: range

import pybullet as p
p.connect(p.GUI)
cube = p.loadURDF("cube.urdf")
frequency = 240
timeStep = 1. / frequency
p.setGravity(0, 0, -9.8)
p.changeDynamics(cube, -1, linearDamping=0, angularDamping=0)
p.setPhysicsEngineParameter(fixedTimeStep=timeStep)
for i in range(frequency):
  p.stepSimulation()
pos, orn = p.getBasePositionAndOrientation(cube)
print(pos)
开发者ID:bulletphysics,项目名称:bullet3,代码行数:12,代码来源:integrate.py


示例20: range

import pybullet as p
import time
#p.connect(p.UDP,"192.168.86.100")


cid = p.connect(p.SHARED_MEMORY)
if (cid<0):
	p.connect(p.GUI)
p.resetSimulation()
#disable rendering during loading makes it much faster
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
objects = [p.loadURDF("plane.urdf", 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000)]
objects = [p.loadURDF("samurai.urdf", 0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,1.000000)]
objects = [p.loadURDF("pr2_gripper.urdf", 0.500000,0.300006,0.700000,-0.000000,-0.000000,-0.000031,1.000000)]
pr2_gripper = objects[0]
print ("pr2_gripper=")
print (pr2_gripper)

jointPositions=[ 0.550569, 0.000000, 0.549657, 0.000000 ]
for jointIndex in range (p.getNumJoints(pr2_gripper)):
	p.resetJointState(pr2_gripper,jointIndex,jointPositions[jointIndex])

pr2_cid = p.createConstraint(pr2_gripper,-1,-1,-1,p.JOINT_FIXED,[0,0,0],[0.2,0,0],[0.500000,0.300006,0.700000])
print ("pr2_cid")
print (pr2_cid)

objects = [p.loadURDF("kuka_iiwa/model_vr_limits.urdf", 1.400000,-0.200000,0.600000,0.000000,0.000000,0.000000,1.000000)]
kuka = objects[0]
jointPositions=[ -0.000000, -0.000000, 0.000000, 1.570793, 0.000000, -1.036725, 0.000001 ]
for jointIndex in range (p.getNumJoints(kuka)):
	p.resetJointState(kuka,jointIndex,jointPositions[jointIndex])
开发者ID:Valentactive,项目名称:bullet3,代码行数:31,代码来源:vr_kuka_setup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pybullet.getCameraImage函数代码示例发布时间:2022-05-25
下一篇:
Python utils.Timer类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap