Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plotting of values containers in an array #44

Conversation

thomas-moulard
Copy link

@thomas-moulard thomas-moulard commented Dec 20, 2019

Before this commit, attempting to plot a value in an array would trigger the following exception:

Traceback (most recent call last):
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 259, in on_topic_edit_textChanged
    plottable, message = is_plottable(self._node, topic_name)
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 154, in is_plottable
    fields, message = get_plot_fields(node, topic_name)
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 137, in get_plot_fields
    for slot, slot_type in field_class.get_fields_and_field_types().items():
AttributeError: 'NoneType' object has no attribute 'get_fields_and_field_types'

Line 129 in plot_widget.py:

    field_class = message_helpers.get_message_class(slot_type)

...would be executed with slot_type set to sequence<foo_msgs/Foo> which
returns a None value. field_class is set to None and the call to
get_fields_and_field_types is then failing.

This pull request adds an extra layer of logic before calling get_message_class
to ensure that, if the type is an array, we extract the inner array type
instead of attempting to run get_message_class on the DDS sequence type
directly.

@thomas-moulard thomas-moulard changed the base branch from master to crystal-devel December 20, 2019 19:29
if is_array:
sequence_inner_type_regexp = re.match('sequence<(.*)>', slot_type)
if sequence_inner_type_regexp:
slot_type = sequence_innter_type_regexp.groupdict()['slot_type']
Copy link
Contributor

@dirk-thomas dirk-thomas Jan 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a spelling mistake. Please update and afterwards test your patch locally.

Before this commit, attempting to plot a value in an array would
trigger the following exception:

Traceback (most recent call last):
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 259, in on_topic_edit_textChanged
    plottable, message = is_plottable(self._node, topic_name)
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 154, in is_plottable
    fields, message = get_plot_fields(node, topic_name)
  File "/opt/ros/eloquent/lib/python3.6/site-packages/rqt_plot/plot_widget.py", line 137, in get_plot_fields
    for slot, slot_type in field_class.get_fields_and_field_types().items():
AttributeError: 'NoneType' object has no attribute 'get_fields_and_field_types'

Line 129 in plot_widget.py:

    field_class = message_helpers.get_message_class(slot_type)

...would be executed with slot_type set to 'sequence<foo_msgs/Foo>' which
returns a None value. field_class is set to None and the call to
get_fields_and_field_types is then failing.

This pull request adds an extra layer of logic before calling get_message_class
to ensure that, if the type is an array, we extract the inner array type
instead of attempting to run get_message_class on the DDS sequence type
directly.

Signed-off-by: Thomas Moulard <tmoulard@amazon.com>
@briansoe66
Copy link

What is the timeline of this issue? Will the eloquent or foxy debian package be patched with this fix? I'd like to plot sensor_msgs/JointState position[i] etc in ROS2.

@Michael-Equi
Copy link

Michael-Equi commented Dec 3, 2020

@dirk-thomas Is this ready to be merged? It looks like @thomas-moulard made the necessary fix in his most recent commit. I just tested the commit on my machine and I seem to have the same issue when trying to listen to /joint_states/velocity[0] not sure if this is an issues on my end or not. I am on Foxy 20.04 with Cyclone DDS. I dont have the time to debug this at the moment but it would be really helpful if someone could figure this out.

@dirk-thomas
Copy link
Contributor

@Michael-Equi I am not maintaining this repository anymore. Maybe the current maintainer can step up?

@ivanpauno
Copy link
Contributor

Closing in favor of #71.

@ivanpauno ivanpauno closed this Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants