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?
Originally posted by hammel on ROS Answers with karma: 1 on 2015-02-25
Post score: 0
Original comments
Comment by dornhege on 2015-02-25:
Try setting pose.orientation.w = 1
.
Comment by hammel on 2015-02-26:
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 :(
Comment by hammel on 2015-02-26:
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 :)
Comment by Sleipnir on 2022-06-22:
Hello I know this is kinda old but i've got the same problem of having nothing showing in rviz even so my code is structured as the answer.
My data is correctly published on the topic and i can select the topic of type marker in rviz but nothing shows. Thanks for helping.
Comment by jarvisschultz on 2022-06-22:
@Sleipnir this is not a discussion forum, it is a Q&A site. If you have a question, please open a new question. See https://wiki.ros.org/Support for more.
Comment by jarvisschultz on 2022-06-22:
@Sleipnir I've deleted your answer and reposted as a comment. I had to remove the code snippet because it was too long to fit as a comment.
Comment by jarvisschultz on 2022-06-22:
@Sleipnir if you are confident you are publishing the marker (which you did indicate), I'd suggest you verify that:
- You've explicitly filled out the
marker.header.stamp
with a current timestamp (if thelifetime
is non-zero this is required) - You've set
rviz
to use the same fixed frame that your marker is using for aframe_id
(or that there is a known transform from the markerframe_id
to the fixed frame used byrviz
- Make sure the topic in
rviz
for the Marker display is set correctly