ubuntu18.04 ZED2 camera calibration

1. Start the camera

Reference: ZED2 SDK usage and development environment configuration under Ubuntu \

1.1 CUDA download

cuda 10.2 download

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

Modify the ./bashrc file

sudo gedit ./bashrc

add at the end

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64

renew

source ./bashrc

1.2 SDK

When installing the SDK
, please pay attention to the version correspondence between the SDK and cuda, and if the SDK version is old and the ros wrapper is new, an error may be reported when the ros wrapper is compiled.

cd  ~/下载
chmod +x ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
./ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run

Error 1 : Some dependencies are missing and not installed
Solution : Just install the dependencies directly

Error 2 : Python API installation failed
Solution : Confirm whether your default version of python is the python3
confirmation version

update-alternatives --list python  

If an error is reported: update-alternatives: error: no alternatives for python
, then update it. I am a ubuntu18.04 system, python3.6, please pay attention to your own python version

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1  
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2 

list python versions

update-alternatives --list python 

Modify the default version of python

sudo update-alternatives --config python 

insert image description here
If it still fails, then refer to the Python API installation details
to use

sudo wget -qO- https://cdn.jsdelivr.net/gh/OAKChina/depthai-docs-website@develop/source/_static/install_dependencies.sh | bash

Then install the SDK.

Test run zed2.

cd /usr/local/zed/tools
./ZED_Depth_Viewer

I didn't report an error here, but the opened interface was black, and the camera didn't show anything. It was detected by the program that comes with zed, and it only said that my processor could not be detected. After tossing for a while, the problem was not solved, but the zed2 camera was still turned on under ROS. That is, the following method:

cd ~/catkin_ws/src
git clone https://github.com/stereolabs/zed-ros-examples.git
cd ../
rosdep install --from-paths src --ignore-src -r -y
catkin_make -DCMAKE_BUILD_TYPE=Release
source ./devel/setup.bash

run

roslaunch zed_display_rviz display_zed.launch

Now you can see the results under rviz.

1.3 Using ZED under ROS

cd ~/zed_calibra_ws/src
git clone https://github.com/stereolabs/zed-ros-wrapper.git
cd ..
rosdep install --from-paths src --ignore-src -r -y
catkin_make -DCMAKE_BUILD_TYPE=Release
source ./devel/setup.bash

run zed2

roslaunch zed_wrapper zed2.launch

report an error

[ INFO] [1619503452.320965252]: Initializing nodelet with 4 worker threads.
[ERROR] [1619503452.339945481]: Failed to load nodelet [/zed2/zed_node] of type [zed_nodelets/ZEDWrapperNodelet] even after refreshing the cache: Failed to load library /home/willingham/zed_calibra_ws/devel/lib//libZEDNodelets.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libturbojpeg.so.0: cannot open shared object file: No such file or directory)
[ERROR] [1619503452.339982271]: The error before refreshing the cache was: Failed to load library /home/willingham/zed_calibra_ws/devel/lib//libZEDNodelets.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = libturbojpeg.so.0: cannot open shared object file: No such file or directory)

Solution : After checking for a long time, I didn't solve it. When I reinstalled, I found that I ignored the warning in the SDK, which was outrageous. Reinstalled the python api, successfully installed the SDK, and successfully ran zed2.

2. Calibration

install kalibr

Install dependencies

sudo apt-get install python-setuptools python-rosinstall ipython libeigen3-dev libboost-all-dev doxygen libopencv-dev ros-melodic-vision-opencv ros-melodic-image-transport-plugins ros-melodic-cmake-modules software-properties-common libpoco-dev python-matplotlib python-scipy python-git python-pip ipython libtbb-dev libblas-dev liblapack-dev python-catkin-tools libv4l-dev

Three of them are versions that need to be paid attention to. I am the modified melodic, and one is python-software-properties. It is said that 18.04 is no longer used.

This step is not too disgusting, but there is a lack of dependencies. I didn't pay attention to downgrading the package, but it seems that 588 packages were deleted, including ROS melodic and so on. burst directly.

sudo pip install python-igraph --upgrade

If the error is reported, it is usually because of the python version problem, so switch it yourself.
The installation failure here will affect the calculation of camera parameters later. My python3.6 has not been installed, and 2.7 is installed like this:

sudo add-apt-repository ppa:igraph/ppa
sudo apt-get update #虽然这步更新的时候显示错误但是下面还是安装成功了,具体原因我也不清楚,但是总算安上了
sudo apt-get install python-igraph
mkdir -p ~/kalibr_workspace/src
cd ~/kalibr_workspace
source /opt/ros/melodic/setup.bash
catkin init
catkin config --extend /opt/ros/melodic
catkin config --merge-devel # Necessary for catkin_tools >= 0.4.
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
cd src
git clone https://github.com/ethz-asl/Kalibr.git

compile

cd ..
catkin build -DCMAKE_BUILD_TYPE=Release -j4

Compilation error : suitesparse error, you can take a look at this issue
source

source ~/zed_ws/devel/setup.bash

start zed2 camera

roslaunch zed_wrapper zed2.launch

Start the left and right camera visualization function, but there is a problem, all the code on the Internet is this code, I also asked my brother, no error is reported, but mine shows that the node name is repeated. So I changed the node name to
original:

rosrun image_view image_view image:=/zed2/zed_node/left/image_rect_color & rosrun image_view image_view image:=/zed2/zed_node/right/image_rect_color 

change:

rosrun image_view image_view __ns:=view1 image:=/zed2/zed_node/left/image_rect_color & rosrun image_view image_view __ns:=view2 image:=/zed2/zed_node/right/image_rect_color 

Kalibr has requirements for the recording frequency, which can be reduced to 20Hz

rosrun topic_tools throttle messages /zed2/zed_node/left/image_rect_color 20 /zed2/zed_node/left/image_rect_color2
rosrun topic_tools throttle messages /zed2/zed_node/right/image_rect_color 20 /zed2/zed_node/right/image_rect_color2

record packet

rosbag record -O Kalibr_data.bag /zed2/zed_node/imu/data_raw /zed2/zed_node/left/image_rect_color /zed2/zed_node/right/image_rect_color

View recorded data

rosbag info Kalibr_data.bag

Get camera parameters

kalibr_calibrate_cameras --bag Kalibr_data.bag --topics /zed2/zed_node/left/image_rect_color /zed2/zed_node/right/image_rect_color --models pinhole-radtan pinhole-radtan --target april_6x6_50x50cm.yaml

My parameters in april_6x6_50x50cm.yaml above are

target_type: 'aprilgrid' #gridtype
tagCols: 6               #number of apriltags
tagRows: 6               #number of apriltags
tagSize: 0.035           #size of apriltag, edge to edge [m]
tagSpacing: 0.285714          #ratio of space between tags to tagSize

Guess you like

Origin blog.csdn.net/qq_41746268/article/details/116195799