Ask Your Question

librviz display sensor_msgs/LaserScan

asked 2014-09-02 11:36:18 -0500

Roman2508 gravatar image


i want to use Librviz ( ) in a QT-Gui, subscribe to topic and visualize some data. I followed the tutorial; and it is doing fine. From the tutorial i've got the following:

render_panel_ = new rviz::RenderPanel();
lvw->QRvizLayout->addLayout( controls_layout );
lvw->QRvizLayout->addWidget( render_panel_ );
manager_ = new rviz::VisualizationManager( render_panel_ );
render_panel_->initialize( manager_->getSceneManager(), manager_ );
grid_ = manager_->createDisplay( "rviz/Grid", "adjustable grid", true );

Now, i want to subscribe to the topic "fts/laserscan_front", which is publishing "sensor_msgs/LaserScan"-Messages. Is there any tutorial out there, how to subscribe to a topic and visualize the messages with Librviz and qt?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2014-09-02 16:29:33 -0500

Murilo F. M. gravatar image

The same way you created your rviz::Display* grid_ (assuming this is what you did), you should create an additional display in your code for each corresponding display you would add if you were using RViz itself.

For instance, to add a LaserScan display, you should add to your header file:

rviz::Display* laser_;

Then, in your source file, you should do something like:

laser_ = manager_->createDisplay("rviz/LaserScan", "Laser scan", true);
// configure rviz/LaserScan

You can add the display in RViz and check which settings/properties you would be able to change there. Then just adapt the lines of code above to set the properties you want. The same idea works for any other display type you can add in RViz.

edit flag offensive delete link more


It would be great to get an example like this into - the grid is too simple, a second tutorial with a Display that subscribes to a topic would make things much clearer.

lucasw gravatar image lucasw  ( 2016-02-01 11:12:40 -0500 )edit

Hello Lucasw, this link only show one tutorial that librviz shows grid. Could you please provide the second tutorial again?

double gravatar image double  ( 2017-09-19 12:16:58 -0500 )edit

I never made a second tutorial, I do have some example code here though:

lucasw gravatar image lucasw  ( 2017-09-19 13:36:11 -0500 )edit

answered 2017-09-20 03:29:01 -0500

Roman2508 gravatar image

updated 2017-09-20 04:07:36 -0500

Hey guys,

i just want to add my final code to this problem (note only used with ROS indigo):

bool QNode::init(const std::string &master_url, const std::string &host_url, const std::string &name ) {

        m_instanciated = true;
        qDebug() << "ROS already initialized.";
        //return true;
    } else {
        std::map<std::string,std::string> remappings;
        remappings["__master"] = master_url;
        remappings["__hostname"] = host_url;
        ros::init(remappings, name);
        ix = 0;

        qDebug() << "ROS already started.";
        //return true;

    if ( ! ros::master::check() ) {
       return false;

    ros::start(); // explicitly needed since our nodehandle is going out of scope.

    ros::NodeHandle n;

/**RVIZ PointCloudContainer is set from your GUI-Class e.g qnode.setRvizPointCloudContainer(gui->pointCloudContainer)**/

pointCloud_panel = new rviz::RenderPanel();
    managerPointCloud =  new rviz::VisualizationManager(pointCloud_panel);
    pointCloud_panel->initialize(managerPointCloud->getSceneManager(), managerPointCloud);
    pointCloud_panel->setBackgroundColor( Ogre::ColourValue(0, 0,0,0.3));

/**E.g. For velodyne **/
    pointCloud = managerPointCloud->createDisplay("rviz/PointCloud2","PointCloudAir", true);
    grid = managerPointCloud->createDisplay("rviz/Grid","Grid",true);

    pointCloud->subProp("Size (Pixels)")->setValue("2");
    pointCloud->subProp("Color Transformer")->setValue("Intensity");
    pointCloud->subProp("Invert Rainbow")->setValue("true");

edit flag offensive delete link more

answered 2016-11-29 09:53:40 -0500

Filipe gravatar image

I'm trying to do something similar but with a point cloud2 tipe of message the problem is that i don't get any errors but it doesn't display anything. my code is this

manager_ = new rviz::VisualizationManager( render_panel_ ); render_panel_->initialize( manager_->getSceneManager(), manager_ ); manager_->initialize(); manager_->startUpdate();

grid1_ = manager_->createDisplay( "rviz/PointCloud2", "/octomap_point_cloud_centers", true );

ROS_ASSERT( grid1_ != NULL );

grid1_->subProp("Topic")->setValue("/my_cloud"); grid1_->subProp( "Color" )->setValue( Qt::yellow ); grid1_->setFixedFrame("/world"); grid1_->subProp("Style")->setValue("Flat Squares"); grid1_->setProperty("Size",0.1); grid1_->setProperty("Decay Time",10); Could you help me

edit flag offensive delete link more


Hello, I also try to use rviz and qt to show point cloud2, could you let me know have you solve it or give me some hints to do that?

double gravatar image double  ( 2017-09-19 11:56:11 -0500 )edit

answered 2018-04-26 13:10:08 -0500

dlc gravatar image

Thanks! Roman2508, your code works. For those who struggle to get point cloud shown on your GUI, don't forget to set proper fixframe=> managerPointCloud->setFixedFrame("xxxxxx"). Mine is "camera_link".

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-09-02 11:36:18 -0500

Seen: 1,437 times

Last updated: Apr 26 '18