Ask Your Question
0

Rviz Marker LINE_STRIP is not displayed

asked 2015-02-25 10:14:48 -0600

hammel gravatar image

hello :)

   marker_pub = rospy.Publisher('visualization_marker', Marker, queue_size=100)
   line_color = ColorRGBA()       # a nice color for my line (royalblue)
   line_color.r = 0.254902
   line_color.g = 0.411765
   line_color.b = 0.882353
   line_color.a = 1.0
   start_point = Point()        #start point
   start_point.x = 0.2
   start_point.y = 0.0
   start_point.z = 0.2
   end_point = Point()        #end point
   end_point.x = 0.7
   end_point.y = 0
   end_point.z = 0.2

   marker3 = Marker()
   marker3.id = 3
   marker3.header.frame_id = 'world'
   marker3.type = Marker.LINE_STRIP
   marker3.ns = 'Testline'
   marker3.action = 0
   marker3.scale.x = 0.1
   marker3.points.append(start_point)
   marker3.points.append(end_point)
   marker3.colors.append(line_color)
   marker3.colors.append(line_color)

   marker_pub.publish(marker3)

the above code should display a simple static line between two points. it is coded in python. the code seems okay and i added the correct marker in rviz, which displays me the correct namespace set in the code. even if i remove all the color code: no line appears :( in an other rviz scene i succesfully added two spheres, so iam wondering whats wrong here.

any help to my suggestion?

edit retag flag offensive close merge delete

Comments

2

Try setting pose.orientation.w = 1.

dornhege gravatar imagedornhege ( 2015-02-25 10:28:48 -0600 )edit

Thanks for your answer. I saw this line also in "rviz /Tutorials / Markers: Points and Lines" and tried it. Unfortunately without any success. I also tried to change the type to Marker.LINE_LIST because i just want to have a single line --> no success :(

hammel gravatar imagehammel ( 2015-02-26 01:25:06 -0600 )edit

Everything is fine. I had a lazy bug in my code, which was a little different from the posted. The above code works as it should.Thank you anyway :)

hammel gravatar imagehammel ( 2015-02-26 01:47:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-09-17 17:58:49 -0600

updated 2017-09-17 18:14:31 -0600

Here is an example code on how to publish a line (LINE_STRIP) as a marker

#!/usr/bin/env python

import rospy
from visualization_msgs.msg import Marker
from geometry_msgs.msg import Point

rospy.init_node('line_pub_example')
pub_line_min_dist = rospy.Publisher('~line_min_dist', Marker, queue_size=1)
rospy.loginfo('Publishing example line')

while not rospy.is_shutdown():
    marker = Marker()
    marker.header.frame_id = "/my_fixed_frame"
    marker.type = marker.LINE_STRIP
    marker.action = marker.ADD

    # marker scale
    marker.scale.x = 0.03
    marker.scale.y = 0.03
    marker.scale.z = 0.03

    # marker color
    marker.color.a = 1.0
    marker.color.r = 1.0
    marker.color.g = 1.0
    marker.color.b = 0.0

    # marker orientaiton
    marker.pose.orientation.x = 0.0
    marker.pose.orientation.y = 0.0
    marker.pose.orientation.z = 0.0
    marker.pose.orientation.w = 1.0

    # marker position
    marker.pose.position.x = 0.0
    marker.pose.position.y = 0.0
    marker.pose.position.z = 0.0

    # marker line points
    marker.points = []
    # first point
    first_line_point = Point()
    first_line_point.x = 0.0
    first_line_point.y = 0.0
    first_line_point.z = 0.0
    marker.points.append(first_line_point)
    # second point
    second_line_point = Point()
    second_line_point.x = 1.0
    second_line_point.y = 1.0
    second_line_point.z = 0.0
    marker.points.append(second_line_point)

    # Publish the Marker
    pub_line_min_dist.publish(marker)

    rospy.sleep(0.5)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-02-25 10:13:35 -0600

Seen: 2,813 times

Last updated: Sep 17 '17