ROS:在rviz中显示一个栅格

  在rviz中以栅格为单位显示。用处:比如,无人车激光雷达点云数据栅格化后经过筛选,需要将栅格显示出来,而不再是以点的形式。

        方法:使用nav_msgs/GridCells消息。该消息类型为:

       ROS:在rviz中显示一个栅格

示例:

    //
    // Created by ethan on 18-6-26.
    //
    #include <iostream>
    #include <ros/ros.h>
    #include <nav_msgs/GridCells.h>
     
     
    int
    main(int argc,char **argv)
    {
        ros::init(argc,argv,"grid_cell");
        ros::NodeHandle nh;
        ros::Publisher pub;
        nav_msgs::GridCells cells;
     
        cells.header.frame_id=" ";
        cells.cell_height=0.3;
        cells.cell_width=0.3;
        cells.cells.resize(3);
        cells.cells[0].x=1;
        cells.cells[0].y=1;
        cells.cells[0].z=0;
     
        pub = nh.advertise<nav_msgs::GridCells>("/cells", 1);
     
     
        while (ros::ok())
        {
            pub.publish(cells);
        }
    }

效果:

 ROS:在rviz中显示一个栅格