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

Publishing array data with rqt

asked 2022-02-13 05:02:29 -0500

kvik gravatar image

I'm trying to use the rqt message publisher to publish a message of type std_msgs/msg/Float64MultiArray.

I can't figure out how I'm supposed to give the data field of type sequence<double>. The default value in the expression field suggests that one should simply specify the array initializer in the array('d') constructor. I tried this to no avail with: array('d', [0.1, 0.1])

>>> [ERROR] [1644749632.166618229] [get_message_class]: Malformed message_type: sequence<double>
Python eval failed for expression "array('d', [0.1, 0.1])" with an exception "name 'array' is not defined"
Publisher._evaluate_expression(): failed to evaluate expression: "array('d', [0.1, 0.1])" as Python type "None"
Traceback (most recent call last):
  File "/opt/ros/rolling/lib/python3.8/site-packages/rqt_publisher/publisher.py", line 161, in change_publisher
    new_text = handler(self._publishers[publisher_id], topic_name, new_value)
  File "/opt/ros/rolling/lib/python3.8/site-packages/rqt_publisher/publisher.py", line 262, in _change_publisher_expression
    expression, error_prefix, slot_type.__name__)
AttributeError: 'NoneType' object has no attribute '__name__'

The interesting bit here is what seems to be the root cause of the problem:

Python eval failed for expression "array('d', [0.1, 0.1])" with an exception "name 'array' is not defined"

If this isn't the correct way to do it, what am I supposed to do? I also tried, all in vain, these options:

[0.1, 0.1]
array.array('d', [0.1, 0.1])
import array; array.array('d', [0.1, 0.1])

I'm using ROS2 Rolling at the moment, although I've had the same issue with Foxy and Galactic before.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-06 09:30:12 -0500

halejo gravatar image

The version 1.6.0 of rqt_publisher solve the problem. I tested also in foxy using this version and is working fine with the expression

array('d', [0.1, 0.1])

edit flag offensive delete link more

Comments

Nice. Thanks for the tip.

kvik gravatar image kvik  ( 2022-09-06 11:43:58 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-02-13 05:02:29 -0500

Seen: 1,099 times

Last updated: Feb 13 '22