Rosanswers logo

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 = rospy.Time.now()
    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/ellipse_marker.py", line 29, in 
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/topics.py", line 695, in publish
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/topics.py", line 872, in publish
    serialize_message(b, self.seq, message)
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/msg.py", line 151, in serialize_message
  File "/opt/ros/electric/stacks/common_msgs/visualization_msgs/src/visualization_msgs/msg/_Marker.py", line 218, in serialize
    buff.write(_struct_3i10d4f2iB.pack(_x.id, _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?


Originally posted by apalomer on ROS Answers with karma: 318 on 2012-05-07

Post score: 0


1 Answer 1


Rosanswers logo

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;

Originally posted by Dustin with karma: 328 on 2012-05-07

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by apalomer on 2012-05-07:
That was the problem.Thenaks!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.