机器人持续学习基准LIBERO系列7——计算并可视化点云

0.前置

1.前置代码

2.重新获取真实深度信息

  • 之前的由于要显示,进行了整数化处理,所以重新获取一下原始真实深度信息
python 复制代码
from robosuite.utils.camera_utils import get_real_depth_map
agentview_depth_real = get_real_depth_map(env.sim, agentview_depth)

3.获取图像尺寸

python 复制代码
h,w = env_args['camera_heights'],  env_args['camera_widths']

4.创建像素点序列和颜色序列

python 复制代码
i = np.zeros([h*w,2])#(点数,像素点二维坐标)
colors = np.zeros([h*w,3])#(点数,像素点对应的RGB值)
for x in range(h):
    for y in range(w):
        i[x*h+y] = [x,y]
        colors[x*h+y] = agentview_image[x,y]

5.获取相机内外参

python 复制代码
from robosuite.utils.camera_utils import get_camera_extrinsic_matrix,get_camera_intrinsic_matrix

camera_intrinsic_matrix_ = np.linalg.inv(get_camera_intrinsic_matrix(env.sim,'agentview', env_args['camera_heights'],  env_args['camera_widths']))
camera_extrinsic_matrix_ = np.linalg.inv(get_camera_extrinsic_matrix(env.sim,'agentview'))

6.计算世界坐标系下三维点坐标

python 复制代码
points = np.zeros([i.shape[0],3])
for num,p in enumerate(i):
    p_ = (camera_intrinsic_matrix_@np.array([[p[0],p[1],1]]).T).T
    p_[0,2] = agentview_depth_real[int(p[0]),int(p[1])]
    p_ = (camera_extrinsic_matrix_@np.array([p_[0,0],p_[0,1],p_[0,2],1]).T).T
    points[num] = p_[:-1]
print(points)

7.关闭环境

python 复制代码
env.close()
  • 不关闭环境,就是用open3d显示的话,会报错
bash 复制代码
X Error of failed request:  BadAccess (attempt to access private resource denied)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  5 (X_GLXMakeCurrent)
  Serial number of failed request:  183
  Current serial number in output stream:  183

8.open3d显示点云

python 复制代码
import open3d as o3d
pcd_show = o3d.geometry.PointCloud()
pcd_show.points = o3d.utility.Vector3dVector(points[:, :3])
pcd_show.colors = o3d.utility.Vector3dVector(colors[:]/255)
o3d.visualization.draw_geometries([pcd_show])


相关推荐
深念Y7 小时前
飞书桥接 Claude Code / Codex 踩坑实录:从部署、魔改到重装
机器人·飞书·远程·codex·工作·claudecode
八月瓜科技9 小时前
豆包启动付费会员测试,承诺基础服务永久免费,免费AI时代是否终结?
数据库·人工智能·科技·深度学习·机器人
地平线开发者1 天前
挑战杯“揭榜挂帅”|机器人领域·地平线赛题发布!共探智慧环卫清扫车新未来
人工智能·机器人
2601_957964871 天前
48V系统轻型巡检机器人锂电池完整设计方案要求(工业级智能巡检平台标准)【浩博电池】
人工智能·机器人
jerryinwuhan1 天前
人工智能工程技术(智能机器人应用)基于赛教融合的项目递进式课程体系
人工智能·机器人
hoiii1871 天前
基于STM32的扫地机器人源码工程
stm32·单片机·机器人
2zcode1 天前
基于MATLAB的家用场景下扫地机器人路径规划研究设计
开发语言·matlab·机器人
weixin_417197051 天前
王府井来了个新店员:穿机械骨骼,不会请假,还会表演节目
人工智能·机器人
AI进化营-智能译站2 天前
ROS2 C++开发系列17-多线程驱动多传感器|chrono高精度计时实现机器人同步控制
java·c++·ai·机器人
2601_957964872 天前
375V锂电池完整设计方案要求(工业级高压动力系统解决方案)【浩博电池】
机器人