feat(agnocastlib): Support ROS_TIME for create_timer#990
Draft
feat(agnocastlib): Support ROS_TIME for create_timer#990
Conversation
Signed-off-by: Koichi <koichi.imai.2@tier4.jp>
f4ba646 to
22e000e
Compare
Signed-off-by: Koichi <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi <koichi.imai.2@tier4.jp>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add support for
RCL_ROS_TIMEandRCL_SYSTEM_TIMEclock types increate_timer. Previously, onlyRCL_STEADY_TIMEwas supported.Background:
use_sim_timeandros_time_is_activeWhen
use_sim_timeparameter is set to true, the node subscribes to the/clocktopic for simulation time. However,ros_time_is_active()returns true only after the first/clockmessage is received. Before that, even withuse_sim_time=true, the system uses wall clock time (ros_time_is_active()returns false).This creates a dynamic transition:
/clockreceived:ros_time_is_active()= false → usetimer_fd(wall clock)/clockreceived:ros_time_is_active() = true→ useclock_eventfd(simulation time)Implementation
Dual-fd Architecture for
ROS_TIMETimersFor
RCL_ROS_TIMEtimers, we use two file descriptors:ros_time_is_active() = false)ros_time_is_active() = true)Time Jump Handling
Registered time jump callbacks handle clock state transitions:
RCL_ROS_TIME_ACTIVATED: Closetimer_fd, switch toclock_eventfdRCL_ROS_TIME_DEACTIVATED: Recreatetimer_fd, switch back to wall clockThread Safety with Reader/Writer Lock
Time jump callbacks run in a dedicated clock executor thread, while timer events are handled in the main executor thread. To prevent race conditions when
timer_fdis closed/recreated:std::shared_mutex fd_mutexprotectstimer_fdaccessshared_lock: Used for read operations (read(),epoll_ctl())unique_lock: Used for write operations (close(),create_timer_fd())This ensures:
timer_fdconcurrentlytimer_fdClock Type Handling
RCL_STEADY_TIME: UsesCLOCK_MONOTONIC timerfdRCL_SYSTEM_TIME: UsesCLOCK_REALTIME timerfdRCL_ROS_TIME: UsesCLOCK_REALTIME timerfd+clock_eventfdRelated links
How was this PR tested?
bash scripts/e2e_test_1to1_with_ros2sub(required)bash scripts/e2e_test_2to2(required)Notes for reviewers
Version Update Label (Required)
Please add exactly one of the following labels to this PR:
need-major-update: User API breaking changesneed-minor-update: Internal API breaking changes (heaphook/kmod/agnocastlib compatibility)need-patch-update: Bug fixes and other changesImportant notes:
need-major-updateorneed-minor-update, please include this in the PR title as well.fix(foo)[needs major version update]: barorfeat(baz)[needs minor version update]: quxrun-build-testlabel. The PR can only be merged after the build tests pass.See CONTRIBUTING.md for detailed versioning rules.