【三维重建】Ubuntu20.04进行RealSenseD435环境配置及初步使用
一、环境配置
github上面的教程:https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
比较完整的配置博客:
https://blog.csdn.net/wanghq2013/article/details/123325671
https://blog.csdn.net/jiexijihe945/article/details/126163341
1、首先按照Installing the packages进行环境配置
- 注册服务器的公钥:
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
以上两行将部署 librealsense2 udev 规则,构建和激活内核模块、运行时库和可执行的演示和工具。
- 可选择安装开发人员和调试包:
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg
由于dev
包已经安装,你可以编译一个应用使用librealsense,通过命令g++ -std=c++11 filename.cpp -lrealsense2
或别的IDE来编译具有librealsense的应用
重新连接英特尔实感深度摄像头并运行:realsense-viewer
以验证安装。
验证内核是否已更新:
modinfo uvcvideo | grep "version:"
应包括realsense
字符。
2、卸载库文件
重要仅当没有其他已安装的软件包直接引用它时才允许删除 Debian 软件包。
例如删除 librealsense2-udev-rules
需要先删除 librealsense2
卸载一个单独的包使用命令:
sudo apt-get purge <package-name>
移除所有Realense 相关的SDK包使用:
dpkg -l | grep "realsense" | cut -d " " -f 3 | xargs sudo dpkg --purge
3、报错
使用realsense-viewer
命令打开界面出现cannot access /sys/access/video4linux
这边出现的问题是刚才安装dkms需要编译linux的内核相关,而重启之后没有选择更改内核的选项,所有出现了问题。
正确的做法是安装dkms之后重启以下,重启的时候会出现爱你UEFI Secure Boot的要求,
UEFI Secure boot是一种验证机制,确保固件启动的代码是可信的
要输入secure boot密码的情况:
重启电脑时perfrom mok management,出现蓝屏的MOK management,具体的解决办法如下:
- 当进入蓝色背景的界面perform mok management后,选择 enroll mok,
- 进入enroll mok界面,选择 continue,
- 进入enroll the key界面,选择yes,
- 接下来输入你在安装驱动时输入的密码
- 之后会跳到蓝色背景的界面perform mok management选择第一个reboot
4、ROS下使用
https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy
在ubuntu下使用
第一步就是刚才写的安装sdk
第二步从源码安装
- 在ubuntu下创建工作空间
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
- 拷贝最新的realsense包到这个空间
git clone https://github.com/IntelRealSense/realsense-ros.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
确保已经安装了
ddynamic_reconfigure
,没有安装的话从https://github.com/pal-robotics/ddynamic_reconfigure/tree/kinetic-devel
此处git到src目录下。接着运行
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
- 在ubuntu下添加启动
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
- 启动节点测试
开启摄像头节点:
roslaunch realsense2_camera rs_camera.launch
然后打开rviz选择摄像头以及DepthCloud就能进行显示了。
- 还可以直接使用rgbd-launch进行测试
rgbd_launch是一组打开RGBD设备,并load 所有nodelets转化 raw depth/RGB/IR 流到深度图(depth image), 视差图(disparity image)和点云(point clouds)的launch文件集。sudo apt-get install ros-noetic-rgbd-launch
测试
roslaunch realsense2_camera demo_pointcloud.launch
二、使用
useage1
https://blog.csdn.net/wanghq2013/article/details/123325671
上面博客中自己的使用是将img_viewer.cpp中的节点改成realsense的RGB图片或者深度图片,如果是深度图片,需要将cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
中的rgb8
改成16UC1
。
也就是调用realsense发布的节点用的是realsense自己的,
roslaunch realsense2_camera rs_camera.launch
订阅节点用的是上面的img_viewer.cpp
另外自己使用的时候用的是rosOpenCV
。
以下是自己的package.xml
点击查看代码
<?xml version="1.0"?>
<package format="2">
<name>myRealSenseTest</name>
<version>0.0.0</version>
<description>The myRealSenseTest package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="bck20@todo.todo">bck20</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/myRealSenseTest</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>rosOpenCV</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>cv_bridge</build_export_depend>
<build_export_depend>image_transport</build_export_depend>
<build_export_depend>rosOpenCV</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>cv_bridge</exec_depend>
<exec_depend>image_transport</exec_depend>
<exec_depend>rosOpenCV</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
img_viewer.cpp
点击查看代码
//接收并查看图像消息的节点img_viewer.cpp
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
//依赖包有std_msgs(消息传递),roscpp(c++),cv_bridge(ros和opencv图像消息转换),sensor_msgs(传感器消息),image_transport(图像编码传输)
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
try
{
cv::imshow("view", cv_bridge::toCvShare(msg, "16UC1")->image);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to '16UC1'.", msg->encoding.c_str());
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "img_viewer");
ros::NodeHandle nh;
cv::namedWindow("view");
cv::startWindowThread();
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("camera/depth/image_rect_raw", 0, imageCallback);
ros::spin();
cv::destroyWindow("view");
return 0;
}
CMakeLists.txt
点击查看代码
cmake_minimum_required(VERSION 3.0.2)
project(myRealSenseTest)
## 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 COMPONENTS
cv_bridge
image_transport
roscpp
sensor_msgs
std_msgs
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
# find_package(OpenCV REQUIRED)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# sensor_msgs# std_msgs
# )
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES myRealSenseTest
# CATKIN_DEPENDS cv_bridge image_transport opencv2 roscpp sensor_msgs std_msgs
# DEPENDS system_lib
)
###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/myRealSenseTest.cpp
# )
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/myRealSenseTest_node.cpp)
## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
# ${catkin_LIBRARIES}
# )
add_executable(img_publisher src/img_publisher.cpp)
target_link_libraries(img_publisher ${catkin_LIBRARIES} )
add_executable(img_viewer src/img_viewer.cpp)
target_link_libraries(img_viewer ${catkin_LIBRARIES})
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# catkin_install_python(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_myRealSenseTest.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
usage2
https://blog.csdn.net/zkk9527/article/details/108224128
usage3
从深度相机生成pcl点云:https://dontla.blog.csdn.net/article/details/102608417
【三维重建】Ubuntu20.04进行RealSenseD435环境配置及初步使用的更多相关文章
- Ubuntu20.04安装 maven并配置阿里源
Ubuntu20.04安装 maven并配置阿里源 sudo apt update sudo apt install maven #安装maven,默认安装路径为/usr/share/maven 添加 ...
- Desktop Ubuntu 14.04LTS/16.04科学计算环境配置
Desktop Ubuntu 14.04LTS/16.04科学计算环境配置 计算机硬件配置 cpu i5 6代 内存容量 8G gpu GTX960 显存容量 2G(建议显存在4G以上,否则一些稍具规 ...
- 自动化kolla-ansible部署ubuntu20.04+openstack-victoria之文件配置-08
自动化kolla-ansible部署ubuntu20.04+openstack-victoria之文件配置-08 欢迎加QQ群:1026880196 进行交流学习 文件配置 #controller ...
- 自动化kolla-ansible部署ubuntu20.04+openstack-victoria之基础配置-04
自动化kolla-ansible部署ubuntu20.04+openstack-victoria之基础配置-04 欢迎加QQ群:1026880196 进行交流学习 近期我发现网上有人转载或者复制原创博 ...
- Ubuntu20.04 Java相关环境(JDK、Mysql、Redis、nacos、influxdb)部署以及运行
重装了系统,系统版本号为:Ubuntu20.04 1.云平台 登录云平台,选择要重装的服务器,关机.一键重装即可 2.安装jdk 下载jdk-8u341-linux-x64.tar.gz,并复制到服务 ...
- ubuntu18.04系统安装+基本环境配置【原创】
平台信息:PC:ubuntu18.04.i5.七彩虹GTX1060显卡.固态硬盘.机械硬盘 作者:庄泽彬(欢迎转载,请注明作者) 说明:在原本的电脑买一个独立显卡,装上去之后,出了各种问题,虽然后面勉 ...
- Ubuntu20.04 PostgreSQL 14 安装配置记录
PostgreSQL 名称来源 It was originally named POSTGRES, referring to its origins as a successor to the Ing ...
- Ubuntu20.04和Docker环境下安装Redash中文版
创建Ubunt20.04虚拟机,请参考:https://www.linuxidc.com/Linux/2020-03/162547.htm 一.安装基础环境: # 1.更换APT国内源 sudo se ...
- php入门一ubuntu16.04中php环境配置及一个网页
1.PHP(全称:PHP:Hypertext Preprocessor,即"PHP:超文本预处理器")是一种通用开源脚本语言. 2.PHP 文件可包含文本.HTML.JavaScr ...
- ubuntu16.04深度学习环境配置
https://www.lizenghai.com/archives/14651.html https://blog.csdn.net/qq_40936141/article/details/8119 ...
随机推荐
- python新冠疫情分析-世界疫情数据爬取
事情发展:1.毕业设计是关于疫情数据的可视化展示(基于java,需要做数据可视化,需要做管理员端对数据进行增删改查处理)2.飞起来速度学爬虫,参考了非常多资料,比如b站的黑马爬取(报错,就是在切片那里 ...
- YouCompleteMe用法总结
1.将.ycm_extra_conf.py拷贝到工程目录,然后打开,将自己的include目录添加进去
- WinUI 剪裁发布中的一个小坑
WinUI 3 (以下简称 WinUI)框架发布后的二进制文件过大的问题存在了很长时间,我在这篇文章中有过详细的讨论,好在 Windows App SDK v1.2 就已经支持剪裁发布,但是我却一直没 ...
- 【NOIP2012提高组】开车旅行
题目 到处都有 闲话 碰巧考场上出了 \(Noip\) 原题 然后这题自然而然想到 预处理一个点开始分别由 \(A,B\) 驾驶会走到的下一个点 然后用预处理的数组求答案 当然你会发现 \(X=X0\ ...
- [EULAR文摘] 滑膜HIF-1a与类风湿关节炎的关节破坏
滑膜HIF-1a与类风湿关节炎的关节破坏 Wei XN, et al. EULAR 2015. Present ID: OP0070. 背景:低氧诱导因子(HIF)-1α是缺氧条件下细胞反应的一个关键 ...
- 视觉SLAM基础-李群和李代数
李群和李代数 目录 李群和李代数 引言 1.0 李群 1.1 群 1.2 李群基础定义 2.0李代数 2.1 引出 2.2 李代数的定义 2.3 李代数 \(so(3)\) 2.4 李代数 \(se( ...
- 基于GLFW的PyOpenGL的使用
1. GLFW概述 OpenGL只是一种规范,不仅语言无关,而且平台无关.规范只字未提获得和管理OpenGL上下文相关的内容,而是将这些作为细节交给底层的窗口系统.出于同样的原因,OpenGL纯粹专注 ...
- 重要内置函数、常见内置函数(了解)、可迭代对象、迭代器对象、for循环原理、异常捕获
目录 一.重要内置函数 二.常见内置函数(了解) 三.可迭代对象 四.迭代器对象 五.for循环内部原理 六.捕捉异常 一.重要内置函数 1. zip 说白了就是压缩几组数据值,说细了就是将可迭代对象 ...
- 如何设置VBA代码的密码?如何取消VBA代码的密码?
经常有网友问,用Access把软件开发好了,怎么样设置VBA代码的密码?以保护自己的代码不被同事修改.这里简单整理了一下.设置VBA代码的密码及取消VBA代码的密码步骤如下:1.打开任意一个窗体,进入 ...
- Linux操作命令(六)1.wc命令 2.grep命令 3.正则表达式
1.wc 命令是一个统计的工具,主要用来显示文件所包含的行.字和字节数 参数 描述 -c 统计字节数 -l 统计行数 -m 统计字符数,这个标志不能与 -c 标志一起使用 -w 统计字数,一个字被定义 ...