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

Sort info output by topic name #1804

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from

Conversation

Sanoronas
Copy link

Closes #1797

  • generate sorted indices for topics from multiple different options (topic name, type, count or serialization format)
  • defaults to sorting by topic name
  • use sorted indices rather than using strict increasing indices for printing out the topics
  • potential use of different sorting options through CLI by passing sort_method argument to format_topics_with_type function

@Sanoronas Sanoronas requested a review from a team as a code owner September 11, 2024 14:55
@Sanoronas Sanoronas requested review from emersonknapp and james-rms and removed request for a team September 11, 2024 14:55
Copy link
Contributor

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

it would be nice if format_service_with_type has the same sorting interface aligned with topics.

this PR is failing to build with the following error and DCO is missing. could you address them?

07:59:08 /tmp/ws/src/rosbag2/rosbag2_py/src/rosbag2_py/format_bag_metadata.cpp:144:8: error: ‘iota’ is not a member of ‘std’
07:59:08   144 |   std::iota(sorted_idx.begin(), sorted_idx.end(), 0);
07:59:08       |        ^~~~
07:59:08 gmake[2]: *** [CMakeFiles/_storage.dir/build.make:90: CMakeFiles/_storage.dir/src/rosbag2_py/format_bag_metadata.cpp.o] Error 1
07:59:08 gmake[1]: *** [CMakeFiles/Makefile2:284: CMakeFiles/_storage.dir/all] Error 2
07:59:08 gmake: *** [Makefile:146: all] Error 2

@@ -115,7 +115,8 @@ void format_topics_with_type(
const std::unordered_map<std::string, uint64_t> & messages_size,
bool verbose,
std::stringstream & info_stream,
int indentation_spaces)
int indentation_spaces,
std::string sort_method = "name")
Copy link
Contributor

Choose a reason for hiding this comment

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

as you suggested, this option would be nice to configure via CLI so that user can choose the sorting method as they like. and test would be ideal

{
return topics[i1].message_count < topics[i2].message_count;
}
if (sort_method == "serialization_format")
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about this use case. most likely the serialization format could be the same in the single bag file which is cdr?

Copy link
Author

Choose a reason for hiding this comment

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

I was also not sure, if there even is the possibility to have different serialization formats in a bag file. As it was available for output I included it here as option, but can drop it if it is not neccessary

Signed-off-by: Soenke Prophet <[email protected]>
Signed-off-by: Soenke Prophet <[email protected]>
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@Sanoronas Thank you for your contribution.
I agree with @fujitatomoya that sorting by the serialization format is unlikely to be useful. Because we are not supporting different serialization formats during recording by design.
I can only envision a possibility to have a different serilization formats if someone will convert the already recorded bag or record with modifyied rosbag2 recorder or using some different tool for recording.
Therefore I think it makes sense to have options for sorting:

  1. By topic or service name.
  2. By topic or service type
  3. By topic or service messages count

Could you please use C++ enum values for the sorting method?
Also, It will be appreciated if you would add the same sorting algorithm for the services in the format_service_with_type(..) function located in the same file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort topics by name when executing ros2 bag info
3 participants