Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit 3291421

Browse files
committed
add dso
1 parent c8d2bda commit 3291421

File tree

530 files changed

+106640
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

530 files changed

+106640
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
# dso_ros笔记本摄像头的安装与跑通
2+
3+
### 环境
4+
5+
- Ubuntu16.04
6+
- ROS-kinetic
7+
- dso_ros catkin版本
8+
- 笔记本自带单目摄像头
9+
- 安装编译成功的DSO
10+
11+
### 安装编译dso_ros
12+
13+
```
14+
cd ~/catkin_dso/src
15+
git clone https://github.com/JakobEngel/dso_ros.git #这里是catkin版本
16+
export DSO_PATH=/home/YOUR_DSO_PATH/dso
17+
cd dso_ros
18+
gedit CMakeLists.txt
19+
# 修改bin文件路径
20+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
21+
# 如果不修改,编译生成的bin将会存在build目录下,rosrun会找不到
22+
mkdir build
23+
cd build
24+
cmake ..
25+
make
26+
sudo make install
27+
cd ~/catkin_dso
28+
catkin_make
29+
30+
```
31+
### 安装编译usb_cam
32+
33+
```
34+
cd ~/catkin_dso/src
35+
git clone https://github.com/bosch-ros-pkg/usb_cam.git
36+
cd ..
37+
catkin_make
38+
source ~/catkin_dso/devel/setup.bash
39+
```
40+
### 笔记本相机ROS标定
41+
42+
- ROSwiki有相机矫正的官方文档,有单目的也有立体相机的教程,[官方链接](http://wiki.ros.org/camera_calibration)
43+
44+
- [参考链接](https://blog.csdn.net/qq_30460905/article/details/80390576)
45+
46+
##### 1 下载标定板
47+
48+
[标定板下载链接](http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration?action=AttachFile&do=view&target=check-108.pdf)
49+
50+
标定板为8x6,A4纸打印出来为,用直尺量square边长为24.5mm(这个根据自己标定板的大小自己量,大点好),即0.0245m,作为标定输入参数。
51+
52+
##### 2 打开相机
53+
54+
```
55+
cd ~/catkin_dso
56+
source devel/setup.bash
57+
roslaunch usb_cam usb_cam-test.get
58+
# launch文件里面默认设备为/dev/video0,外接USB摄像头是有可能是/dev/video1,根据具体情况而定)
59+
# 如果你没有矫正过的话,你会发现打开相机时会有一条警告
60+
```
61+
62+
##### 3 开始矫正
63+
64+
一般来说正常安装ros都是包含了camera_calibration,输入下面命令检查一下
65+
66+
```
67+
~$ rosdep install camera_calibration
68+
#All required rosdeps installed successfull
69+
70+
```
71+
72+
执行矫正文件
73+
74+
`rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.0245 image:=/usb_cam/image_raw camera:=/usb_cam`
75+
76+
弹出display窗口
77+
78+
**注意:**如果没有的话检查你命令输入是否输入正确,例如:8x6,中间不能用 "*" ,是字母 "x",--size,--square前面是两个"-",还要注意你的相机发出的话题是不是`usb_cam/image_raw`
79+
80+
##### 4 采集样本
81+
82+
- 使得标定板尽量出现在摄像头视野的各个位置里
83+
- CALIBRATE按钮变绿色,点击等待
84+
- 点击COMMIT将结果保存到电脑路径:/home/××××/.ros/camera_info/head_camera.yaml
85+
86+
##### 5 结果格式例下
87+
88+
```
89+
[image]
90+
width
91+
640
92+
height
93+
480
94+
[narrow_stereo]
95+
camera matrix
96+
644.987121 0.000000 331.735116
97+
0.000000 647.308571 248.505845
98+
0.000000 0.000000 1.000000
99+
100+
distortion
101+
0.248372 -0.436036 -0.008074 -0.000495 0.000000
102+
103+
rectification
104+
1.000000 0.000000 0.000000
105+
0.000000 1.000000 0.000000
106+
0.000000 0.000000 1.000000
107+
108+
projection
109+
669.478394 0.000000 331.064954 0.000000
110+
0.000000 669.226440 245.232233 0.000000
111+
0.000000 0.000000 1.000000 0.000000
112+
113+
```
114+
115+
参数意义:
116+
117+
image_width、image_height代表图片的长宽 camera_name为摄像头名
118+
camera_matrix规定了摄像头的内部参数矩阵
119+
distortion_model指定了畸变模型
120+
distortion_coefficients指定畸变模型的系数
121+
rectification_matrix为矫正矩阵,一般为单位阵
122+
projection_matrix为外部世界坐标到像平面的投影矩阵
123+
124+
### 运行dso_ros
125+
126+
编写相机文件:
127+
128+
`gedit ~/catkin_dso/src/dso_ros/camera.txt`
129+
130+
格式如下:
131+
132+
```
133+
fx fy cx cy k1 k2 r1 r2
134+
in_width in_height
135+
"crop" / "full" / "fx fy cx cy 0"
136+
out_width out_height
137+
138+
```
139+
不同相机的格式写法不同,[官方链接](https://github.com/JakobEngel/dso)
140+
141+
打开一个终端
142+
143+
`roscore`
144+
145+
再开终端
146+
147+
```
148+
source ~/catkin_dso/devel/setup.bash
149+
roslaunch usb_cam usb_cam-test.launch
150+
```
151+
152+
再开终端
153+
154+
```
155+
source ~/catkin_dso/devel/setup.bash
156+
rosrun dso_ros dso_live image:=/usb_cam/image_raw calib=/home/YOUR_PATH/camera.txt mode=1
157+
```
158+
159+
### 跑通图示
160+
161+
笔记本摄像头跑通截图:
162+
163+
![2019-04-28_15-36-13屏幕截图](./image/Notebook_computer_dso.png)
164+
165+
### 可能遇到的问题
166+
167+
`error1`
168+
169+
```
170+
/usr/bin/ld: CMakeFiles/dso_live.dir/src/main.cpp.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
171+
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
172+
collect2: error: ld returned 1 exit status
173+
CMakeFiles/dso_live.dir/build.make:198: recipe for target 'bin/dso_live' failed
174+
make[3]: *** [bin/dso_live] Error 1
175+
```
176+
177+
##### error1解决办法
178+
179+
```
180+
cd ~/catkin_dso/src/dso_ros
181+
gedit CMakeLists.txt
182+
# 编辑前:
183+
target_link_libraries(dso_live ${DSO_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS})
184+
185+
# 编辑后:
186+
target_link_libraries(dso_live ${DSO_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS} GL glut GLU boost_system)
187+
```
188+
`error2`
189+
190+
```
191+
# 运行dso_ros出现
192+
193+
Couldn't find executable named dso_live below /home/chuanxu/catkin_dos/src/dso_ros
194+
```
195+
196+
##### error2解决办法
197+
198+
- 可能原因1:下错了版本,下成了rosbuild,重新下载catkin版本并编译测试。
199+
- 可能原因2:rosrun ××× 路径错误,找不到camera.txt,检查路径并修正即可。
200+
201+
202+
`error3`
203+
204+
xbot上安装 usb_cam 出现error:
205+
206+
```
207+
[usb_cam-1] process has died [pid 5257, exit code 1, cmd /home/zkzdzn/catkin_dso/devel/lib/usb_cam/usb_cam_node __name:=usb_cam __log:=/home/zkzdzn/.ros/log/ea6db8de-6759-11e9-a323-34415de66a2c/usb_cam-1.log].
208+
log file: /home/zkzdzn/.ros/log/ea6db8de-6759-11e9-a323-34415de66a2c/usb_cam-1*.log
209+
```
210+
211+
##### error3解决办法
212+
213+
- `rostopic list`
214+
- 找到自己相机发布的image topic 例如: /camera/color/image_raw
215+
- 找到usb_cam launch文件 修改重映射 remap 到自己相机发布的topic
216+
217+
```
218+
</node>
219+
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
220+
# 修改前
221+
<remap from="image" to="/usb_cam/image_raw"/>
222+
# 修改后
223+
<remap from="image" to="/camera/color/image_raw"/>
224+
<param name="autosize" value="true" />
225+
</node>
226+
</launch>
227+
```
228+
229+
230+
231+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# DSO在仿真xbot上的部署
2+
3+
### 环境
4+
5+
- Ubuntu 16.04
6+
- bro2018fall-codes
7+
- DSO
8+
- DSO_ROS catkin版本
9+
- 仿真xbot自带摄像头
10+
11+
### 操作步骤
12+
13+
打开仿真环境:
14+
15+
```
16+
cd catkin_ws/ # 包含仿真环境的工作空间
17+
source devel/setup.bash
18+
roslaunch robot_sim_demo robot_spawn.launch
19+
```
20+
重新打开一个终端,查看当前工作相机发布话题
21+
22+
```
23+
rostopic list
24+
25+
# /camera_D415/rgb/image_raw 使我们要的发布图像信息话题
26+
27+
```
28+
29+
再打开一个终端
30+
31+
```
32+
cd catkin_dso/src/usb_cam/launch
33+
gedit usb_cam-test.launch
34+
35+
# 修改launch文件如下:
36+
<launch>
37+
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
38+
<param name="video_device" value="/dev/video0" />
39+
# 图片长和宽修改为xbot相机参数值
40+
<param name="image_width" value="320" />
41+
<param name="image_height" value="240" />
42+
<param name="pixel_format" value="yuyv" />
43+
<param name="camera_frame_id" value="usb_cam" />
44+
<param name="io_method" value="mmap"/>
45+
</node>
46+
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
47+
# 重映射xbot现在发布的话题
48+
<remap from="image" to="/camera_D415/rgb/image_raw"/>
49+
<param name="autosize" value="true" />
50+
</node>
51+
</launch>
52+
```
53+
保存后
54+
55+
```
56+
cd ~/catkin_dso
57+
source devel/setup.bash
58+
roslaunch usb_cam usb_cam-test.launch
59+
```
60+
修改xbot仿真摄像头的camera.txt如下:
61+
62+
```
63+
277.191356 277.191356 160.5 120.5 0 0 0 0
64+
320 240
65+
crop
66+
320 240
67+
```
68+
再开一个终端
69+
70+
```
71+
cd catkin_dso
72+
source devel/setup.bash
73+
rosrun dso_ros dso_live image:=/camera_D415/rgb/image_raw calib=/home/YOUR_PATH/camera.txt
74+
```
75+
76+
再开一个终端
77+
78+
```
79+
cd catkin_ws/ #仿真环境所在工作空间
80+
source devel/setup.bash
81+
rosrun robot_sim_demo robot_keyboard_teleop.py #启动键盘控制程序
82+
```
83+
84+
### 运行结果
85+
86+
![2019-05-06_22-36-37屏幕截图](./image/simu_dso_1.png)
87+
88+
![2019-05-06_22-38-40屏幕截图](./image/simu_dso_2.png)
89+
90+
![2019-05-06_22-23-33屏幕截图](./image/simu_dso_3.png)
91+
92+
### 仿真中效果和问题总结
93+
94+
- 仿真中由于光照等因素稳定不变,所以相机的畸变矩阵参数全为0.建图效果相当好.
95+
- 仿真中xbot上的摄像头输入分辨率太低,只有320 x 240,导致输出图像分辨率也只能是320 x 240,更低的话算法会报错,因为图分辨率过低无法进行建图,没有进行降低分辨率的输出,结果就是:建图缓慢,转弯丢失,和在现实中部署效果一致
96+
97+
### 改进建议
98+
99+
- 将xbot携带的摄像头数据进行修改提升,预计效果显著提升.

0 commit comments

Comments
 (0)