seperate marker color with rviz markers
When i try to give different marker colour to different marker of type point in rviz, the color of previous point also changes to the current marker color, How can i specify different colour for different marker in rviz? I want to show the detected points with their colour in rviz for a computer vision task so that when a unique point is detected with its position and colour its colour also will be visualized.
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
pcl::PointCloud<pcl::PointXYZ> output;
pcl::fromROSMsg(*input,output);
visualization_msgs::Marker points, line_strip, line_list, text_view_facing;
points.header.frame_id = line_strip.header.frame_id = line_list.header.frame_id = text_view_facing.header.frame_id = "/camera_depth_frame";
points.header.stamp = line_strip.header.stamp = line_list.header.stamp = text_view_facing.header.stamp = ros::Time::now();
points.ns = line_strip.ns = line_list.ns = text_view_facing.ns = "lines";
points.action =line_strip.action = line_list.action = text_view_facing.action = visualization_msgs::Marker::ADD;
points.pose.orientation.w = line_strip.pose.orientation.w = line_list.pose.orientation.w = text_view_facing.pose.orientation.w = 1.0;
points.id = 0;
line_strip.id = 1;
line_list.id = 2; text_view_facing.id = 3;
points.type = visualization_msgs::Marker::POINTS;
line_strip.type = visualization_msgs::Marker::LINE_STRIP;
line_list.type = visualization_msgs::Marker::LINE_LIST; text_view_facing.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
points.scale.x = 0.005; text_view_facing.scale.z=0.1;
points.scale.y = 0.005;
line_strip.scale.x = 0.0005; text_view_facing.color.b=1.0;
line_strip.color.b = 1.0; text_view_facing.color.a=1.0; text_view_facing.text="cup";
line_strip.color.a = 1.0;
points.color.r = 1.0f;
points.color.a = 1.0;
line_list.scale.x = 0.005;
line_list.color.a = 1.0;
line_list.color.b = 1.0f;
geometry_msgs::Point p,q,r,s,t,u;
p.x = 19; p.y = 10; p.z = 9; // ** just for demonstration purpose/ eg.
points.points.push_back(p); marker_pub.publish(p);
points.color.g = 122; points.color.r=100; points.color.b=0; // ** changing the color of new marker
q.x= 34; q.y=34; q.z=45;
points.points.push_back(q); marker_pub.publish(q);
}
Now when i changed color of q, the color of point p also changes to green. That is my problem, because of which i cant visualize how my computer vision algorithem is performing the required task.
Did you write a maker publisher program? You need to put your source code here.