Rviz教程(十一):Rviz in Stereo

本文档详述了如何配置RViz以实现三维立体渲染,包括硬件需求、使用NVIDIA和AMD硬件的方法、X服务器设置步骤及故障排除技巧。同时介绍了如何从源代码构建支持立体视觉的RViz和Ogre。

Rviz in Stereo

Description:  Teaches how to set up Rviz to  render (致使)  in 3D Stereo.

Tutorial Level:  INTERMEDIATE 

Intro

3D stereo(立体声) rendering(翻译) displays a different view to each eye so that the scene appears to have depth. If you have a stereo capable(能干的) monitor and stereo capable graphics(图形) card you can get Rviz to render(致使) its view in stereo. This tutorial(个别指导) describes how to accomplish(完成) this.

Hardware Requirements

To render in stereo you will need a graphics card capable of Quad-buffer stereo. You may also need a stereo-capable monitor and/or a monitor that can display at 120Hz.

Using NVIDIA hardware

On Linux NVIDIA Quadro cards support quad(四方院子) buffered(缓冲) stereo. There is information about which cards support this feature(特色) here on the NVIDIA website.

Also see http://www.zib.de/durmaz/3dVision.html or try a web search for other info on "quad buffer(有软皮摩擦) stereo linux".

There seem to be 2 options for displays:

Special 3D Monitor

Get a special monitor that comes with 3DVision glasses and has a built in 3DVision IR transmitter(发射机). I have stereo working on an ASUS VG278H monitor with an NVIDIA Quadro K4000 graphics adaptor(适配器). You will need to connect the display directly to the graphics card with a DVI Dual-link cable(电缆). (Single link DVI will not work. Display-port to DVI will not work. HDMI will not work at 120Hz.) The monitor comes with active 3DVision glasses and has a built in IR transmitter, so you do not need a separate IR transmitter and you do not need a "3 pin mini-din" connector(连接器) on your graphics card.

3DVision glasses

Get 3DVision kit with active glasses and an IR transmitter (or 3DVision-Pro glasses with a radio transmitter). You will also need a monitor with a refresh(更新) rate of at least 100Hz (120Hz is better).

On Linux you need to connect the IR (or radio) transmitter directly to the graphics card. Transmitters that plug into USB do not work on Linux (they may work on Mac but I have not tried). To connect directly to the graphics card use the '3-pin mini-din to 1/8" stereo cable' that comes with the 3DVision kit.

Many NVIDIA cards that support stereo DO NOT come with a '3-pin mini-din' connector on them. If you do not see a round 3-pin 'mini-din' connector on the back of your graphics card (next to the DVI/VGA/etc connectors) then you need to buy a separate "NVIDIA Quadro Stereo Board Connector". PNY sells one: Search for part number "QSP-STRBOARD-PB"This will only work with Quadro cards that support quad buffer stereo. Check the NVIDIA website for your card to be sure your card will work before buying the board connector(连接器).

On linux you can tell what kind of graphics(图形) card you have by running

   lspci | grep VGA

If it does not say "Quadro" then it probably does not support stereo(立体声).

You will need to connect the display directly to the graphics card with a DVI Dual-link cable(电缆). (Single link DVI will not work. Display-port to DVI will not work. HDMI works at 60Hz which is too slow and you will quickly get a headache.)

Using AMD hardware

I believe some high end AMD graphics cards support quad-buffer stereo, but I do not know which ones. If you have information on this please add it here.

Setting up X (in Linux) to support stereo

NVIDIA

Install binary drivers

Be sure you are using the NVIDIA binary(二进制的) drivers. Run

  sudo apt-get install nvidia-settings
  nvidia-settings

If you are using the NVIDIA binary drivers this will work -- go on to the next step. If not the program will inform(通知) you that you are not using the NVIDIA binary drivers.

Search the web for Install NVIDIA drivers

Set resolution(分辨率)refresh(更新) rate, and stereo mode

Run

  nvidia-settings

Click on "X Server Display Configuration". If you have multiple monitors choose the one you want to setup(设置) for stereo. Select the Resolution (do not choose "Auto"). Select the refresh rate (to the right of "Resolution"). You want a refresh rate at least 100Hz (120Hz or faster is better). Click "Apply".

Assuming(承担) everything works you need to save these settings. Click the button "Save to X Configuration File" and follow the prompts(提示) to save the file as /tmp/xorg.conf

Now you have to add the stereo setting. Open a terminal and run these commands:

  cd /tmp
  nvidia-xconfig -c xorg.conf -o xorg.conf --stereo=10

Note: "10" means "NVIDIA 3D VISION". If you have "NVIDIA 3D VISION PRO" use 11. For other settings run man nvidia-xconfig and search for stereo(立体声).

  sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original-no-stereo
  cp xorg.conf /etc/X11/xorg.conf

Now restart(重新启动) X by logging out and logging back in.

To verify(核实) that stereo is enabled run

   nvidia-settings

Click on "X Screen 0" and look at the "Stereo Mode" setting. It should say "NVIDIA 3D Vision Stereo"

Known-working Stereo Hardware(计算机硬件)

Please add to this section if you have stereo working on your system.

* WORKS: NVIDIA Quadro K4000, ASUS VG278H monitor (comes with 3DVision glasses), DVI dual-link cable(电缆). IR transmitter(发射机) is built into the monitor.

Testing stereo hardware

To verify that your stereo hardware is working run

   sudo apt-get install mesa-utils
   glxgears -stereo

If you have multiple monitors, drag the gears(齿轮) window to the monitor with stereo support. You should see a double image. Put on your 3D Glasses. You should see the image in stereo. To see it better resize(调整大小) the window (make it bigger) and use the arrow keys to rotate(旋转) the gears around. If it looks funny try running

   nvidia-settings

click on "OpenGL Settings" and check the "Exchange Stereo Eyes" button.

troubleshooting

I have found that once the computer goes to sleep or if the monitor is turned off that the monitor stops transmitting the stereo signal to the glasses after the computer wakes up and the monitor is turned on. If you cannot get stereo to work try this: Shut down the computer. Leave the monitor turned on. Power on the computer. Now it should work (at least until the computer goes to sleep again).

Building Rviz to render(致使) in stereo

Ogre (the graphics(图形) library that Rviz uses) does not currently support stereo rendering(致使) by default. To enable stereo rendering you will have to build Rviz and a custom version of Ogre from source.

Do not bother with this until you have confirmed(确认) that your graphics card and monitor work in stereo (see Testing stereo hardware). Rviz will not render in stereo if glxgears -stereo does not render(致使) in stereo(立体声).

Building Ogre for Stereo

Get the sources, build and install(安装)Rviz only works with versions of Ogre older than 1.8, so checkout(检验) that tag.

    cd $HOME
    mkdir my-ogre
    cd my-ogre
    hg clone https://bitbucket.org/sinbad/ogre
    cd ogre
    hg pull && hg update v1-8
    cd ..
    mkdir build
    cd build
    cmake -DOGRE_FULL_RPATH=ON -DOGRE_CONFIG_ENABLE_QUAD_BUFFER_STEREO=ON -DCMAKE_INSTALL_PREFIX:PATH="/usr/local" -DFREETYPE_INCLUDE_DIR:PATH="/usr/include/freetype2" -DFREETYPE_FT2BUILD_INCLUDE_DIR:PATH="/usr/include/freetype2" ../ogre
    make install

Note: This installs Ogre into /usr/local.

Building Rviz for Stereo

First create a workspace to build Rviz. (If you already have a workspace you can use the existing one instead of creating a new "my-rviz-workspace" workspace.)

    cd $HOME
    mkdir -p my-rviz-workspace/src
    cd my-rviz-workspace/src
    git clone https://github.com/ros-visualization/rviz.git
    cd ..
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} catkin_make --cmake-args -DCMAKE_SHARED_LINKER_FLAGS:STRING=" -Wl,-rpath,/usr/local/lib" -DCMAKE_CXX_FLAGS:STRING="-DOGRE_STEREO_ENABLE=1" -DUseQt5:BOOL="0"

Run your new rviz compiled(编译) binary(二进制的) manually(手动地):

    roscore & ./devel/lib/rviz/rviz

If your hardware(计算机硬件) doesn't support quad(四方院子) buffer(有软皮摩擦) stereo rviz might segfault at this point.

Add a display (e.g. an Axis Display) so there is something to look at.

If your HW supports stereo you should see a double image. Put on the glasses to see it in stereo.

Adjusting(调整) stereo properties in Rviz

Properties in the "View Controller" panel(仪表板) can be used to set eye-separation, focal-distance, to swap(与…交换) the eyes, and disable stereo.

If you do not see the "Views" panel (by default in upper right) then click the "Panels" menu item and check "Views".

In the "Current View" you will see some properties that can be used to adjust the stereo rendering(翻译):

  • Enable Stereo Renderinguncheck(不选) this to turn off stereo.

  • Swap Stereo Eyes: check this if Rviz has gotten(得到) confused(混乱) and has swapped the left and right eyes.

  • Stereo Eye Separation: Use larger values for greater stereo(立体声) effect. Ideally(理想的) this is the distance between your eyes (in meters).

  • Stereo Focal Distance: Set this to the distance between your eyes and the monitor. Smaller values tend(照料) to produce a greater stereo effect.

QSocketNotifier: Can only be used with threads started with QThread [INFO] [1755765167.802211513] [rviz2]: Stereo is NOT SUPPORTED [INFO] [1755765167.802902738] [rviz2]: OpenGl version: 4.5 (GLSL 4.5) [ERROR] [1755765167.830033330] [rviz2]: RenderingAPIException: Invalid parentWindowHandle (wrong server or screen) in GLXWindow::create at ./.obj-x86_64-linux-gnu/ogre-v1.12.1-prefix/src/ogre-v1.12.1/RenderSystems/GLSupport/src/GLX/OgreGLXWindow.cpp (line 257) [ERROR] [1755765167.830161288] [rviz2]: rviz::RenderSystem: error creating render window: RenderingAPIException: Invalid parentWindowHandle (wrong server or screen) in GLXWindow::create at ./.obj-x86_64-linux-gnu/ogre-v1.12.1-prefix/src/ogre-v1.12.1/RenderSystems/GLSupport/src/GLX/OgreGLXWindow.cpp (line 257)[ERROR] [1755768313.907220214] [rviz2]: RenderingAPIException: Invalid parentWindowHandle (wrong server or screen) in GLXWindow::create at ./.obj-x86_64-linux-gnu/ogre-v1.12.1-prefix/src/ogre-v1.12.1/RenderSystems/GLSupport/src/GLX/OgreGLXWindow.cpp (line 257) [ERROR] [1755768313.907271832] [rviz2]: rviz::RenderSystem: error creating render window: RenderingAPIException: Invalid parentWindowHandle (wrong server or screen) in GLXWindow::create at ./.obj-x86_64-linux-gnu/ogre-v1.12.1-prefix/src/ogre-v1.12.1/RenderSystems/GLSupport/src/GLX/OgreGLXWindow.cpp (line 257) [ERROR] [1755768313.907283450] [rviz2]: Unable to create the rendering window after 100 tries terminate called after throwing an instance of 'std::runtime_error' what(): Unable to create the rendering window after 100 tries 已中止 (核心已转储)
最新发布
08-22
### SLAM建图原理 SLAM(Simultaneous Localization and Mapping),即同步定位与地图构建技术,是一种让移动机器人在未知环境中通过传感器数据实现自主导航的核心算法。其基本目标是在探索过程中实时估计自身的位姿,并同时创建环境的地图。 #### 原理概述 1. **传感器数据采集** SLAM通常依赖于激光雷达、摄像头或其他类型的传感器来获取周围环境的信息。对于激光建图而言,主要依靠Lidar设备提供精确的距离测量数据[^1]。 2. **状态估计** 使用扩展卡尔曼滤波器(EKF)、粒子滤波(PF)或者优化方法解决机器人的位置不确定性问题。这些算法能够融合来自不同源的时间序列观测值以提高精度。 3. **特征提取与匹配** 对于基于视觉的SLAM系统(V-SLAM),会从图像帧中检测关键点并跟踪它们;而对于激光SLAM,则可能涉及扫描线段配准或栅格单元比较等操作。Hector SLAM仅需利用激光测距仪的数据就能完成高质量的地图绘制过程。 4. **闭环检测(Closure Detection)** 当重新访问之前已经映射过的区域时,识别这种重叠有助于减少累积误差并增强全局一致性。 --- ### RViz中的SLAM建图实验工作方式 RViz是一个强大的可视化工具,在ROS框架下被广泛应用于调试和展示各种感知模块的结果,包括但不限于路径规划、避障策略以及最重要的——SLAM生成的地图。 #### 实验设置与执行流程 - **启动Gazebo模拟环境** 用户可以通过命令`roslaunch demo4_urdf_gazebo car_move.launch`加载包含虚拟场景的世界文件,其中包括一辆可控制的小车及其运动学模型定义[^3]。 - **运行SLAM Launch脚本** 接下来调用特定配置好的launch文件(`nav4_slam_auto.launch`),它内部集成了多个子组件的功能描述,比如开启实际负责处理原始传感信号转换成二维占据网格形式的服务端程序实例化指令片段: ```xml <!-- 启动SLAM节点 --> <include file="$(find demo5_navigation)/launch/nav1_slam.launch" /> ``` - **显示界面调整** 最终打开Rviz应用窗口后,按照个人需求定制好各层参数选项卡布局样式再保存当前设定以便后续重复利用方便快捷[^2]: ```bash rviz -d $(find demo5_navigation)/config/rviz/nav1.rviz ``` 在此期间,随着小车载具不断改变方位角度前进轨迹变化积累更多样本点云集合体投射至屏幕平面形成直观图形表现效果出来供研究分析人员观察评估性能指标优劣程度如何满足预期标准范围之内。 --- ### 示例代码:简易SLAM启动脚本 以下是简化版的一个用于触发整个链条动作序列组合而成的整体结构概览: ```xml <launch> <!-- 加载仿真环境 --> <include file="$(find demo4_urdf_gazebo)/launch/car_move.launch"/> <!-- 初始化SLAM服务 --> <include file="$(find demo5_navigation)/launch/nav1_slam.launch"/> <!-- 设置导航相关yaml配置 --> <include file="$(find demo5_navigation)/launch/nav3_set_yaml.launch"/> <!-- 展示结果 --> <node pkg="rviz" type="rviz" name="rviz" output="screen"> <param name="display_config" value="$(find demo5_navigation)/config/rviz/nav1.rviz"/> </node> </launch> ``` 此XML文档片断清晰地展示了各个独立部分之间相互协作关系链路走向逻辑顺序安排合理紧凑高效实用性强易于维护升级改进空间广阔前景光明未来值得期待! ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值