Skip to content

Conversation

@YuchengZhou821
Copy link
Contributor

@YuchengZhou821 YuchengZhou821 commented Dec 16, 2025

This pull request refactors the sensor input system to introduce strongly-typed, Pydantic-based configuration classes for each sensor, improving type safety, validation, and code clarity. The changes generalize the Sensor and FuserInput base classes to support specific configuration types, and update all input plugins to use these new config classes. The load_input function is also updated to instantiate sensors with their configuration objects.

Core infrastructure and typing improvements:

  • Refactored SensorConfig to inherit from Pydantic's BaseModel, enabling validation and type hints for sensor configuration. The base Sensor and FuserInput classes are now generic over their configuration type, allowing each sensor to specify its own config schema. [1] [2] [3] [4]
  • Updated the load_input function in src/inputs/__init__.py to accept a configuration dictionary, dynamically detect and instantiate the appropriate config class for each sensor, and pass it to the sensor's constructor. [1] [2] [3]

Plugin-specific configuration classes:

  • For each sensor plugin (e.g., battery_turtlebot4, battery_unitree_go2, dimo_tesla, fabric_closest_peer, face_presence_input, gallery_identities_input), introduced a dedicated Pydantic config class with explicit fields and documentation, replacing generic or ad-hoc config handling. Constructors and config usage within each plugin were updated accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Generalization and consistency:

  • All sensor plugin classes and their constructors were updated to use the new config types, eliminating the previous pattern of defaulting to a generic SensorConfig and using getattr for config values. [1] [2] [3]

These changes make the input system more robust, maintainable, and ready for further extension.

@YuchengZhou821 YuchengZhou821 requested review from a team as code owners December 16, 2025 00:47
@github-actions github-actions bot added robotics Robotics code changes python Python code labels Dec 16, 2025
@YuchengZhou821 YuchengZhou821 requested a review from a team as a code owner December 16, 2025 20:01
@github-actions github-actions bot added the tests Test files label Dec 16, 2025
@openminddev openminddev merged commit aafb93c into main Dec 17, 2025
6 checks passed
@openminddev openminddev deleted the Refactor-inputs-using-pydantic branch December 17, 2025 07:31
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.

2 participants