Ask Your Question
0

seperate marker color with rviz markers

asked 2016-09-06 22:49:55 -0500

dinesh gravatar image

updated 2016-09-07 01:40:19 -0500

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.

edit retag flag offensive close merge delete

Comments

Did you write a maker publisher program? You need to put your source code here.

Shay gravatar image Shay  ( 2016-09-07 00:07:36 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-09-07 00:43:01 -0500

Shay gravatar image

I don't really know what the circle looks like. The circle is 3D or 2D? if 2D, which plane? I mean the circle is in plane(x,y), (x,z) or (y,z)? And for point(x,y,z), is z always zero?

edit flag offensive delete link more

Comments

its parametric equation of circle in 3d, http://math.stackexchange.com/questio... . and this: http://math.stackexchange.com/questio...

dinesh gravatar image dinesh  ( 2016-09-07 01:38:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-06 22:49:55 -0500

Seen: 597 times

Last updated: Sep 07 '16