上的安装说明如下:

官网上明确写了如果安装windows kinect还需要安装一个驱动,但是有些ROS的书上并没有这么做,只提到了使用如下两步进行安装即可使用:

sudo apt-get install ros-<rosdistro>-openni-camera sudo apt-get install ros-<rosdistro>-openni-launch

        我仅使用如上两步安装时候,会发生如下的错误:

"No Device Connected, Waiting for Device to be Connected"

在ROS answers上也有不少人提出这个问题,发生错误的原因就是没有缺少SensorKinect驱动,可以参考:

http://answers.ros.org/question/191594/no-device-connected-waiting-for-device-to-be-connected-error-when-connecting-kinect-with-ubuntu-on-a-virtual-box/

驱动的源码在这里:https://github.com/avin2/SensorKinect

安装驱动

mkdir ~/kinectdriver
cd ~/kinectdriver
git clone https://github.com/avin2/SensorKinect
cd SensorKinect/Bin/
tar xvjf SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2
cd Sensor-Bin-Linux-x64-v5.1.2.1/
sudo ./install.sh

  

安装完整后,再运行

roslaunch openni_launch openni.launch

发现还是存在问题,这个应该是USB2.0的端口不支持的原因

USB interface is not supported!

修改GlobalDefaults.ini配置文件

$ sudo gedit /etc/openni/GlobalDefaults.ini

将第60行前面的分号去掉(即取消注释)

;UsbInterface=2

 之后就一切正常了

然后可以查看深度图和彩色图信息

如果想看到各种图像的话,可以在终端中输入rqt,这时候会打开一个窗口,在Plugins菜单栏中选择最后一项的image_view,此时可以左侧的下拉菜单中选择话题的种类,注意,默认情况下,选择/camera/depth/XXXX的话题才会显示出来图像,因为你并没有设置depth_registered,如果你在显示的过程中,在新的终端里使用rosrun rqt_reconfiguration rqt_reconfiguration,之后在camera->driver中勾选了depth_registered,此时你的rqt窗口就不会进行图像刷新了,此时切换至/camera/depth_registered/XXXX的话题后,继续会刷新图像。

最后还是要保存Kinect看到的深度图像和彩色图像

找个文件夹

rosrun image_view extract_images _sec_per_frame:=0.1 image:=/camera/rgb/image_color

发现Kinect存储深度图并没有那么简单,保存格式是有问题的。

rosrun image_view image_saver image:=/camera/depth_registered/image_raw _encoding:=16UC1 _filename_format:="image%04i.png"

  

先写个node试试

https://github.com/GERUNSJ/guardar_imagenes_turtlebot

trick if you want you will get!

/* Este es un nodo de ROS Indigo para guardar imagenes de /camera/depth_registered/image_rect_raw* y de /camera/rgb/color/image_rect_raw de un Turtlebot1 para luego procesarlas con otro programa. * Las de profundidad se guardan como unsigned int de 16 bits * y 1 canal, las de color se guardan como unsigned int de 8 bits en 3 canales.* Se utiliza un suscriptor sincronizado para guardar el par de imagenes que estén más* cercanas en el tiempo.* LAS IMAGENES SE GUARDAN ADONDE SE EJECUTE EL NODO.* ---------------------------------------------------------* Creado por Fabricio Emder y Pablo Aguado en el 2016 *//* This is a ROS Indigo node for saving Turtlebot images from the /camera/depth_registered/image_rect_raw* and /camera/rgb/color/image_rect_raw topics, for further processing outside of the program. * Depth images are saved as 1 channel 16 bit unsigned int PNGs (CV_16UC1), and * RGB images are saved as 3 channel 8 bit unsigned int PNGs (CV_8UC3).* A synchronized subscriber is used, for saving the pair of images that are most closer in time.* THE IMAGES ARE SAVED WHEREVER THE NODE IS RUN.* Created by Fabricio Emder and Pablo Aguado - 2016* */#include <ros/ros.h>
#include <cv_bridge/cv_bridge.h>  // OpenCV
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>/* La política de sincronización exacta NO FUNCIONA para los topics seleccionados, ya * que la Kinect o sus drivers no los están publicando con la misma marca temporal.* Ver más en http://wiki.ros.org/message_filters * * Exact sychronization policy IS NOT WORKING for the topics used, because the kinect* is not publishing them with the same timestamp. * See more in http://wiki.ros.org/message_filters  *///#define EXACT
#define APPROXIMATE#ifdef EXACT
#include <message_filters/sync_policies/exact_time.h>
#endif
#ifdef APPROXIMATE
#include <message_filters/sync_policies/approximate_time.h>
#endifusing namespace std;
//using namespace sensor_msgs;
using namespace message_filters;// Contador para la numeración de los archivos.
// Counter for filenames.
unsigned int cnt = 1;// Handler / callback
void callback( const sensor_msgs::ImageConstPtr& msg_rgb , const sensor_msgs::ImageConstPtr& msg_depth )
{ROS_INFO_STREAM(" callback\n");cv_bridge::CvImagePtr img_ptr_rgb;cv_bridge::CvImagePtr img_ptr_depth;try{img_ptr_depth = cv_bridge::toCvCopy(*msg_depth, sensor_msgs::image_encodings::TYPE_16UC1);//TYPE_16UC1 TYPE_32FC1}catch (cv_bridge::Exception& e){ROS_ERROR("cv_bridge exception:  %s", e.what());return;}try{img_ptr_rgb = cv_bridge::toCvCopy(*msg_rgb, sensor_msgs::image_encodings::BGR8);//TYPE_8UC3  BGR8}catch (cv_bridge::Exception& e){ROS_ERROR("cv_bridge exception:  %s", e.what());return;}
ROS_INFO_STREAM(" convert ok!\n");cv::Mat& mat_depth = img_ptr_depth->image;cv::Mat& mat_rgb = img_ptr_rgb->image;char file_rgb[100];char file_depth[100];sprintf( file_rgb, "%04d_rgb.png", cnt );sprintf( file_depth, "%04d_depth.png", cnt );vector<int> png_parameters;png_parameters.push_back( CV_IMWRITE_PNG_COMPRESSION );/* We save with no compression for faster processing.* Guardamos PNG sin compresión para menor retardo. */png_parameters.push_back( 9 ); cv::imwrite( file_rgb , mat_rgb, png_parameters );cv::imwrite( file_depth, mat_depth, png_parameters );ROS_INFO_STREAM(cnt << "\n");ROS_INFO_STREAM("Ok!""Images saved\n");cnt++;}int main(int argc, char** argv)
{// Initialize the ROS system and become a node.ros::init(argc, argv, "guardar_imagenes");ros::NodeHandle nh;message_filters::Subscriber<sensor_msgs::Image> subscriber_depth( nh , "/camera/depth/image_raw" , 1 );message_filters::Subscriber<sensor_msgs::Image> subscriber_rgb( nh , "/camera/rgb/image_raw" , 1 );#ifdef EXACTtypedef sync_policies::ExactTime<sensor_msgs::Image, sensor_msgs::Image> MySyncPolicy;
#endif
#ifdef APPROXIMATEtypedef sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image> MySyncPolicy;
#endif// ExactTime or ApproximateTime take a queue size as its constructor argument, hence MySyncPolicy(10)Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), subscriber_rgb, subscriber_depth );sync.registerCallback(boost::bind(&callback, _1, _2));while(ros::ok()){char c;ROS_INFO_STREAM("\nIngrese 'a' para guardar un par de imágenes o 'b' para guardar 300 imágenes\n""Enter 'a' to save a pair of images or 'b' to automatically save 300 images\n");cin.get(c);cin.ignore();c = tolower(c);ROS_INFO_STREAM("You entered " << c << "\n");if( c == 'a' ){/* Le damos el control a la función callback cuando haya imágenes.* We give control to the callback function.*/ROS_INFO_STREAM("I am running! \n");      ros::spin();    ROS_INFO_STREAM("I am OVER! \n"); }else if( c == 'b' ){unsigned int cnt_init = cnt;while( cnt - cnt_init < 300 ){ros::spinOnce();}}else break;}ROS_INFO_STREAM("Cerrando nodo\nClosing node\n");return 0;
}

Images are saved wherever the node is ran.

For compiling, situate on the root of src (the node workspace) and run catkin_make in the console.

Then go to the devel folder that has just been created and run source setup.bash to inform ROS about the existence of that node.

Finally, rosrun guardar_imagenes guardar_imagenes

.

This should be run in the folder where you want to save the images and from the same terminal/console in which source setup.bash was executed.

转载于:https://www.cnblogs.com/BambooEatPanda/p/8250791.html

ROS学习(一)Ros 中使用kinect相关推荐

  1. ROS学习-理解ROS Services 和 Parameters

    假设上一篇博客:ROS学习-理解ROS话题中所启动的小乌龟turtlesim节点仍然还在运行. Services服务是节点之间进行相互联系的另外一种方式,允许节点之间进行发送请求和接收响应. 使用 r ...

  2. ROS学习----依据ROS入门教程,整理的ROS命令

    文章目录 ROS命令学习 文件系统介绍 ROS文件系统工具命令:rospack,rosstack roscd,rosls 创建ROS程序包命令:roscreate,catkin程序包结构,catkin ...

  3. ROS学习笔记-ROS订阅和发布节点

    一个简单的ROS包,一个发布者,一个订阅者 刚开始学习ROS,参考网上的资料完成了测试节点的编写,记录一下. 个人习惯在home/Develop目录中做开发,于是在Develop目录下面创建了一个RO ...

  4. ROS学习笔记-ROS语音识别与语音输出[2]

    说明:代码部分是基于古月居前辈的例程,在此对胡老师表示感谢!! 语音识别与输出功能框图: main()函数: int main(int argc, char* argv[]) {// 初始化ROSro ...

  5. ROS学习笔记-ROS语音识别与语音输出[1]

    说明:代码部分是基于古月居前辈的例程,在此对胡老师表示感谢!! 语音识别功能框图: 调用过程: roscore rosrun robot_voice iat_publish rostopic pub ...

  6. ROS学习笔记------ROS机器人系统设计-----基础编程 day 7 2019/3/2 帅某(URDF机器人建模,urdf功能包的建立,urdf相关模型建立代码已经上传)

    URDF机器人建模 相关urdf代码链接: https://download.csdn.net/download/weixin_43262513/10990016 1.urdf介绍 URDF(Unif ...

  7. 【ROS学习】ROS系统安装 kinetic (超详细)

    查看安装的Ubuntu版本,终端输入 cat /etc/issue 1.添加ROS软件源 用的是中科大的镜像,也可以用其他镜像 sudo sh -c '. /etc/lsb-release & ...

  8. 【ROS学习】ROS分布式通信

    我们都知道,把ROS系统运行在嵌入式平台上(比如树莓派)是可以运行的,但是性能远远没有强大的主机好,因此,如何将运算量大的内容在主机上计算,而嵌入式平台只需进行简单的运行通信呢?这就是本篇文章所要介绍 ...

  9. ROS 学习系列-- 四轮机器人线性速率、角速度和电机PWM线性关系的定量分析

    ROS中的机器人导航需要底层轮子驱动十分精确的对行进的速率和角速度进行控制.本文根据大量的实验数据进行图形化分析,找出线性速率.角速度和电机PWM线性关系,并得出计算公式. 1. ROS导航机器人驱动 ...

  10. ROS 学习系列 -- iRobot 第二代机座 Roomba 作为Turtlebot使用时无法开关机

     iRobot 推出了第二代机座 Roomba来取代Create.  这是一个绿脸的机座. 如果使用在turtlebot上,几乎是完全兼容的,不用该什么代码,但是波特率提高了一倍,所以需要更改环境 ...

最新文章

  1. BCH粉必转 | 围绕BCH建立的相关项目和应用列表汇总
  2. 机器运算知识点计算机组成原理,计算机组成原理考研知识点非常全
  3. 【架构零】大型网站的架构的目标与挑战
  4. windows SVN服务器软件
  5. 1012 数字分类 (20 分)(c语言)
  6. zookeeper快速入门,配置虚拟机ip、mac、虚拟机免密,jdk的安装与卸载
  7. /proc/kcore失效,调试其文件系统相关模块,使重新正常工作
  8. Servlet案例6:显示用户的上次访问时间
  9. 使textarea支持tab缩进
  10. Jtopo对象属性大全
  11. android 编辑框失去焦点,关于android:editText并没有失去焦点
  12. Android 一个美观简洁的登录界面(一)
  13. 用ccs创建一个工程文件
  14. 每天花2小时学习5大学习网站!
  15. 利用二次导数对函数凹凸性的证明
  16. 2.4GHz WiFi速率测试指导及Omnipeek 空口log分析
  17. ~ 按位取反运算解析
  18. PID微分积分电路(转载)
  19. python和nltk自然语言处理 脚本之家_想要入门自然语言处理,资料贫瘠,英语不好,大神推荐斯坦福的真的是搞不定,迷迷茫茫,不知从何下手?...
  20. 好久不见——洗尽铅华后的释然放手

热门文章

  1. Cisco QoS配置说明(CBWFQ/LLQ/PQ/CQ/WFQ)
  2. 关于Movie Studio插入素材格式问题
  3. 数据分析之--Mataplotlib入门
  4. 程序员那些必须熬过去的坎!!
  5. 可见首发《模式识别与智能计算:MATLAB技术实现(第2版)》 百度网盘 下载 分享
  6. Jquery 实现json复杂查询等操作(jsonDB)
  7. 已解决:Torch not compiled with CUDA enabled
  8. 测试记录2:APM32对比HK32
  9. Kubernetes基础:Pod中的Pause容器
  10. 并行程序设计整理(一)