摄像头驱动安装
先安装显示工具:
1 2
| sudo apt-get update sudo apt-get install ros-indigo-image-view, v4l-utils
|
然后安装驱动;
1 2 3 4 5 6 7 8
| sudo apt-get update sudo apt-get install ros-indigo-image-view, v4l-utils
cd ~/catkin_ws/src git git clone https://github.com/bosch-ros-pkg/usb_cam.git cd .. catkin_make source ~/catkin-ws/devel/setup.bash
|
进入~/catkin-ws/usb_cam/src/usb_cam/launch/usb_cam-test.launch
,以usb_cam-test.launch
为参考新建usb_cam.launch
,修改里面内容(主要是video_device的值):
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <launch> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="/dev/video0" /> <param name="image_width" value="640" /> <param name="image_height" value="480" /> <param name="pixel_format" value="yuyv" /> <param name="camera_frame_id" value="usb_cam" /> <param name="io_method" value="mmap"/> </node> <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen"> <remap from="image" to="/usb_cam/image_raw"/> <param name="autosize" value="true" /> </node> </launch>
|
现在一个新窗口运行roscore
。 然后在另外一个新窗口:
1 2 3
| cd ~/catkin_ws/ source devel/setup.sh roslaunch usb_cam usb_cam.launch
|
安装ORB-SLAM2
1 2 3 4 5 6 7
| sudo apt-get install libblas-dev sudo apt-get install liblapack-dev git clone https://github.com/raulmur/ORB_SLAM2.git cd ORB_SLAM2 chmod +x build.sh ./build.sh
|
1 2 3
| cd ~ sudo gedit .bashrc export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
|
其中PATH/ORB_SLAM2/Examples/ROS
为你的实际位置(如/home/luohanjie/SLAM/Code/slam_catkin_ws/src/ORB_SLAM2/Examples/ROS
)。
ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc
中某代码修改为:
1
| ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);
|
1 2 3 4 5
| cd PATH/ORB_SLAM2/Examples/ROS/ORB_SLAM2 mkdir build cd build cmake .. -DROS_BUILD_TYPE=Release make -j
|
运行
打开一个窗口运行roscore
然后在另外一个新窗口:
1 2 3
| cd ~/catkin_ws/ source devel/setup.sh roslaunch usb_cam usb_cam.launch
|
然后在另外一个新窗口:
1 2 3
| cd ~/catkin_ws/ source devel/setup.sh rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE
|
PATH_TO_VOCABULARY是词典的位置,PATH_TO_SETTINGS_FILE是摄像头标定的yaml文件。
如:
1
| rosrun ORB_SLAM2 Mono /home/luohanjie/SLAM/Code/slam_catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/luohanjie/SLAM/Code/slam_catkin_ws/src/usb_cam/calib/camera_slam.yml
|
1
| rosrun ORB_SLAM2 Mono /home/luohanjie/SLAM/Code/catkin_ws_orbslam_loadmap/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/luohanjie/SLAM/Code/catkin_ws_orbslam_loadmap/src/usb_cam/calib/camera_slam.yml
|