Skip to content

fix: add thread safety to navigation and localization providers#2422

Open
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:fix/thread-safety-navigation-providers
Open

fix: add thread safety to navigation and localization providers#2422
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:fix/thread-safety-navigation-providers

Conversation

@Wanbogang
Copy link
Collaborator

Summary

Add threading.Lock to three Unitree providers to prevent race conditions
between Zenoh callback threads and the main thread accessing shared state.

Changes

src/providers/unitree_go2_navigation_provider.py

  • Add threading.Lock to protect _nav_in_progress, _current_destination, and navigation_status
  • Add lock to properties navigation_state and is_navigating

src/providers/unitree_g1_navigation_provider.py

  • Add threading.Lock to protect _nav_in_progress, _current_destination, and navigation_status
  • Add lock to properties navigation_state and is_navigating
  • Fix indentation in navigation_status_message_callback

src/providers/unitree_go2_lidar_localization_provider.py

  • Add threading.Lock to protect localization_status and localization_pose
  • Add lock to properties is_localized and pose
  • Remove duplicate self._lock initialization

- Add threading.Lock to UnitreeGo2NavigationProvider, UnitreeG1NavigationProvider, and UnitreeGo2LidarLocalizationProvider
- Protect all shared state access (_nav_in_progress, _current_destination, navigation_status, localization_status, localization_pose) with lock
- Add lock to all properties (navigation_state, is_navigating, is_localized, pose)
- Update tests to 100% coverage for all three providers
@Wanbogang Wanbogang requested review from a team as code owners February 26, 2026 06:49
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files labels Feb 26, 2026
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant