Generated reference › Angle Unwrap — Robotics/Coordinate Transforms
kind: generated#block#robotics-coordinate-transforms

Angle Unwrap — Robotics/Coordinate Transforms

Robotics/Coordinate_Transforms/Angle_Unwrap · 1 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.

Angle Unwrap

Robotics / Coordinate Transforms

Removes the 2π jumps from a wrapped angle stream, turning a heading that snaps at the branch cut into a continuous one:

y[0] = u[0], and for each later sample the step is the difference wrapped into [−π, π): d = u[k] − u[k−1], step = d − 2π·floor((d + π)/2π), y[k] = y[k−1] + step.

This is what a Difference, a rate estimate or a PID needs in front of it: on a wrapped feed the crossing from π to −π looks like a jump of −2π, and any derivative of it is nonsense for one sample.

Ports

  • u – the wrapped angle in radians. Scalar – see Notes.
  • y – the continuous angle. Unbounded: it accumulates, so a wheel turning one way forever gives an output growing forever.

Parameters

  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period. This block has no other parameter, deliberately – see Simulink bridge.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text.

The three HDL targets are genuine synthesizable Q16.16: the wrap is one multiply by a folded reciprocal, one fx_to_int floor and a multiply-add, with no divider and no transcendental. One caveat for a hardware deployment: the output is unbounded by construction, so on a long enough one-way run it leaves Q16.16's ±32768 integer range. That is a property of unwrapping, not of the export.

PLC Structured Text has no FLOOR and its TRUNC rounds toward zero, so the floor is rebuilt with a sign correction – the same construction Angle Wrap uses.

Simulink bridge

Both directions, onto dspsigops/Unwrap. Two of its parameters are pinned rather than mapped, because at its defaults the block computes something else entirely:

  • running = on and InputProcessing = Elements as channels (sample based) – the streaming form. At the defaults (running = off, frame based) a scalar stream has one element per frame, so unwrapping along the vector is a no-op and the block passes its input straight through. That is measured, not inferred.
  • tol does not cross, and this block exposes no tolerance parameter, because in streaming mode it has no effect: tolerances of 1.0, 2.4, π, 3.5, 4.0 and 6.0 all produce byte-identical output. A parameter that changes nothing is worse than none, since it invites tuning that does nothing.

It has no SampleTime parameter, so Sampling Time (s) does not cross.

Notes

  • Stateful, and discrete by nature (setDiscreteOnlyBlock(true)): the state advances once per sample and there is no derivative to integrate.
  • The first sample passes through unchanged, and that needs an explicit flag rather than a zeroed previous input – otherwise the block would invent a jump of u[0] out of nothing on the very first step.
  • Scalar only. Simulink's sample-based mode treats each element of a vector as its own channel; this block takes one. The consumer is a single encoder, compass or heading feed, and per-element state would multiply the state surface across ten backends for no use this library has. Wire one block per channel – the size is checked rather than silently unwrapping only the first element.
  • It wraps the difference; it does not round. The natural-looking alternative – adding ±2π according to round(d/2π) – agrees on ordinary jumps and is out by a whole turn wherever a jump is exactly ±π.
  • The inverse is Angle Wrap, which folds the result back into a principal interval.

Code facts#

FactValue
registered typeRobotics/Coordinate_Transforms/Angle_Unwrap
familyRobotics/Coordinate_Transforms
solver environment classICoreBlock_0_Robotics_1_Coordinate_Transforms_2_Angle_Unwrap
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Coordinate_Transforms/Angle_Unwrap/ICoreBlock_0_Robotics_1_Coordinate_Transforms_2_Angle_Unwrap.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Coordinate_Transforms/Angle_Unwrap/ICoreBlock_0_Robotics_1_Coordinate_Transforms_2_Angle_Unwrap.h
default size on canvas122 × 72 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubleu
2outICoreDoubley

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#

No config variable beyond the Sampling Time (s) every block carries.

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.

supportSupport::Both
Simulink pathdspsigops/Unwrap
port-count rulePortsParam::None
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
always setrunning = on, InputProcessing = Elements as channels (sample based)

Caveat (shown to the user): the Simulink block is pinned to its STREAMING form (running = on, sample-based InputProcessing): at its defaults it unwraps along the vector within one sample, which on a scalar stream is a pass-through rather than an unwrap. Its "tol" parameter does NOT cross and this block deliberately has no tolerance config -- measured, tol is inert in streaming mode (1.0, 2.4, pi, 3.5, 4.0 and 6.0 give byte-identical output). It defines no SampleTime either, so "Sampling Time (s)" stays on the ICore side

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).

Angle Unwrap — remove the 2*pi jumps from a wrapped angle stream y[0] = u[0]; d = u[k] - u[k-1] step = d - 2*pi*floor((d + pi)/(2*pi)); if step = -pi and d > 0 then step = +pi y[k] = y[k-1] + step

Measured against dspsigops/Unwrap pinned to its streaming form. It wraps the DIFFERENCE unconditionally and does not round; tol is inert and is therefore not exposed; and the Simulink defaults are a pass-through, which is why running and InputProcessing are fixedParams. See the header for the probe that settled each one.

The correction is carried as an accumulated offset rather than as the previous OUTPUT, so the emitted state is two doubles and a flag in every backend; y = u + corr keeps the output exact against the input rather than drifting through a running sum.

Sample results#

Angle Unwrap — Step: 0 -> 1 at t = 1 sAngle Unwrap — Step: 0 -> 1 at t = 1 s00.51012345t (s)in ICoreDouble-Out-0out ICoreDouble-Out-0

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0 … 1
rampRamp: slope 1 from t = 00 … 5.8
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-1 … 0.9996
tableRepeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-2 … 43.48

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__Coordinate_Transforms__Angle_Unwrap.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).