rospy rviz markers [closed]

asked 2020-06-19 13:47:19 -0500

gerhmi gravatar image

Hi!

I'm having some difficulty getting my MarkerArray to show up in rviz. When I run the code, no namespace nor markers appear under the visualization_marker_array topic. I'm using 3 arrays: x_points, y_points, and yaw_points and this function:

import tf
import visualization_msgs
from visualization_msgs.msg import MarkerArray, Marker
from geometry_msgs.msg import Point, Quaternion, Vector3
from std_msgs.msg import ColorRGBA

def show_markers(x_points, y_points, yaw_points):

array = MarkerArray()
pub = rospy.Publisher('/visualization_marker_array', MarkerArray, queue_size=100)

for i in range(0, len(x_points)):
    mk = Marker()
    mk.header.frame_id = '/map'
    mk.header.stamp = rospy.Time()
    mk.ns = 'goals'
    mk.id = i
    mk.type = 2
    mk.action = 0
    quat = tf.transformations.quaternion_from_euler(0.0, 0.0, yaw_points[i])
    mk.pose.orientation = Quaternion(*quat)
    mk.pose.position = Point(x_points[i], y_points[i], 0.0)
    mk.scale = Vector3(1.0, 1.0, 1.0)
    mk.color = ColorRGBA(0.0, 1.0, 0.0, 1.0)
    array.markers.append(mk)

pub.publish(array)

Thank you for any suggestions!

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by gerhmi
close date 2020-06-19 14:00:43.164797

Comments

What is this a duplicate of?

Please always link to the duplicate.

gvdhoorn gravatar image gvdhoorn  ( 2020-06-19 15:45:53 -0500 )edit