ubuntu18.04 realsense
1.直接運行
官方網站:Intel RealSense SDK 2.0 – Intel RealSense Depth and Tracking cameras
(1) x86運行
librealsense/distribution_linux.md at master · IntelRealSense/librealsense · GitHub
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u sudo apt-get install librealsense2-dkms sudo apt-get install librealsense2-utils?(2)jeston 使用這種方式無cuda加速
NVIDIA Jetson installation
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE?ubuntu18.04
sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo bionic main" -u sudo apt-get install librealsense2-utils sudo apt-get install librealsense2-dev?運行
realsense-viewer2.源碼安裝
官網:Linux/Ubuntu - RealSense SDK 2.0 Build Guide
2.1.更新內核
運行代碼(4.4.0-50以上)
uname -r2.2.更新cmake(需要3.6以上版本)
cmake -version2.3.安裝gcc-c++(gcc 5.00以上):
gcc -v3.安裝依賴
sudo apt-get install libusb-1.0-0-dev pkg-config libgtk-3-dev sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev4下載安裝包
https://github.com/IntelRealSense/librealsense/tags
建議在上述網址選擇合適的版本進行安裝,測試2.49.0跑ros點云很卡,卸載安裝2.48.0
sudo git clone https://github.com/IntelRealSense/librealsense?5.添加驅動(不插設備)
(1)x86運行
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && udevadm trigger ./scripts/patch-realsense-ubuntu-lts.sh?(2)arm運行
./scripts/patch-realsense-ubuntu-L4T.sh ./scripts/setup_udev_rules.sh6.安裝Openssl庫:
sudo apt-get install libssl-dev8.安裝編譯
cd librealsense/ sudo mkdir build cd build(1) x86運行cmake(程序中有很多例子,若想編譯example,如無例子添加可省略,編譯點云-DBUILD_PCL_EXAMPLES=true)
cmake ../ -DBUILD_EXAMPLES=true sudo make && make install(2)jeston 帶有cuda加速
cmake .. -DBUILD_EXAMPLES=true -DCMAKE_BUILD_TYPE=release -DFORCE_RSUSB_BACKEND=false -DBUILD_WITH_CUDA=true && make -j$(($(nproc)-1)) && sudo make install?運行
~/Desktop/realsense_document/software/librealsense-2.48.0/build/examples/capture/rs-capture9.ROS Realsense
https://github.com/IntelRealSense/realsense-ros/blob/development/README.md#installation-instructions
Releases · IntelRealSense/realsense-ros · GitHub
?創建工作空間在src中解壓下載的source文件
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release catkin_make install10.錯誤?
(1) ros在opencv之前安裝,導致重新安裝了opencv在cv_bridge中找opencv的默認路徑不一樣,所以要修改。
這里:/opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
原來是這樣子:
?修改的內容是把 /usr/include/opencv 改為/usr/local/include/opencv4/opencv2,/usr/local/include/opencv4
下面set(libraries)也需要改。
set(libraries "cv_bridge;/usr/lib/libopencv_core.so.4.5.3;/usr/lib/libopencv_imgproc.so.4.5.3;/usr/lib/libopencv_imgcodecs.so.4.5.3")
(2)ddynamic_reconfigure
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):Could not find a package configuration file provided by"ddynamic_reconfigure" with any of the following names:ddynamic_reconfigureConfig.cmakeddynamic_reconfigure-config.cmake修改:
sudo apt install ros-melodic-rgbd-launch sudo apt-get install ros-melodic-ddynamic-reconfigure roslaunch realsense2_camera rs_camera.launch //realsense數據採集節點 roslaunch realsense2_camera rs_camera.launch filters:=pointcloud //點暈 roslaunch realsense2_camera rs_camera.launch filters:=pointcloud pointcloud_texture_stream:=RS2_STREAM_ANY enable_color:=false //完全無圖像只有點云,換為ture有圖像,非對齊后的,直接是圖像對其點云 rosrun image_view image_view image:=/camera/color/image_raw //系統自帶顯示 rosrun recive_rgb recive_rgbc //C++節點,在cmake與xml 要添加image_transfer rosrun recive_rgb src/recevi_rgb.py //python監聽節點 rosrun rqt_graph rqt_graph //節點關系圖 rosrun pcl_cloudc pcl_cloudc //點暈 roslaunch realsense2_camera rs_rgbd.launch// sudo gedit ~/.bashrc source /home/catkin_ws/devel/setup.bash source ~/.bashrc(3) /opt/ros/kinetic/lib/nodelet/nodelet: symbol lookup error: /opt/ros/kinetic/lib//libexample_pkg.so: undefined symbol: _ZN2cv11namedwindowERKNS_6StringEi
?說明:undefined symbol: _ZN2后的字母,cv =opencv
在camera CMakeLists中添加下面
set(OpenCV_DIR /usr/local/lib) find_package( OpenCV REQUIRED )target_link_libraries(?${OpenCV_LIBS})symbol lookup error: /home/llx/catkin_ws/markerlocalization/devel/lib//liblaneloc.so: undefined symbol: _ZN2tf17TransformListenerC1EN3ros8DurationEb
說明:tf的問題。
使用c++filt 查看報錯的位置: 終端輸入:
c++filt ?_ZN2tf17TransformListenerC1EN3ros8DurationEb
tf::TransformListener::TransformListener(ros::Duration, bool)
顯示這個
原文鏈接:https://blog.csdn.net/weixin_39608351/article/details/92843763
11.pcl_cloudc.cpp
說明:點云數據ros提取。
catkin_create_pkg pcl_cloudc cv_bridge image_transport pcl_conversions pcl_ros roscpp rospy sensor_msgs std_msgs #include <ros/ros.h> // PCL specific includes #include <sensor_msgs/PointCloud2.h> #include <pcl_conversions/pcl_conversions.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h>#include <pcl/filters/voxel_grid.h>ros::Publisher pub;void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg) {// Container for original & filtered datapcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2; pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);pcl::PCLPointCloud2 cloud_filtered;// Convert to PCL data typepcl_conversions::toPCL(*cloud_msg, *cloud);// Perform the actual filteringpcl::VoxelGrid<pcl::PCLPointCloud2> sor;sor.setInputCloud (cloudPtr);sor.setLeafSize (0.1, 0.1, 0.1);sor.filter (cloud_filtered);// Convert to ROS data typesensor_msgs::PointCloud2 output;pcl_conversions::moveFromPCL(cloud_filtered, output);// Publish the datapub.publish (output); }int main (int argc, char** argv) {// Initialize ROSros::init (argc, argv, "my_pcl_tutorial");ros::NodeHandle nh;// Create a ROS subscriber for the input point cloudros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2> ("/camera/depth/color/points", 1, cloud_cb);// Create a ROS publisher for the output point cloudpub = nh.advertise<sensor_msgs::PointCloud2> ("filtered_points", 1);// Spinros::spin (); }CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2) project(pcl_cloudc) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") find_package(catkin REQUIRED COMPONENTScv_bridgeimage_transportpcl_conversionspcl_rosroscpprospysensor_msgsstd_msgs ) catkin_package() include_directories( # include${catkin_INCLUDE_DIRS} ) add_executable(pcl_cloudc src/pcl_cloudc.cpp) target_link_libraries(pcl_cloudc ${catkin_LIBRARIES})package.xml添加:
<build_depend>libpcl-all-dev</build_depend>??
<exec_depend>libpcl-all</exec_depend>
(2) arm64行下面
12.recive_rgb
catkin_create_pkg recive_rgb cv_bridge roscpp rospy sensor_msgs image_transport std_msgsrecevice_rgb.cpp
#include <ros/ros.h> #include <image_transport/image_transport.h> #include <cv_bridge/cv_bridge.h> //OpenCV2標準頭文件#include<opencv2/core/core.hpp> #include<opencv2/highgui/highgui.hpp> #include <opencv2/imgcodecs.hpp>void imageCallback(const sensor_msgs::ImageConstPtr& msg) {try{cv::imshow("c++ show", cv_bridge::toCvShare(msg, "bgr8")->image);//展示圖片cv::waitKey(10);}catch (cv_bridge::Exception& e){ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());} }int main(int argc, char **argv) {ros::init(argc, argv, "image_listener");ros::NodeHandle nh;cv::namedWindow("view");cv::startWindowThread();image_transport::ImageTransport it(nh);image_transport::Subscriber sub = it.subscribe("/camera/color/image_raw", 1, imageCallback);ros::spin();cv::destroyWindow("view"); }?recevi_rgb.py
#!/usr/bin/env python import rospy from sensor_msgs.msg import Image import cv2 from cv_bridge import CvBridgedef callback(imgmsg):bridge = CvBridge()img = bridge.imgmsg_to_cv2(imgmsg, "bgr8")#print('******************')#print(img.shape)cv2.imshow("python show", img)cv2.waitKey(3)def listener():# In ROS, nodes are uniquely named. If two nodes with the same# node are launched, the previous one is kicked off. The# anonymous=True flag means that rospy will choose a unique# name for our 'listener' node so that multiple listeners can# run simultaneously.rospy.init_node('listener', anonymous=True)rospy.Subscriber("/camera/color/image_raw", Image, callback)# spin() simply keeps python from exiting until this node is stoppedrospy.spin() if __name__ == '__main__':listener()CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2) project(recive_rgb)## Compile as C++11, supported in ROS Kinetic and newer # add_compile_options(-std=c++11)## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTScv_bridgeroscpprospysensor_msgsimage_transportstd_msgs ) find_package(OpenCV 4.2.0 REQUIRED) catkin_package( # INCLUDE_DIRS include # LIBRARIES recive_rgbCATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs std_srvs # DEPENDS system_lib ) include_directories( # include${catkin_INCLUDE_DIRS}${OpenCV_INCLUDE_DIRS} )add_executable(recive_rgbc src/recevice_rgb.cpp) target_link_libraries(recive_rgbc ${catkin_LIBRARIES} ${OpenCV_LIBS})package.xml
<buildtool_depend>catkin</buildtool_depend><build_depend>cv_bridge</build_depend><build_depend>roscpp</build_depend><build_depend>rospy</build_depend><build_depend>sensor_msgs</build_depend><build_depend>std_msgs</build_depend><build_depend>std_srvs</build_depend><build_depend>image_transport</build_depend> <build_export_depend>image_transport</build_export_depend><build_export_depend>cv_bridge</build_export_depend><build_export_depend>roscpp</build_export_depend><build_export_depend>rospy</build_export_depend><build_export_depend>sensor_msgs</build_export_depend><build_export_depend>std_msgs</build_export_depend><build_export_depend>std_srvs</build_export_depend><exec_depend>image_transport</exec_depend><exec_depend>cv_bridge</exec_depend><exec_depend>roscpp</exec_depend><exec_depend>rospy</exec_depend><exec_depend>sensor_msgs</exec_depend><exec_depend>std_msgs</exec_depend><exec_depend>std_srvs</exec_depend>roslaunch realsense2_camera rs_camera.launch filters:=pointcloud pointcloud_texture_stream:=RS2_STREAM_ANY enable_color:=true
?
?roslaunch realsense2_camera demo_pointcloud.launch
?
總結
以上是生活随笔為你收集整理的ubuntu18.04 realsense的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tomcat集群部署
- 下一篇: Datagrip免费