Skip to content

enhance(ros2agnocast): avoid unnecessary get_topic_names_and_types in topic info_agnocast#1236

Draft
Koichi98 wants to merge 1 commit intomainfrom
enhance/topic_info_agnocast
Draft

enhance(ros2agnocast): avoid unnecessary get_topic_names_and_types in topic info_agnocast#1236
Koichi98 wants to merge 1 commit intomainfrom
enhance/topic_info_agnocast

Conversation

@Koichi98
Copy link
Copy Markdown
Collaborator

@Koichi98 Koichi98 commented Apr 8, 2026

Description

Optimize ros2 topic info_agnocast by removing the expensive get_topic_names_and_types() call that fetched all topics just to look up the type of a single topic.

Problem

The command made 3 ROS2 API calls:

  1. get_topic_names_and_types() — fetched all topics to find the type of the target topic
  2. get_publishers_info_by_topic() — called inside print_publishers_info
  3. get_subscriptions_info_by_topic() — called inside print_subscribers_info

Change

  • Remove get_topic_names_and_types() entirely
  • Call get_publishers_info_by_topic() and get_subscriptions_info_by_topic() once in main, extract the topic type from the results, and pass them to the print functions
  • ROS2 API calls reduced from 3 to 2, and the most expensive one (full topic discovery) is eliminated

Related links

How was this PR tested?

  • Autoware (required)
  • bash scripts/test/e2e_test_1to1.bash (required)
  • bash scripts/test/e2e_test_2to2.bash (required)
  • kunit tests (required when modifying the kernel module)
  • bash scripts/test/run_requires_kernel_module_tests.bash (required)
  • sample application

Notes for reviewers

Version Update Label (Required)

Please add exactly one of the following labels to this PR:

  • need-major-update: User API breaking changes
  • need-minor-update: Internal API breaking changes (heaphook/kmod/agnocastlib compatibility)
  • need-patch-update: Bug fixes and other changes

Important notes:

  • If you need need-major-update or need-minor-update, please include this in the PR title as well.
    • Example: fix(foo)[needs major version update]: bar or feat(baz)[needs minor version update]: qux
  • After receiving approval from reviewers, add the run-build-test label. The PR can only be merged after the build tests pass.

See CONTRIBUTING.md for detailed versioning rules.

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 changed the title avoid unnecessary get_topic_names_and_types enhance(ros2agnocast): avoid unnecessary get_topic_names_and_types in topic info_agnocast Apr 8, 2026
@Koichi98 Koichi98 added need-patch-update Bug fixes and other changes - requires PATCH version update next-release labels Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-patch-update Bug fixes and other changes - requires PATCH version update next-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant