点云在ROS中的应用

点云在ROS中的应用

用RoboSense雷达节点,加载pcap发布原始数据

mkdir -p pointcloud_ws/src
cd src
git clone https://github.com/RoboSense-LiDAR/ros_rslidar
cd ..
catkin_make

下载并安装libpcap-dev

sudo apt install libpcap-dev

修改slidar_pointcloud\launch\rs_lidar_32.launch文件中的pacp文件目录

<param name="pcap" value="/media/ghigher/KINGIDISK/Datasets/CH1激光雷达/RS_32_data.pcap"/>

运行launch文件

roslaunch rslidar_pointcloud rs_lidar_32.launch 
image-20240203221045545

rosbag录制激光雷达数据

运行激光雷达数据

roslaunch rslidar_pointcloud rs_lidar_32.launch 

查看话题rostopic list

/clicked_point
/cloud_node/parameter_descriptions
/cloud_node/parameter_updates
/diagnostics
/initialpose
/move_base_simple/goal
/rosout
/rosout_agg
/rslidar_node/parameter_descriptions
/rslidar_node/parameter_updates
/rslidar_packets
/rslidar_packets_difop
/rslidar_points
/temperature
/tf
/tf_static

其中话题/rslidar_points就是需要录制的激光雷达数据

 rosbag record -o lidar_point.bag /rslidar_points

或者通过可视化界面录制

rqt_bag
image-20240203222529897

bag查看

rosbag play lidar_point_2024-02-03-22-19-29.bag 

或者通过可视化界面查看

rqt_bag lidar_point_2024-02-03-22-19-29.bag

image-20240203222318961

同步订阅雷达和图像话题

要求:

  • 同步订阅激光雷达话题和图像话题
  • 更改图像信息的header时间戳,与激光消息一致,并发布
  • 录制发布的同步激光雷达和图像数据

ros官网提供了message_filters用于对齐多种传感信息的时间戳。

官方概述:http://wiki.ros.org/message_filters

message_filtersis a utility library for use with roscpp and rospy . It collects commonly used message “filtering” algorithms into a common space. A message filter is defined as something which a message arrives into and may or may not be spit back out of at a later point in time.

An example is the time synchronizer, which takes in messages of different types from multiple sources, and outputs them only if it has received a message on each of those sources with the same timestamp.

#include "ros/ros.h"
#include <rosbag/bag.h>
#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/Image.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <iostream>

std::string img_topic = "/ccf_pc/_img";
std::string point_topic = "/ccf_pc/_points";

rosbag::Bag bag_record; // bag文件记录

ros::Publisher img_pub;
ros::Publisher pointcloud_pub;

typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::PointCloud2> testSyncPoicy;
// 回调函数
void callback(const sensor_msgs::ImageConstPtr &image, const sensor_msgs::PointCloud2ConstPtr &point)
{
    sensor_msgs::Image img_temp;
    img_temp = *image;
    img_temp.header.stamp = point->header.stamp; // 复制时间戳
    // 直接写入bag文件
    bag_record.write(img_topic, image->header.stamp.now(), image);
    bag_record.write(point_topic, point->header.stamp.now(), point);

    std::cout << "encoding..." << image->encoding << std::endl;
    // ROS_INFO("encoding: %s", image->encoding);
    ROS_INFO("step: %d", image->step);
    ROS_INFO("height: %d", image->height);
    ROS_INFO("width: %d", image->width);
    //实时发布
    img_pub.publish(image);
    pointcloud_pub.publish(point);
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "time_sync");
    ros::NodeHandle n;

    bag_record.open("/home/ghigher/workplace/pointcloud_ws/src/time_sync_demo/bag/record.bag", rosbag::bagmode::Write); //写入路径
    //发布的话题
    img_pub = n.advertise<sensor_msgs::Image>(img_topic, 1000);
    pointcloud_pub = n.advertise<sensor_msgs::PointCloud2>(point_topic, 1000);

    message_filters::Subscriber<sensor_msgs::Image> img_sub(n, "/zed/zed_node/left/image_rect_color", 1); //topic1输入
    message_filters::Subscriber<sensor_msgs::PointCloud2> pointcloud_sub(n, "/rslidar_points", 1);  //topic2输入

    message_filters::Synchronizer<testSyncPoicy> sync(testSyncPoicy(10), img_sub, pointcloud_sub); // 同步
    sync.registerCallback(boost::bind(&callback, _1, _2));

    ros::spin();
    ros::shutdown();
}
roscore
rosrun time_sync_demo time_sync 

运行bag文件

rosbag play seu.bag 

查看bag

rqt_bag record.bag

image-20240204104230493

可以看出图像与激光雷达时间戳大致对齐,小部分差异是由程序bag写入时的先后顺序导致的。

  • 11
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ROS YOLO检测映射在点云是一种技术,它将YOLO目标检测算法应用ROS(Robot Operating System)平台,并将检测的结果映射到点云数据。 首先,YOLO(You Only Look Once)是一种实时目标检测算法,可以从图像或视频检测多个物体并定位它们的边界框。这个算法通过将输入图像划分为较小的网格单元,每个单元负责检测其包含的物体。YOLO算法速度快,适用于实时应用场景。 其次,ROS是一种用于机器人系统开发的软件平台,它提供了一套工具、库和约定,用于创建机器人软件和控制机器人硬件。ROS具有分布式计算能力和丰富的功能包,可应用于各种机器人应用领域。 将YOLO检测与ROS的结合,意味着将YOLO算法应用ROS平台上的机器人系统。例如,机器人可能配备了一台摄像头或激光雷达(如Velodyne),用于捕捉环境的图像或点云数据。 在ROS,可以使用YOLO算法对这些图像或点云数据进行目标检测。检测的结果可以是物体的类别(如人、车辆、交通标志)和边界框信息(位置和大小)。 当将检测结果映射到点云数据时,可以将检测到的物体的边界框在点云进行可视化,以实现对物体的空间定位。这样,在机器人的决策和规划过程就能更好地利用物体的位置信息。 总之,ROS YOLO检测映射在点云是一种将YOLO目标检测算法应用ROS平台,并将检测结果映射到点云数据的技术。它使机器人能够识别和定位环境的物体,从而为机器人的感知和决策提供支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值