encoder_wheel
encoder_wheel.py
Overview
encoder_wheel.py is a synthetic wheel-odometry source that emits pseudo-random tick counts on each wheel revolution at a fixed rate. It enables movement stacks—dead-reckoning, PID controllers and loggers—to run in simulation or CI without real encoder hardware.
Interfaces (strongly-typed, stateless)
Direction |
Topic |
Semantics |
---|---|---|
Provided |
|
|
Contract
Pre-conditions
Node launched with valid robot_id CLI argument.
Downstream expects wheel ticks at ~10 Hz.
Post-conditions
Publishes exactly one Int32 message each loop iteration.
data field is an integer uniformly drawn from [0, 999].
No other side-effects or retained state.
Invariants
Loop frequency = _RATE ± ROS scheduler jitter.
Tick range fixed by _MAX_TICK.
Quality-of-Service KPIs
Metric |
Target |
Rationale |
---|---|---|
Message rate |
10 Hz ± 0.5 Hz |
Keeps odometry loops stable. |
Latency |
< 100 ms |
Avoids stale encoder data. |
CPU load |
< 1 % |
Safe on embedded CPU. |
Implementation notes
Uses random.randint(0, _MAX_TICK) for uniform tick generation.
All logic resides in wheel_encoder(); the main loop only handles timing.
Seed the RNG (random.seed(…)) before wheel_encoder() to reproduce traces.
Functions
Initialise ROS publisher and broadcast random tick counts until shutdown. |