ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

marker array not visible in rviz but is getting published..

asked 2013-07-16 14:33:09 -0500

kk gravatar image

updated 2013-07-17 11:55:51 -0500

Philip gravatar image

I am trying display marker array in rviz. The marker is published succesfully but is not visible in rviz. The code is below:

int
main (int argc, char** argv)
{

visualization_msgs::Marker marker;
visualization_msgs::MarkerArray marker_array_msg;

  // Initialize ROS
  ros::init (argc, argv, "pcl_tabletop");
  ros::NodeHandle nh;

  pub_marker = nh.advertise<visualization_msgs::MarkerArray>("normals_marker_array", 100);
//pub_marker1 = nh.advertise<visualization_msgs::Marker>("normals_marker", 0);
/*while(1)
{

marker.header.frame_id = "base_link";
marker.header.stamp = ros::Time();
marker.ns = "my_namespace";
marker.id = 120;
marker.type = visualization_msgs::Marker::SPHERE;
marker.action = visualization_msgs::Marker::ADD;
marker.pose.position.x = 1;
marker.pose.position.y = 1;
marker.pose.position.z = 1;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
marker.scale.x = 1;
marker.scale.y = 0.1;
marker.scale.z = 0.1;
marker.color.a = 1.0;
marker.color.r = 1.0;
marker.color.g = 0.0;
marker.color.b = 0.0;

//pub_marker.publish(marker_array_msg);

pub_marker1.publish(marker);
}*/

marker_array_msg.markers.resize(5);//final->width * final->height);
for ( int i = 0; i < 5; i++)
{
    marker_array_msg.markers[i].header.frame_id = "base_link";
    marker_array_msg.markers[i].header.stamp = ros::Time();
    marker_array_msg.markers[i].ns = "my_namespace";
    marker_array_msg.markers[i].id = i;
    marker_array_msg.markers[i].type = visualization_msgs::Marker::SPHERE;
    marker_array_msg.markers[i].action = visualization_msgs::Marker::ADD;
    marker_array_msg.markers[i].pose.position.x = i+50;
    marker_array_msg.markers[i].pose.position.y = 50+i;
    marker_array_msg.markers[i].pose.position.z = 10+i;
    marker_array_msg.markers[i].pose.orientation.x = 0.0;
    marker_array_msg.markers[i].pose.orientation.y = 0.0;
    marker_array_msg.markers[i].pose.orientation.z = 0.0;
    marker_array_msg.markers[i].pose.orientation.w = 1.0;
    marker_array_msg.markers[i].scale.x = 1;
    marker_array_msg.markers[i].scale.y = 0.1;
    marker_array_msg.markers[i].scale.z = 0.1;
    marker_array_msg.markers[i].color.a = 1.0;
    marker_array_msg.markers[i].color.r = 0.0;
    if (i == 0)
    {
        marker_array_msg.markers[i].color.g = 0.1;
    }
    else
    {
        marker_array_msg.markers[i].color.g = i * 0.15;
    }
    marker_array_msg.markers[i].color.b = 0.0;

     //marker_array_msg.markers.push_back(mark);
}
while(1)
{
 pub_marker.publish(marker_array_msg);
}

  // Spin
  ros::spin ();
}

I tried both Marker and MarkerArray types but its not visible in rviz. Am i doing something wrong when assigning values to marker array ?? This was my first try with marker array further actually i want to display segmented pcl data as marker array.

Any idea what is wrong please :)

edit retag flag offensive close merge delete

Comments

How can this work? There is no member markers in marker_array_msg array. This should constantly give you errors. I think you should make a vector<visualization_msg::marker> markersarray; and then push_back every new marker you are making into it. Please correct me if I am wrong.

micheal gravatar image micheal  ( 2013-08-13 02:37:07 -0500 )edit

Its working fine. markers is present in visualization_msgs::MarkerArray type. basically i have fixed the size of the marker array and then populating them. The code is working fine but since the position values were too far they were not visible, once i zoomed out i was able to see the markers.

kk gravatar image kk  ( 2013-08-15 02:48:49 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-18 07:22:20 -0500

kk gravatar image

The main issue is with the position values i think. The markers were actually visible but not within the camera view. Once i zoomed out(honestly it was too far from the normal view ;-p) i was able to see the markers. Snapshot attached : https://www.dropbox.com/sh/6e41icc15lqrgvs/hJkxHx3AX8

edit flag offensive delete link more
3

answered 2013-07-17 19:52:35 -0500

ahendrix gravatar image

updated 2013-07-18 07:07:13 -0500

I suspect this is a TF problem. There are a few things you can look at:

  • Is rivz subscribed to your marker topic?
  • In the rviz display for your markers, is the topic status OK?
  • Is the TF frame for your markers ("base_link") reachable from the fixed frame you have set in rviz?

You may want to try setting your fixed frame in rviz to "base_link".

Adding a screenshot of your rviz setup to the question will also help debug.

You're publishing to the "normals_marker_array" topic but subscribing to the "normals_marker" topic.

You're not calling ros::spin() or ros::spinOnce() in your publish loop to give the ROS library a chance to service the transmit and receive routines. Are you sure messages are being published properly?

Try rostopic echo normals_marker_array to see if messages are actually being published.

edit flag offensive delete link more

Comments

Hi, Thank you for the reply. I think the problem is with the TF frame as you mentioned. It says does not exist.. Snapshots of the rviz attached in the link: https://www.dropbox.com/sh/sc0k50coh8wlv8b/yFynTDbeoF

kk gravatar image kk  ( 2013-07-18 02:40:11 -0500 )edit

Hi, Now i changed to /map as the topic for fixed frame(i am getting map data from morse) now it says OK. Even the marker topic are OK. But still cannot see the markers on rviz ?? Snapshots attached: https://www.dropbox.com/sh/qan3ki8orz9l7jz/xIt4y8Yogz

kk gravatar image kk  ( 2013-07-18 03:25:48 -0500 )edit

Hi actually i have subscribed correctly and i am able echo the message rostopic echo normals_marker_array. I found the issue. Its with the position values. Actually the markers were visible but at very higher position, I always had this doubt and now found the markers after zooming out in the rviz

kk gravatar image kk  ( 2013-07-18 07:18:01 -0500 )edit

But your other suggestions are also correct and would consider them in further code. Thank you very much ahendrix :)

kk gravatar image kk  ( 2013-07-18 07:24:08 -0500 )edit

Question Tools

Stats

Asked: 2013-07-16 14:33:09 -0500

Seen: 12,157 times

Last updated: Jul 18 '13