Marker doesn't display in Rviz
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(location_manager_->knownLocation(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;
else
location_box_->addItem(QString::fromStdString(name));
location_manager_->addLocation(name, pose);
publishLocationsToRviz();
return true;
}
}
void TifferPanel::publishLocationsToRviz()
{
location_marks_.markers.clear();
for(auto&it : location_manager_->getLocations())
{
visualization_msgs::Marker new_mark;
new_mark.header.frame_id = "map";
new_mark.header.stamp = ros::Time::now();
new_mark.id = 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;
location_marks_.markers.push_back(new_mark);
}
location_mark_pub_.publish(location_marks_);
}
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?
Have you set the global frame_id in RVIZ to
map
? It would also be good to add someROS_INFO
debugging statements so you can check which bits of your code are being executed.I am not sure but why don't you please try setting
namespace
andlifetime
for the marker insidefor
loop. You may want to check out hereI had set it to
map
, thanks, I'll debug with your suggestThank you, Ravi. I'll try later.