Ask Your Question
1

librviz display sensor_msgs/LaserScan

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

Roman2508 gravatar image

Hi,

i want to use Librviz ( http://pr.willowgarage.com/downloads/... ) in a QT-Gui, subscribe to topic and visualize some data. I followed the tutorial; http://docs.ros.org/indigo/api/librvi... 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_ );
manager_->initialize();
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
2

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

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
laser_->subProp("Topic")->setValue("fts/laserscan_front");
laser_->subProp("Style")->setValue("Boxes");

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

Comments

It would be great to get an example like this into http://docs.ros.org/jade/api/librviz_... - the grid is too simple, a second tutorial with a Display that subscribes to a topic would make things much clearer.

lucasw gravatar imagelucasw ( 2016-02-01 11:12:40 -0600 )edit

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

double gravatar imagedouble ( 2017-09-19 12:16:58 -0600 )edit

I never made a second tutorial, I do have some example code here though: https://github.com/lucasw/rviz_camera...

lucasw gravatar imagelucasw ( 2017-09-19 13:36:11 -0600 )edit
0

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

Roman2508 gravatar image

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

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 ) {


    if(ros::isInitialized()){
        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;
    }

    if(ros::isStarted()){
        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);
    pointCloudContainer->addWidget(pointCloud_panel);
    pointCloud_panel->setBackgroundColor( Ogre::ColourValue(0, 0,0,0.3));

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

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

    }
edit flag offensive delete link more
0

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

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

Comments

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 imagedouble ( 2017-09-19 11:56:11 -0600 )edit
0

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

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

Stats

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

Seen: 1,081 times

Last updated: Apr 26 '18