Unicycle Odometry — Robotics/Planar Kinematics
Robotics/Planar_Kinematics/Unicycle_Odometry · 2 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
Unicycle Odometry
Robotics / Planar Kinematics
Dead reckoning for a wheeled robot: integrates body velocities into an SE(2) pose.
- x[k+1] = x[k] + v·Ts·cosθ[k]
- y[k+1] = y[k] + v·Ts·sinθ[k]
- θ[k+1] = θ[k] + ω·Ts
The integration is forward Euler – the heading is held at its start-of-step value across the step. That is the contract, not an approximation being hidden: it is what a microcontroller ships, and its error shrinks with Ts.
Ports
- v / wL – in Body rates mode the forward speed v in m/s; in Wheel speeds mode the left wheel's angular speed in rad/s.
- omega / wR – in Body rates mode the yaw rate ω in rad/s; in Wheel speeds mode the right wheel's angular speed in rad/s.
- pose – (x, y, θ) as a [3,1] column. Its size is fixed, not inherited.
Parameters
- Initial Pose – the pose at t = 0, a [3,1] column (x, y, θ) with θ in radians.
- Input Mode – which quantities the two input ports carry:
- Body rates (v, omega) – the ports are v and ω directly.
- Wheel speeds (wL, wR) – the ports are left and right wheel angular speeds, and the block converts them with v = (r/2)·(wL + wR) and ω = (r/b)·(wR − wL).
- Wheel Radius (m) – r, used only in Wheel speeds mode.
- Track Width (m) – b, the distance between the wheels, used only in Wheel speeds mode. It must be non-zero in that mode.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. The seed, the step Ts, the mode and the wheel geometry are baked into the generated body at export time rather than exposed as tunable parameters.
The three HDL targets are simulation-only: a sine and a cosine per sample have no Q16.16 form. ⚠ The pose state also round-trips through Q16.16 there, and – unlike Gyro Quaternion Integration, whose renormalization bounds the same effect – nothing here pulls it back, so over a long run the exported HDL pose drifts from the reference as a random walk. That is a property of dead reckoning in fixed point, not a codegen fault.
Simulink bridge
None, measured rather than assumed: the mobile-robot odometry blocks ship in the Robotics System Toolbox, which is not installed on this machine.
Notes
- Stateful and inherently discrete. The state is the pose itself.
- The output is the pose at the START of the step, published before the update, so the first sample is exactly the configured seed.
- θ is RAW and never wrapped. It accumulates without bound, which is what keeps it usable directly by Rotation 2D (cos and sin are periodic). Put Angle Wrap after it when a bounded heading is wanted – wrapping is always visible in the diagram.
- Dead reckoning drifts, by construction: there is no correction from any external measurement, so errors in v and ω integrate forever. Fuse with an absolute source before trusting it over distance.
- Nonlinear, so deliberately no state space – the update multiplies an input by the cosine of a state.
Code facts#
| Fact | Value |
|---|---|
| registered type | Robotics/Planar_Kinematics/Unicycle_Odometry |
| family | Robotics/Planar_Kinematics |
| solver environment class | ICoreBlock_0_Robotics_1_Planar_Kinematics_2_Unicycle_Odometry |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Planar_Kinematics/Unicycle_Odometry/ICoreBlock_0_Robotics_1_Planar_Kinematics_2_Unicycle_Odometry.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Planar_Kinematics/Unicycle_Odometry/ICoreBlock_0_Robotics_1_Planar_Kinematics_2_Unicycle_Odometry.h |
| default size on canvas | 140 × 84 px |
| ports at insert | 2 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | v |
| 2 | in | ICoreDouble | omega |
| 3 | out | ICoreDouble | pose |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
Initial Pose | [0; 0; 0] | — |
Input Mode | Body rates (v, omega)%~%Wheel speeds (wL, wR)~~Body rates… | — |
Wheel Radius (m) | 0.05 | — |
Track Width (m) | 0.3 | — |
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): no Simulink equivalent available: mobile-robot odometry ships in the Robotics System Toolbox, which is not installed. Rebuild it on the Simulink side from Discrete-Time Integrator and Trigonometric Function blocks, keeping the (x, y, theta) pose layout and the raw, unwrapped heading this block uses
Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
Unicycle Odometry — planar dead reckoning x[k+1] = x[k] + v*Ts*cos(theta[k]) y[k+1] = y[k] + v*Ts*sin(theta[k]) theta[k+1] = theta[k] + omega*Ts
Two input modes (body rates, or wheel speeds through the ledger's diff-drive matrix), the pose published BEFORE the update, and the seed baked in from CONFIG rather than read off the live member. All three are explained in the header.
Every generated body has the same two-part shape: publish the held pose, then advance it. Each new component depends only on the OLD pose and the inputs, so no backend needs scratch storage and the HDL bodies need no read-after-write dance - unlike the gyro block, which normalizes and therefore has to see its own updated components.
Sample results#
The same rig also ran:
| Stimulus | What it is | Output range |
|---|---|---|
impulse | Impulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair) | 0 … 0.1 |
ramp | Ramp: slope 1 from t = 0 | -0.9728 … 1.071 |
sine | Sine Wave: amplitude 1, 2 rad/s, no phase, no bias | 0 … 0.8943 |
table | Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample | -0.3458 … 1.425 |
Plotted: step — Step: 0 -> 1 at t = 1 s
Category dynamic · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Robotics__Planar_Kinematics__Unicycle_Odometry.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).