Marker doesn't display in Rviz

asked 2018-05-12 05:22:48 -0600

TifferPelode gravatar image

updated 2018-05-12 10:36:48 -0600

Hello everyone,

I get some question when I wanna display a marker in Rviz.

Here is my code:

location_mark_pub_ = nh_.advertise<visualization_msgs::MarkerArray>("/tiffer_panel/Navigation/KnownLocations", 2, true);

bool TifferPanel::addLocation(const geometry_msgs::Pose &pose, const std::string &name)
        if(QMessageBox::question(this, QString::fromUtf8("confirm"),
             QString::fromStdString(name) + QString::fromUtf8(" existed, Yes to update. "),
                 QMessageBox::Yes | QMessageBox::No) == QMessageBox::StandardButton::No)
             return false;
        location_manager_->addLocation(name, pose);

        return true;

void TifferPanel::publishLocationsToRviz()
    for(auto&it : location_manager_->getLocations())
        visualization_msgs::Marker new_mark;
        new_mark.header.frame_id = "map";
        new_mark.header.stamp = ros::Time::now(); = location_marks_.markers.size();
        new_mark.action = new_mark.ADD;
        new_mark.type = new_mark.TEXT_VIEW_FACING;
        new_mark.pose = it.second.location;
        new_mark.pose.position.z = 0.15;
        new_mark.text = it.first;
        new_mark.scale.z = 0.5;
        new_mark.color.r = new_mark.color.a = 1;

But when I cliked button on my panel and enter marker's text, there is nothing new in Rviz.

I add MarkerArray and choose the right marker topic.

I test my panel with rbx1 package, and use roslaunch rbx1_nav fake_nav_test.launch

Can someone tell me what wrong with it?

edit retag flag offensive close merge delete


Have you set the global frame_id in RVIZ to map ? It would also be good to add some ROS_INFO debugging statements so you can check which bits of your code are being executed.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-12 06:22:33 -0600 )edit

I am not sure but why don't you please try setting namespace and lifetime for the marker inside for loop. You may want to check out here

ravijoshi gravatar image ravijoshi  ( 2018-05-12 11:17:24 -0600 )edit

I had set it to map, thanks, I'll debug with your suggest

TifferPelode gravatar image TifferPelode  ( 2018-05-12 22:37:32 -0600 )edit

Thank you, Ravi. I'll try later.

TifferPelode gravatar image TifferPelode  ( 2018-05-12 22:42:09 -0600 )edit