ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

publish marker

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

apalomer gravatar image

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

ngrennan gravatar image

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

#!/usr/bin/python

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
    publisher.publish(ellipse)

    rospy.sleep(0.01)

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 <module>
    publisher.publish(ellipse)
  File "/opt/ros/electric/stacks/ros_comm/clients/rospy/src/rospy/topics.py", line 695, in publish
    self.impl.publish(data)
  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
    msg.serialize(b)
  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?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Comments

That was the problem.Thenaks!

apalomer gravatar image apalomer  ( 2012-05-07 23:21:28 -0600 )edit

Question Tools

Stats

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

Seen: 5,463 times

Last updated: May 07 '12