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 Rendering: uncheck(不选) 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.