Generated reference › World Magnetic Model — Robotics/Gravity Models
kind: generated#block#robotics-gravity-models

World Magnetic Model — Robotics/Gravity Models

WMM

Robotics/Gravity_Models/World_Magnetic_Model · 0 input / 0 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.

World Magnetic Model

Robotics / Gravity Models

The Earth's main magnetic field from the joint NOAA/BGS World Magnetic Model, a spherical-harmonic expansion of degree 12 whose Gauss coefficients gnm, hnm move linearly with time from the model's epoch. At a geodetic position and a decimal year t the block reports the field vector in the local north-east-down frame and the four readings derived from it:

  • B = [X; Y; Z] nT, from the potential V = a·Σn=1..12(a/r)n+1Σm=0..n (gnmcos mλ + hnmsin mλ)·Pnm(cosθ), evaluated in geocentric spherical coordinates and rotated into the geodetic frame.
  • H = √(X² + Y²), F = √(H² + Z²), D = atan2(Y, X) and I = atan2(Z, H), the last two in degrees.

Ports

  • h – height above the WGS84 ellipsoid in metres, [1,1].
  • lat – geodetic latitude in degrees, north positive, [1,1]. A latitude past a pole is folded back (±180 − φ) and its longitude turned half a revolution, as the reference does.
  • lon – geodetic longitude in degrees, east positive, [1,1]; wrapped to [−180, 180].
  • dyear – the time as a decimal year (2025.5 is halfway through 2025), [1,1]. Outside the model's five-year window the coefficients are extrapolated rather than clamped.
  • B – the field vector [X; Y; Z] in nT, a [3,1]: north, east and down.
  • H – horizontal intensity in nT, [1,1].
  • D – declination in degrees, east positive, [1,1].
  • I – inclination in degrees, down positive, [1,1].
  • F – total intensity in nT, [1,1].

Parameters

  • Model – which release's coefficients run. This selects a whole coefficient set, not a value, and each is valid for the five years from its epoch:
    • WMM2000 (2000-2005), WMM2005 (2005-2010), WMM2010 (2010-2015) – the superseded releases, kept so an old recording can be reproduced.
    • WMM2015 V1 (2015-2020) – deprecated by NOAA: it degrades in the Arctic. WMM2015 V2 (2015-2020) is its 2019 correction and the one to use.
    • WMM2020 (2020-2025) and WMM2025 (2025-2030) – the current pair; WMM2025 is the default, as in Simulink.
  • 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 chosen model's coefficients are inlined at export time as two tables of 169 numbers (the field and its yearly rate), together with the Schmidt factors and the recursion constants of the Legendre functions; the decimal year stays a port, so one exported core covers every date. The synthesis itself is emitted once, as loops, so all ten targets run the same statements in the same order.

The three hardware targets are simulation-only: sines, arctangents, square roots and a degree-12 recursion do not belong in a Q16.16 datapath, so the arithmetic runs in real and only the ports are fixed point. Q16.16 also bounds every port to about ±32767, which for this block means a height below about 32.7 km and a field below 32767 nT – the Earth's field exceeds that over most of the globe, so a hardware core is honest only where the field is weak (the South Atlantic, where it falls to ~22000 nT). PLC Structured Text has neither floor nor atan2 and rebuilds both from TRUNC and ATAN.

Simulink bridge

Import and export, mapped to Aerospace Blockset's aerolibgravity2/World Magnetic Model. Model → model, value for value (WMM2025 (2025-2030) → WMM2025 (2025-2030) and so on for all seven), which is 1:1 and lossless in both directions.

Seven Simulink parameters are always implied and carry no configuration here: units is always Metric (MKS) (English units – feet and nanogauss – do not cross), time_in is always on so the decimal year arrives on the fourth port rather than as a month/day/year dialog (no configuration here can add or remove a port), action is always Warning, and h_out, dec_out, inc_out and ti_out are always on so all five outputs exist. An imported block holding any other value of the seven is reported rather than silently accepted. action only decides whether Simulink reports a position or date outside the model's range; the values are the same either way, and this block computes them without a report. The Custom model, which reads a NOAA .COF file at model load, does not cross: an exported core carries its coefficients as numbers and has no file to read. The Simulink block defines no SampleTime (measured), so the rate stays on the ICore side.

Notes

  • Algebraic and stateless: the output depends only on this sample's inputs.
  • Not linear, so the block carries no state space and model reduction correctly reports it as unmergeable.
  • At a geographic pole the east component is a limit rather than a quotient (sinθ is zero there), and the block takes the reference's own special case for it. Declination is still defined, but it changes by a whole revolution as the pole is crossed.
  • Verified against R2026a: over 400 positions and dates – both poles exactly, latitudes of 95, 181 and 270, a longitude of −370, heights from −1 km to 850 km, dates inside and outside the five-year window – the Simulink block and this arithmetic agree to 1.3×10−15 relative.
  • The model is a coefficient set, not an approximation order: WMM2020 and WMM2025 differ by about 100 nT at the same place and date, which is the field's own drift, not an error in either.

Code facts#

FactValue
registered typeRobotics/Gravity_Models/World_Magnetic_Model
familyRobotics/Gravity_Models
solver environment classICoreBlock_0_Robotics_1_Gravity_Models_2_World_Magnetic_Model
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Gravity_Models/World_Magnetic_Model/ICoreBlock_0_Robotics_1_Gravity_Models_2_World_Magnetic_Model.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Gravity_Models/World_Magnetic_Model/ICoreBlock_0_Robotics_1_Gravity_Models_2_World_Magnetic_Model.h
default size on canvas180 × 140 px
ports at insert? in, ? out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubleh
2inICoreDoublelat
3inICoreDoublelon
4inICoreDoubledyear
5outICoreDoubleB
6outICoreDoubleH
7outICoreDoubleD
8outICoreDoubleI
9outICoreDoubleF

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 variableDefaultSimulink parameter
Modeloptions~~ICoreGeomagneticSupport::wmmOptionName(6)model

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 pathaerolibgravity2/World Magnetic Model
port-count rulePortsParam::None
SampleTime parameterno — the counterpart defines none; the rate stays on the ICore side
always setunits = Metric (MKS), time_in = on, action = Warning, h_out = on, dec_out = on, inc_out = on, ti_out = on
ICore configSimulink parameterValue translation
ModelmodelWMM2000 (2000-2005) → WMM2000 (2000-2005), WMM2005 (2005-2010) → WMM2005 (2005-2010), WMM2010 (2010-2015) → WMM2010 (2010-2015), WMM2015 V1 (2015-2020) → WMM2015 V1 (2015-2020), WMM2015 V2 (2015-2020) → WMM2015 V2 (2015-2020), WMM2020 (2020-2025) → WMM2020 (2020-2025), WMM2025 (2025-2030) → WMM2025 (2025-2030)

Caveat (shown to the user): the position crosses on three scalar ports (height in metres, latitude and longitude in degrees) and the time on a fourth as a decimal year; the field comes back as a [3,1] [X; Y; Z] in nT plus H, D, I and F. 'units' is always Metric (MKS): English units (feet, nanogauss) do not cross. 'time_in' is always on -- the month/day/year dialog would remove the fourth input port, and no configuration here can move a port. 'h_out', 'dec_out', 'inc_out' and 'ti_out' are always on, so all five outputs exist. 'action' is always Warning; it only decides whether Simulink reports a position or a date outside the model's range, and the values are identical either way. The Custom model does not cross: it reads a NOAA .COF file at model load, and an exported core carries numbers rather than a file. The Simulink block has no SampleTime, so the rate stays on the ICore side. ⚠ Model IS A MODE: each release is a different coefficient set and each is rigged separately

Catalog contract: src/ICoreBlocks/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).

World Magnetic Model -- the Earth's main magnetic field, WMM2000 .. WMM2025 Inputs h (metres), latitude and longitude (degrees), the time as a decimal year Outputs [X; Y; Z] nT in north-east-down, H nT, D degrees, I degrees, F nT

The arithmetic is shared with the International Geomagnetic Reference Field and lives in ICoreGeomagneticSupport: one spherical-harmonic synthesis, ten export targets, and a coefficient set per model. This file is the block around it -- the ports, the model choice, and the Simulink mapping.

MEASURED against R2026a's aerolibgravity2/World Magnetic Model over 400 positions and dates (both poles exactly, latitudes of 95, 181, 270, a longitude of -370, heights from -1 km to 850 km, dates through and past the five-year window): this arithmetic reproduces the block to <= 1.3e-15 relative. It is MATLAB's own wrldmagm.m transcribed, which agrees with the block to the same 1e-15 -- so the block, the function and this file are one algorithm.

⚠ THE DECIMAL YEAR IS A PORT, not a date parameter. The Simulink block offers both (time_in); the port is its default and the only one that carries a time-varying field, so it is what crosses. Out of the model's five-year window the coefficients are EXTRAPOLATED, which is what the Simulink block does too at action None or Warning (measured at 2024, 2031 and 2040 against WMM2025).

⚠ EVERY MODEL IS A MODE: the seven releases are seven coefficient sets, baked into an export.

ALGEBRAIC and STATELESS.

Sample results#

World Magnetic Model — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleWorld Magnetic Model — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample05e41e51.5e5012345t (s)in ICoreDouble-Out-0in ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0 [3x1] entry 0out ICoreDouble-Out-1out ICoreDouble-Out-2
tin ICoreDouble-Out-0in ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0 [3x1] entry 0out ICoreDouble-Out-1out ICoreDouble-Out-2
0-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
0.40.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
0.8-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
1.20.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
1.6-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
20.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
2.4-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
2.80.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
3.2-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
3.60.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
4-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
4.40.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1
4.8-2-2-2[7.386e4, -1.351e5, -3.271e4]1.54e5-61.34
5.20.50.50.5[6.759e4, -1.224e5, -3.959e4]1.399e5-61.1

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)6.644e4 … 6.878e4
rampRamp: slope 1 from t = 05.633e4 … 6.878e4
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias6.644e4 … 7.124e4
stepStep: 0 -> 1 at t = 1 s6.644e4 … 6.878e4

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit d3366c0179cc3d88aa09e88058f22d3f108eb9e3 · produced by docsSample --out <folder> --blocks World_Magnetic_Model --steps 60 · data docs/generated/samples/Robotics__Gravity_Models__World_Magnetic_Model.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).