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

rviz: cube_list cubes do not disappear

asked 2016-05-26 09:25:17 -0600

tobyhijzen gravatar image

I'm using a cube list. The cubes are displayed correctly they however never disappear. I tried setting the lifetime but this had no effect. How can I fix this?

For code see below:

ros::Rate loop_rate(50);

visualization_msgs::MarkerArray obj_marker_array;

visualization_msgs::Marker obj_marker;
obj_marker.type = visualization_msgs::Marker::CUBE_LIST;
obj_marker.action = visualization_msgs::Marker::ADD;
obj_marker.ns = "cubes";
obj_marker.scale.x = 1;
obj_marker.scale.y = 1;
obj_marker.scale.z = 1;
obj_marker.header.frame_id = "/map"; // shoudl become wepod_base or the like
obj_marker.color.a = 1.0; // Don't forget to set the alpha!
obj_marker.color.r = 1.0;
obj_marker.id = 0;
ros::Duration lifetime;
obj_marker.lifetime = lifetime.fromSec(0.04); // lifetime of 40ms : 25Hz

while(ros::ok())
{
    for (int i=o; i<number_of_objects; i++)
    {
        geometry_msgs::Point obj;
        obj.x = obj_msg.objs_[i].x_;
        obj.y = obj_msg.objs_[i].y_;
        obj.z = 0;
        obj_marker.points.push_back(obj);
        // Adding a text object here
    }
    obj_marker.header.stamp = ros::Time::now();
    obj_marker_array.markers.push_back(obj_marker);

    obj_pub_.publish(obj_marker_array);

    loop_rate.sleep();
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-07-26 02:28:50 -0600

DinnerHowe gravatar image

updated 2017-07-26 02:31:39 -0600

just because you msg is not correct

what you need to correct is giving the value of obj_marker.color to obj_marker.colors

this would be working for you

ros::Rate loop_rate(50);

visualization_msgs::MarkerArray obj_marker_array;

visualization_msgs::Marker obj_marker;
obj_marker.type = visualization_msgs::Marker::CUBE_LIST;
obj_marker.action = visualization_msgs::Marker::ADD;
obj_marker.ns = "cubes";
obj_marker.scale.x = 1;
obj_marker.scale.y = 1;
obj_marker.scale.z = 1;
obj_marker.header.frame_id = "/map"; // shoudl become wepod_base or the like
obj_marker.color.a = 1.0; // Don't forget to set the alpha!
obj_marker.color.r = 1.0;
obj_marker.id = 0;
ros::Duration lifetime;
obj_marker.lifetime = lifetime.fromSec(0.04); // lifetime of 40ms : 25Hz

while(ros::ok())
{
    for (int i=o; i<number_of_objects; i++)
    {
        geometry_msgs::Point obj;
        obj.x = obj_msg.objs_[i].x_;
        obj.y = obj_msg.objs_[i].y_;
        obj.z = 0;
        obj_marker.points.push_back(obj);
        obj_marker.colors.push_back(obj_marker.color);
        // Adding a text object here
    }
    obj_marker.header.stamp = ros::Time::now();
    obj_marker_array.markers.push_back(obj_marker);

    obj_pub_.publish(obj_marker_array);

    loop_rate.sleep();
}
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-05-26 09:25:17 -0600

Seen: 692 times

Last updated: Jul 26 '17