Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

writing rosbags adds a newline#780

Merged
dirk-thomas merged 1 commit intoros:kinetic-develfrom
dhood:issue736
May 5, 2016
Merged

writing rosbags adds a newline#780
dirk-thomas merged 1 commit intoros:kinetic-develfrom
dhood:issue736

Conversation

@dhood
Copy link
Copy Markdown
Contributor

@dhood dhood commented Mar 25, 2016

Potential fix for #736 where it was noticed that newlines are added each time rosbag filter is called.

From what I can see a newline is added to the message text here when writing a message, but it's never accounted for when reading the message. So it should either not be written, or it should be removed when reading.

Have removed the newline in the rosbag code but it may be appropriate to remove it here instead

@dirk-thomas
Copy link
Copy Markdown
Member

Thank you for creating a regression test for this. The test itself looks good. I will comment on some minor style things inline.

Regarding the proposed fix: as you mentioned it would probably be cleaner to fix genpy instead. The function compute_full_text_escaped should escape a trailing double quote if it has not already been escaped by https://github.com/ros/genpy/blob/9c74c588955bc4398176bbc4b9d09224a7804307/src/genpy/generator.py#L316 Then the extra newline in https://github.com/ros/genpy/blob/6577cc3d3731801913b3fdf62951609f1bf41b72/src/genpy/generator.py#L773 would be obsolete and rosbag doesn't need to cut it off. Can you please try that alternative approach?


inbag_filename = '/tmp/test_rosbag_filter__1.bag'
outbag1_filename = '/tmp/test_rosbag_filter__2.bag'
outbag2_filename = '/tmp/test_rosbag_filter__3.bag'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please avoid hard coding temporary paths. Use tempfile instead. That will ensure that the names don't collide with other tests and potentially work on other platforms.

@dhood
Copy link
Copy Markdown
Contributor Author

dhood commented Mar 25, 2016

Thanks for the review @dirk-thomas - I'm understanding better now where the problem originated.

I think the newline is trying to solve the same problem compute_full_text_escaped is. But, there was a bug in compute_full_text_escaped.

What do you think about this instead? ros/genpy@indigo-devel...dhood:indigo-devel

I haven't been able to find a message type that this will actually affect in order to test it properly though. Do you know of any?

@dirk-thomas
Copy link
Copy Markdown
Member

While the missing assignment certainly needs fixing a single quote at the end of the string also needs to be escaped. For the following input something ... " the trailing quote would be a problem the the input is wrapped in """.

I don't know any message out of my head which has a trailing quote. Obviously none has triple quotes since escaping that correctly is broken. 😉

@dhood
Copy link
Copy Markdown
Contributor Author

dhood commented Mar 25, 2016

How does ros/genpy@indigo-devel...dhood:indigo-devel look now? I didn't bother with the beginning given the current msg format

@dhood
Copy link
Copy Markdown
Contributor Author

dhood commented Mar 25, 2016

I'll open a PR on genpy so the tests can run

@dhood
Copy link
Copy Markdown
Contributor Author

dhood commented Mar 28, 2016

Commits squashed. I think this can be closed now with ros/genpy#47 right?

import sys
import time
import unittest
import tempfile
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move this line two up (for alphabetical order of the core modules [PEP8]).

@dirk-thomas
Copy link
Copy Markdown
Member

I think it still makes sense to merge this new test since it fill prevent regressions in this area in the future.

@dhood
Copy link
Copy Markdown
Contributor Author

dhood commented Mar 28, 2016

thanks again - hopefully ok to merge now

@dirk-thomas
Copy link
Copy Markdown
Member

I will wait with the merge until genpy has been released and the test passes. But the current patch looks good. Thanks.

@dirk-thomas
Copy link
Copy Markdown
Member

@ros-pull-request-builder retest this please

@dirk-thomas dirk-thomas merged commit c70c072 into ros:kinetic-devel May 5, 2016
rsinnet pushed a commit to MisoRobotics/ros_comm that referenced this pull request Jun 19, 2017
writing rosbags adds a newline
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants