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 tuples for bisect calls #67

Merged
merged 1 commit into from
Oct 27, 2020
Merged

Conversation

mjeronimo
Copy link
Contributor

Python3 doesn't allow comparisons between 'NoneType' and some other types, like
float, generating the following error:

TypeError: '<' not supported between instances of 'float' and 'NoneType'

This error was encountered when calling bisect() with tuples that have a second element
as 'None' (one occurance is when displaying all thumbnails) where the corresponding element
type is int, float, etc. Instead, single element tuples are created, which result in the correct
comparison behavior.

Signed-off-by: Michael Jeronimo michael.jeronimo@openrobotics.org

Python3 doesn't allow comparisons between 'NoneType' and other types like
float, generating the following error:

    TypeError: '<' not supported between instances of 'float' and 'NoneType'

This error was encountered when creating tuples for calls to bisect, where
a tuple was created using 'None'. Instead, a single element tuples are
created, which result in the correct comparison behavior.

Signed-off-by: Michael Jeronimo <michael.jeronimo@openrobotics.org>
Copy link

@mabelzhang mabelzhang left a comment

Choose a reason for hiding this comment

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

Thanks to your bag file with images (and your demo showing what that last button is. I know, or I should just read the wiki better), I can now reproduce the error!

One way to reproduce the error on master branch:
In Ubuntu 20.04 + ROS Noetic, which defaults to Python 3, run

$ rqt_bag

to bring up the GUI. Use the Load Bag button to load a bag file with image topics.
Right click in the timeline, check Thumbnails. Or use the Toggle Thumbnails button (last one on the right in the tool bar).
Errors, seems like one per image, will print in the terminal.
After the fix in this PR, images can now be displayed.

To make sure this still works for Python 2, I tested the branch in Ubuntu 18.04 + ROS Melodic as well, which defaults to Python 2. Things still work.

One thing I noticed though, which may or may not be related to this PR, is that Melodic shows thumbnails for these two topics

/camera/color/image_raw/compressed
/camera/depth/image_rect_raw/compressed

whereas Noetic does not. They are type sensor_msgs/CompressedImage.

Did you notice that? Is this something related that we can easily fix in this PR, or it's a separate issue?

Edit: I noticed another PR for image_helper, maybe it's fixed there.

@mjeronimo
Copy link
Contributor Author

It should be a separate issue. This PR is targeted specifically at the "TypeError: '<' not supported between instances of 'float' and 'NoneType'" errors.

Copy link

@mabelzhang mabelzhang left a comment

Choose a reason for hiding this comment

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

Thanks! I'll create an issue for the other behavior - I don't see an existing ticket for it - for the sake of documenting it. We don't have to address it now.

@mjeronimo mjeronimo merged commit 3beb083 into master Oct 27, 2020
@mabelzhang
Copy link

Issue created #74

mjeronimo added a commit that referenced this pull request Oct 28, 2020
Python3 doesn't allow comparisons between 'NoneType' and other types like
float, generating the following error:

    TypeError: '<' not supported between instances of 'float' and 'NoneType'

This error was encountered when creating tuples for calls to bisect, where
a tuple was created using 'None'. Instead, a single element tuples are
created, which result in the correct comparison behavior.

Signed-off-by: Michael Jeronimo <michael.jeronimo@openrobotics.org>
mjeronimo added a commit that referenced this pull request Oct 29, 2020
Python3 doesn't allow comparisons between 'NoneType' and other types like
float, generating the following error:

    TypeError: '<' not supported between instances of 'float' and 'NoneType'

This error was encountered when creating tuples for calls to bisect, where
a tuple was created using 'None'. Instead, a single element tuples are
created, which result in the correct comparison behavior.

Signed-off-by: Michael Jeronimo <michael.jeronimo@openrobotics.org>
@mjeronimo mjeronimo deleted the mjeronimo/fix-tuples-for-bisect branch October 29, 2020 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants