python ray定时_Python pybullet.rayTestBatch方法代码示例

# 需要导入模块: import pybullet [as 别名]

# 或者: from pybullet import rayTestBatch [as 别名]

def _laserScan(self):

"""

INTERNAL METHOD, a loop that simulate the laser and update the distance

value of each laser

"""

lastLidarTime = time.time()

while not self._module_termination:

nowLidarTime = time.time()

if (nowLidarTime-lastLidarTime > 1/LASER_FRAMERATE):

results = pybullet.rayTestBatch(

self.ray_from,

self.ray_to,

parentObjectUniqueId=self.robot_model,

parentLinkIndex=self.laser_id,

physicsClientId=self.physics_client)

for i in range(NUM_RAY*len(ANGLE_LIST_POSITION)):

hitObjectUid = results[i][0]

hitFraction = results[i][2]

hitPosition = results[i][3]

self.laser_value[i] = hitFraction * RAY_LENGTH

if self.display:

if not self.ray_ids:

self._createDebugLine()

if (hitFraction == 1.):

pybullet.addUserDebugLine(

self.ray_from[i],

self.ray_to[i],

RAY_MISS_COLOR,

replaceItemUniqueId=self.ray_ids[i],

parentObjectUniqueId=self.robot_model,

parentLinkIndex=self.laser_id,

physicsClientId=self.physics_client)

else: # pragma: no cover

localHitTo = [self.ray_from[i][0]+hitFraction*(

self.ray_to[i][0]-self.ray_from[i][0]),

self.ray_from[i][1]+hitFraction*(

self.ray_to[i][1]-self.ray_from[i][1]),

self.ray_from[i][2]+hitFraction*(

self.ray_to[i][2]-self.ray_from[i][2])]

pybullet.addUserDebugLine(

self.ray_from[i],

localHitTo,

RAY_HIT_COLOR,

replaceItemUniqueId=self.ray_ids[i],

parentObjectUniqueId=self.robot_model,

parentLinkIndex=self.laser_id,

physicsClientId=self.physics_client)

else:

if self.ray_ids:

self._resetDebugLine()

lastLidarTime = nowLidarTime

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值