win10安装pybullet并测试

安装

pip install pybullet

可能出现的问题:
1、microsoft visual c++ 14.0 or greater is required.
解决:访问 http://go.microsoft.com/fwlink/?LinkId=691126,安装下载的文件。

测试

import pybullet as p
from time import sleep

physicsClient = p.connect(p.GUI)

p.setGravity(0, 0, -10)
# planeId = p.loadURDF("plane.urdf")
cubeStartPos = [0, 0, 1]
cubeStartOrientation = p.getQuaternionFromEuler([0, 0, 0])
boxId = p.loadURDF("path_to_urdf", cubeStartPos, cubeStartOrientation)
cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)

useRealTimeSimulation = 0

if (useRealTimeSimulation):
  p.setRealTimeSimulation(1)

while 1:
  if (useRealTimeSimulation):
    p.setGravity(0, 0, -10)
    sleep(0.01)  # Time in seconds.
  else:
    p.stepSimulation()

可能出现的问题:
1、pybullet.error: cannot load urdf file.
解决:path_to_urdf 要写绝对路径。
2、b3Printf: path_to_urdf.urdf:15: cannot find ‘path_to_urdf.obj’ in any directory in urdf path
解决:urdf所在的文件夹内需要包含模型文件,将path_to_urdf.obj放到path_to_urdf.urdf的同目录下即可。

最终的结果:

在这里插入图片描述

参考:https://blog.csdn.net/weixin_41045354/article/details/104534581

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值