Ask Your Question

publish marker

asked 2012-05-07 05:36:00 -0500

apalomer gravatar image

updated 2014-01-28 17:12:14 -0500

ngrennan gravatar image

Hi, I'm trying to publis a simple marker. A cilinder. I've done this code


import roslib; roslib.load_manifest('ellipse_marker')
from visualization_msgs.msg import Marker
import rospy

rospy.init_node('ellipse', anonymous=True)
publisher = rospy.Publisher("ellipse", Marker)
count = 0
while not rospy.is_shutdown():
    ellipse = Marker()
    ellipse.header.frame_id = "odom"
    ellipse.header.stamp =
    ellipse.type = Marker.CYLINDER
    ellipse.pose.position.x = 0
    ellipse.pose.position.y = 0
    ellipse.pose.position.z = 0
    ellipse.pose.orientation = (0,0,0,1)
    ellipse.scale.x = 2*count
    ellipse.scale.y = 2*count
    ellipse.scale.z = 1
    ellipse.color.a = 1.0
    ellipse.color.r = 1.0
    ellipse.color.g = 1.0
    ellipse.color.b = 1.0
    count += 0.1

    # Publish the MarkerArray


But, when i run this node i get the following error:

Traceback (most recent call last):
  File ".../ellipse_marker/src/", line 29, in <module>
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/", line 695, in publish
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/", line 872, in publish
    serialize_message(b, self.seq, message)
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/", line 151, in serialize_message
  File "/opt/ros/electric/stacks/common_msgs/visualization_msgs/src/visualization_msgs/msg/", line 218, in serialize
    buff.write(_struct_3i10d4f2iB.pack(, _x.type, _x.action, _x.pose.position.x, _x.pose.position.y, _x.pose.position.z, _x.pose.orientation.x, _x.pose.orientation.y, _x.pose.orientation.z, _x.pose.orientation.w, _x.scale.x, _x.scale.y, _x.scale.z, _x.color.r, _x.color.g, _x.color.b, _x.color.a, _x.lifetime.secs, _x.lifetime.nsecs, _x.frame_locked))
AttributeError: 'tuple' object has no attribute 'x'

can somebody help me?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-05-07 06:26:21 -0500

Dustin gravatar image

I don't see anything obviously wrong but then I don't use Python frequently. If I may hazard a guess though I would say the problem lies with the line 18:

ellipse.pose.orientation = (0,0,0,1)

The error states that some tuple does not have an x attribute as required and I don't see any other tuples in your code. Try changing that to the following:

ellipse.pose.orientation.x = 0;
ellipse.pose.orientation.y = 0;
ellipse.pose.orientation.z = 0;
ellipse.pose.orientation.w = 1;
edit flag offensive delete link more


That was the problem.Thenaks!

apalomer gravatar image apalomer  ( 2012-05-07 23:21:28 -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


Asked: 2012-05-07 05:36:00 -0500

Seen: 4,471 times

Last updated: May 07 '12