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

rostopic echo of a field of an array in ROS Indigo

asked 2015-11-04 08:50:35 -0600

Hi, I have an issue trying to display a field of an array in a message in ROS Indigo with the command rostopic echo. I'm trying to display the position of an object detected with the Ork package, using this command :

rostopic echo /recognized_object_array/objects[0]/pose/pose/pose/position

But I got this traceback :

Traceback (most recent call last):
  File "/opt/ros/indigo/bin/rostopic", line 35, in <module>
    rostopic.rostopicmain()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostopic/__init__.py", line 1765, in rostopicmain
    _rostopic_cmd_echo(argv)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostopic/__init__.py", line 1136, in _rostopic_cmd_echo
    _rostopic_echo(topic, callback_echo, bag_file=options.bag)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rostopic/__init__.py", line 788, in _rostopic_echo
    index = submsg_class.__slots__.index(field)
AttributeError: 'NoneType' object has no attribute '__slots__'

But it works if I only do :

rostopic echo /recognized_object_array/objects[0]

This is just an example, I have the same issue with other custom messages using arrays. Is there a specific syntax to display the field of an element of an array ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-15 08:28:56 -0600

peci1 gravatar image

It should work in Indigo now (it didn't use to work in older Indigo releases, but now I tested it and it works).

The

AttributeError: 'NoneType' object has no attribute '__slots__'

means you reference an invalid field in your topic path definition. Make sure you correctly type in all parts of the path and "dereference" all arrays.

edit flag offensive delete link more

Comments

It works for me in Indigo:

rostopic echo /namespace/ball_tracking/ball_states/ball_states[0]/position

However if I would like to visualize that in rviz as pointstamped it does not work: Error subscribing: Character [[] at element [49] is not valid in Graph... Any ideas how to sole this?

Markus gravatar image Markus  ( 2018-05-07 02:18:12 -0600 )edit

Is your topic .../ball_states[0]/position of type PointStamped and is element 49 continuously published ? Just a guess, if you track a lot of balls, it's likely that your array has a different size each frame and so element 49 might not always exist. However I would suggest to open a new question.

Cyril Jourdan gravatar image Cyril Jourdan  ( 2018-05-07 03:17:22 -0600 )edit

hm no the problem is that I am not allowed to used these brackets [ in rviz as topic name. And I do not know how to select the first element of an array otherwise ..... :( thats the problem here.

Markus gravatar image Markus  ( 2018-05-07 03:47:12 -0600 )edit

Ok I see, you could to write a simple node that does the translation to a MarkerArray of spheres which is resized dynamically and display your balls in rviz ?

Cyril Jourdan gravatar image Cyril Jourdan  ( 2018-05-07 04:29:25 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-11-04 08:50:35 -0600

Seen: 4,238 times

Last updated: Feb 15 '16