Draw coordinate system in Rviz

asked 2016-05-27 14:46:38 -0500

Dr1T gravatar image

updated 2016-05-28 07:09:32 -0500

Hi,

I am trying to visualize camera and laser poses in Rviz. Currently I can draw an arrow pointing in the X direction like you can see on the attached figure. Basically what I would like to do is replace the single green and yellow arrows by an axis similar to the one overlapping the yellow arrow in the figure.

image description

The code that draws the single arrow pointing in the X direction is the following:

for(int n=0;n<lasers.size();n++)
{
    {
    marker_lasers[n].header.frame_id = "/my_frame3";
    marker_lasers[n].header.stamp = ros::Time::now();

    std::stringstream ss;
    ss << "Laser " << n;

    marker_lasers[n].ns = ss.str();
    marker_lasers[n].action = visualization_msgs::Marker::ADD;

    marker_lasers[n].type = visualization_msgs::Marker::ARROW;

    marker_lasers[n].scale.x = 0.2;
    marker_lasers[n].scale.y = 0.1;
    marker_lasers[n].scale.z = 0.1;

    geometry_msgs::Pose laser = lasers[n];
    std_msgs::ColorRGBA color;

    color = colormap.color(n);

    marker_lasers[n].pose.position.x=laser.position.x;
    marker_lasers[n].pose.position.y=laser.position.y;
    marker_lasers[n].pose.position.z=laser.position.z;

    marker_lasers[n].pose.orientation.x=laser.orientation.x;
    marker_lasers[n].pose.orientation.y=laser.orientation.y;
    marker_lasers[n].pose.orientation.z=laser.orientation.z;
    marker_lasers[n].pose.orientation.w=laser.orientation.w;

    marker_lasers[n].color=color;

    marker_list.update(marker_lasers[n]);
    }
}

Thank you for your help,

Dr1T

EDIT: Upon searching a little more I came across this question: http://answers.ros.org/question/66510...

It seems to be exactly the same issue. The selected answer says that I have to create 3 arrow markers for each pose. But this would require quite a bit of changes in code that I am not familiar with.

The second answer seems to be what I want without changing much, could someone give an example of how to implement it (adding a Pose display type and changing its shape to "Axis")?

edit retag flag offensive close merge delete

Comments

Rviz has a built in TF display, if you're using TF.

ahendrix gravatar image ahendrix  ( 2016-05-27 17:51:47 -0500 )edit

Don't think I am using TF, since the "Frame" filed in the TF display does not have the frame I am using. The current code publishes a single markerarray in a single frame which contains the point clouds and poses for all sensors. Each color represents a different sensor.

Dr1T gravatar image Dr1T  ( 2016-05-28 06:52:26 -0500 )edit

Then, I recommend you get familiar with TF and use it properly. Then, this you want to do is going to be much easier and you will have tons of advantages when dealing with your sensor data.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-05-30 02:50:29 -0500 )edit

Late update. TF really is the best option, but I ended up creating 3 arrow markers since changing to TF, in this specific case, would require a lot of changes and I didn't have much time to do it. Thanks for your answers.

Dr1T gravatar image Dr1T  ( 2016-06-18 06:03:32 -0500 )edit