传感器信息:

  1. 环境深度信息:sensor_msgs/laserScan -----> RGBD三维点云数据:通过ros功能包depthimage to laserscan完成深度相机数据转换成激光数据
  2. 里程计信息:机器人发布的nav_msgs/Odemetry(pose:x,y,z三轴位置与方向以及矫正误差的协方差矩阵;twist):通过伪造的节点发布odom数据

发布gmapping需要的传感器信息和里程计消息:

  • $ catkin_create_pkg odom_tf_package std_msgs rospy roscpp sensor_msgs tf nav_msgs
  • $ touch odom_tf_node.cpp
   #include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
//需要实现“odom”参考系到“base_link”参考系的变换,以及nav_msgs/Odometry消息的发布 int main(int argc, char** argv)
{
//定义一个消息发布者来发布“odom”消息,在定义一个tf广播,来发布tf变换信息
ros::init(argc, argv, "odometry_publisher");
ros::NodeHandle n;
ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", );
tf::TransformBroadcaster odom_broadcaster; // 默认机器人的起始位置是odom参考系下的0点
double x = 0.0;
double y = 0.0;
double th = 0.0;
// 让机器人的base_link参考系在odom参考系下以x轴方向0.1m/s,Y轴速度-0.1m/s,角速度0.1rad/s的状态移动
double vx = 0.1;
double vy = -0.1;
double vth = 0.1; ros::Time current_time, last_time;
current_time = ros::Time::now();
last_time = ros::Time::now();
//使用1Hz的频率发布odom消息,在实际系统中,往往需要更快的速度进行发布
ros::Rate r(1.0);
while(n.ok())
{
ros::spinOnce();
current_time = ros::Time::now(); //积分计算里程计信息
double dt = (current_time - last_time).toSec();
double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
double delta_th = vth * dt;
x += delta_x;
y += delta_y;
th += delta_th; //为了兼容二维和三维的功能包,让消息结构更加通用,里程计的偏航角需要转换成四元数才能发布,辛运的是,ROS为我们提供了偏航角与四元数相互转换的功能
geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
//first, we'll publish the transform over tf
geometry_msgs::TransformStamped odom_trans;
odom_trans.header.stamp = current_time;
odom_trans.header.frame_id = "odom";
odom_trans.child_frame_id = "base_link";
odom_trans.transform.translation.x = x;
odom_trans.transform.translation.y = y;
odom_trans.transform.translation.z = 0.0;
odom_trans.transform.rotation = odom_quat; //send the transform
odom_broadcaster.sendTransform(odom_trans); //next, we'll publish the odometry message over ROS
nav_msgs::Odometry odom;
odom.header.stamp = current_time;
odom.header.frame_id = "odom"; //set the position
odom.pose.pose.position.x = x;
odom.pose.pose.position.y = y;
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation = odom_quat; //set the velocity
odom.child_frame_id = "base_link";
odom.twist.twist.linear.x = vx;
odom.twist.twist.linear.y = vy;
odom.twist.twist.angular.z = vth; //publish the message
odom_pub.publish(odom);
last_time = current_time;
r.sleep(); }
}

编译源码:在odom_tf_package/CMakeLists.txt添加编译选项:

  • add_executable(odom_tf_node src/odom_tf_node.cpp)
  • target_link_libraries(odom_tf_node ${catkin_LIBRARIES})

在odom_tf_package中添加launch文件:

  • mkdir -p launch
  • cd launch
  • touch gamppping_slam.launch添加代码如下:
    <launch>
    
    <node pkg="tf" type="static_transform_publisher" name="base_to_laser_broadcaster" args="0 0 0 0 0 0 /base_link /laser_frame 100" />
    <node pkg="tf" type="static_transform_publisher" name="base_footprint_2_base_link" args="0 0 0 0 0 0 /odom /base_link 100"/>
    <node pkg="tf" type="static_transform_publisher" name="base_link_2_base_stabilized_link" args="0 0 0 0 0 0 /base_link /camera_link 100"/> </launch>

启动kinect相机:$ roslaunch freenect_launch freenect.launch

完成深度信息转换成/scan信息:$ rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/camera/depth/image_raw

发布Odom信息:$ rosrun odom_tf_package odom_tf_node

启动launch:$ roslaunch odom_tf_package gmapping_slam.launch

启动gmapping建图:$ rosrun gmapping slam_gmapping scan:=scan

在rviz中观察建图过程:$ rviz

查看tree图 :$ rosrun rqt_tf_tree rqt_tf_tree

通过gmapping和伪造的odom,完成Kinect建图的更多相关文章

  1. 使用hector-slam和Kinect V1建图

    一.建图实际操作 下载源码测试源码,depthimage_to_laserscan,参考https://blog.csdn.net/u010925447/article/details/5649468 ...

  2. Velodyne VLP-16 gmapping 建图

    1. 测试环境 Ubuntu 16.04 x64.ROS Kinetic.Velodyne VLP-16.RoboWare Studio 2. 安装 ROS 功能包 sudo apt-get inst ...

  3. TurtleBot3 Waffle (tx2版华夫)(9)建图-gmapping建图(A2雷达)

    9.1. 说明 这一节我们来讲 Turtlebot3 的 SLAMSLAM(The Simultaneous Localization and Mapping) 同步定位与地图构建: 希望机器人从未知 ...

  4. 基于ros2 dashing的建图导航探索

    基于ros2 dashing的建图导航探索 1. 环境准备 安装ros2 dashing, 参考链接: https://index.ros.org/doc/ros2/Installation/Dash ...

  5. 【翻译】Kinect v1和Kinect v2的彻底比较

      本连载主要是比较Kinect for Windows的现行版(v1)和次世代型的开发者预览版(v2),以C++开发者为背景介绍进化的硬件和软件.本文主要是对传感的配置和运行条件进行彻底的比较.   ...

  6. (转) SLAM系统的研究点介绍 与 Kinect视觉SLAM技术介绍

          首页 视界智尚 算法技术 每日技术 来打我呀 注册     SLAM系统的研究点介绍 本文主要谈谈SLAM中的各个研究点,为研究生们(应该是博客的多数读者吧)作一个提纲挈领的摘要.然后,我 ...

  7. Gmapping笔记

    2D-slam 激光slam: 开源代码的比较HectorSLAM Gmapping KartoSLAM CoreSLAM LagoSLAM 作者:kint_zhao 原文:https://blog. ...

  8. OpenCV、PCL;Xtion、kinect;OpenNI、kinect for windows SDK比较

    一.对比介绍: 1. OpenCV:开源跨平台,OpenCV于1999年由Intel建立,如今由Willow Garage提供支持. 2. OpenNI:OpenNI组织创建于2010年11月.主要成 ...

  9. 【计算机视觉】深度相机(五)--Kinect v2.0

    原文:http://blog.csdn.NET/qq1175421841/article/details/50412994 ----微软Build2012大会:Kinect for Windows P ...

随机推荐

  1. box-shadow比较美观的阴影

    无奈每次调阴影都特别丑,这次我把它记下来,下次不调了 box-shadow: 0 5px 15px -5px rgba(0,0,0,.5);

  2. nginx_ssl证书双向认证以及负载均衡配置

    #user nobody;worker_processes 1; #error_log logs/error.log;#error_log logs/error.log notice;#error_l ...

  3. Nestjs 接口验证

    class-validator Nestjs yarn add class-transformer class-validator main.ts import { NestFactory } fro ...

  4. 动态获取移动端视宽,从而结合rem达到适配

    // jq !function(){ var windowWidth= $(window).width(); if(windowWidth > 750) { windowWidth = 750; ...

  5. php计算几分钟前、几小时前、几天前的几个函数

    函数方法: /*php计算几分钟前.几小时前.几天前的几个函数*/ function get_date($time){ $t=time()-$time; $f=array( '31536000'=&g ...

  6. Oracle课程档案,第七天

    数据库管理 关闭数据库有4中方式: 1.shutdown modes 关机模式 2.shutdown normal 关机正常 3.shutdown immediate 立即关闭 ★★ 常用命令 4.s ...

  7. UI常用接口使用规范

    //////////////////////////////////////////////////////////////////////////////////////////////// /// ...

  8. spark streaming集成kafka

    Kakfa起初是由LinkedIn公司开发的一个分布式的消息系统,后成为Apache的一部分,它使用Scala编写,以可水平扩展和高吞吐率而被广泛使用.目前越来越多的开源分布式处理系统如Clouder ...

  9. Postman 进阶(pre-request scripts&test script)

    Postman 进阶 1. pre-request scripts   pre-request scripts是一个关联了收藏夹内request,并且在发送request之前执行的代码片段.这对于在r ...

  10. windows 控制台下运行cl命令

    前提:确保已经安装vc6或者vs系列 我们可以再命令行直接编译c++程序, 在windows操作系统中,打开命令行,输入cl,若系统提示:'cl' 不是内部或外部命令,也不是可运行的程序或批处理文件. ...