Encapsulation hides raw sensor and actuator details behind readable interfaces. In a robot, planning code can ask whether a collision occurred or whether a computer is active instead of interpreting electrical input values directly. section 3.2.1
A practical encapsulation layer:
- Converts raw input into a meaningful operation, such as collision(). section 3.2.1
- Keeps hardware changes inside the sensing code rather than scattering them through movement and planning logic. section 3.2.1
- Adds further layers when one abstraction cannot hide details such as multiple collision sensors. section 3.2.1
From raw input to robot behavior
Instead of checking robot.inputs[0].status() directly, movement code can call robot.collision_sensor.collision() and immediately trigger an emergency stop. The sensing component owns the interpretation of the switch. section 3.2.1
if robot.collision_sensor.collision(): robot.emergency_stop()
Shows the higher-level collision interface that keeps raw input handling out of behavior code. section 3.2.1
















