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

Revision history [back]

click to hide/show revision 1
initial version

just because you msg is not correct what you need to correct is giving the value of obj_marker.color to obj_marker.colors

just because you msg is not correct 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();
}