SensorConfiguration#
A simple coordinate system that allows for storing sensor and target offsets.
Supported sensors are:
compass: Affects
Sensordata.headingwith yaw offsetposition system: Affects Sensordata gps variables with x,y and z offset
depth sensor: Affects Sensordata.depth variables with x,y and z offset
attitude system: Affects Sensordata imu variables with yaw, pitch and roll offset
The class allows for registering multiple targets (e.g. “MBES” and “SBES”) with respective PositionOffsets. Once targets are registered, the system can be used to compute the georeferenced of the targets using a Sensordata object. (see usage below)
Note 1: The returned Geolocation object type depends on the input Sensordata object.
A
datastructures.SensordataUTMobject will cause compute_target_position to returndatastructures.GeolocationUTMA
datastructures.SensordataLatLonwill cause compute_target_position to returndatastructures.GeolocationLatLon… and so on
Example usage#
# import this module
import themachinethatgoesping.navigation as nav
# initialize
scs = nav.SensorConfiguration()
# add sensor offsets
scs.set_heading_source("compass",yaw=9)
scs.set_depth_source("altimeter",0, 0, 1)
scs.set_position_source("gps",1, 2, 3)
scs.set_attitude_source("mru",10, -10, -30)
# add a target with target offsets
scs.add_target(
target_id = "mbes",
x = 1,
y = 2,
z = 3,
yaw = 0,
pitch = 0,
roll = 0)
# create a object that contains sensor data
sensor_data = nav.datastructures.SensordataLatLon(
latitude = 53,
longitude = 10,
depth = 3,
heave = -1,
heading = 45,
roll = 2,
pitch = -3)
# compute target position from the specified sensor data
target_position = scs.compute_target_position("mbes", sensor_data)
#print georeferenced target position
print(target_position)
# GeolocationLatLon
# *****************
# - latitude: 53°0'0.0"N [ddd°mm',ss.s''N/S]
# - longitude: 53°0'0.0"E [ddd°mm',ss.s''E/W]
# - z: 6.51 [positive downwards, m]
# - yaw: 36.00 [90 ° at east]
# - pitch: 10.72 [° positive bow up]
# - roll: 30.90 [° positive port up]
Module API#
A coordinate system that allows for specifying sensor offsets (e.g. gps antenna and attitude sensor) and target offsets (e.g. MBES). Call the class and specify target_id and current sensor data to derive the geolocation and attitude of the specified targets
Construct a new, empty Sensor Coordinate System object After construction: add sensor offsets and targets (offsets) Then compute target positions for sensor data
- add_target(self, target_id: str, target_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) None
Overloaded function.
add_target(self, target_id: str, x: float, y: float, z: float, yaw: float, pitch: float, roll: float) -> None
add a target (e.g. MBES) with offsets to the sensor position system
- Parameters:
target_id – name of the target for reference
x – x-offset of the target (in meters, positive forward)
y – y-offset of the target (in meters, positive starboard)
z – z-offset of the target (in meters, positive down)
yaw – yaw offset of the target (right-handed around the z-axis) (in degrees, 90° = east)
pitch – pitch offset of the target (right-handed around the y-axis) (in degrees, positive = bow up)
roll – roll offset of the target (right-handed around the x-axis) (in degrees, positive = port up)
add_target(self, target_id: str, target_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) -> None
add a target (e.g. MBES) with offsets to the sensor position system
- Parameters:
target_id – name of the target for reference
target_offsets – mounting offsets of the target
Register (or overwrite) a single named subarray offset for a target.
A subarray offset is a small SensorPose in the target (transducer) frame that compute_target_pose can add to the target pose to obtain the pose of a specific transmit subarray or the receive-array phase center. The position is always applied; the rotation is only composed when it is not the identity (see SensorPose::has_zero_rotation).
- Parameters:
target_id – parent target
subarray_id – name of the subarray (e.g. “0”/”1”/”2” for tx port/center/starboard, “RX”)
subarray_offsets – offset pose in the target frame
add targets (e.g. MBES) with given target_ids and offsets to the sensor position system
- Parameters:
targets – map<target_id, target_offsets> of target offsets
Check if the given SensorConfiguration includes a target (offsets) that is incompatible with the given SensorConfiguration targets
- Returns:
false if the same target_id is registered with different offsets, true otherwise
Compute the location of the active position-system reference point relative to the vessel reference point, in the surface (reference- heading) frame.
This is the heading-referenced translation between the position system and the vessel reference point: vessel_rotation(reference_heading) · position_source_lever_arm. It carries the full horizontal antenna lever arm (not only its vertical component), so it can be used to convert beam positions referenced to the positioning system (e.g. Kongsberg .all XYZ88) into the vessel-reference-point convention (e.g. Kongsberg .kmall).
- Parameters:
sensor_data – Sensordata (heading/pitch/roll are used)
reference_heading_in_degrees – heading (deg) removed from the orientation (transmit heading); 0 = keep the absolute world heading
at_waterline – if true, replace the antenna height by the waterline offset, i.e. project the position-system point onto the water surface (the horizontal reference of the .all XYZ88 beam positions); if false, use the true antenna height (position_source.z)
- Returns:
{x, y, z} of the position-system reference point in the surface frame (metres)
- compute_target_pose(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: Sensordata, reference_heading_in_degrees: float) themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Overloaded function.
compute_target_pose(self, target_id: str, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.Sensordata, reference_heading_in_degrees: float, subarray_id: str = '', subarray_pose: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose | None = None) -> themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Compute the ready-to-trace pose (position + ship-frame orientation) of a target.
Unlike compute_target_position (which returns a geolocation), this bakes the target installation, the vessel attitude and the removal of a common reference heading into a single pose, so a raytracer can consume it without re-composing installation/attitude/heading. The orientation is vessel_rotation(reference_heading) · target_installation and the position is that SAME reference-relative vessel_rotation applied to the body-frame lever arm (z reduced to the depth below the waterline). Pass the SAME reference_heading (the heading at transmit time) for every target of a ping so all poses share one surface frame.
- Parameters:
target_id – name of the target (e.g. “MBES”)
sensor_data – Sensordata (heading/pitch/roll + depth/heave)
reference_heading_in_degrees – heading (deg) removed from the orientation (transmit heading)
subarray_id – optional name of a registered subarray offset of the target to add to the pose (e.g. “0”/”1”/”2” for a transmit subarray, “RX” for the receive phase center); “” = none
subarray_pose – optional explicit subarray offset (target frame) that overrides
subarray_id;handy for debugging or one-off corrections
- Returns:
target pose (position + ship-frame Rotation)
compute_target_pose(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.Sensordata, reference_heading_in_degrees: float) -> themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Compute the ready-to-trace pose of a target from its (already resolved) offsets.
Same as compute_target_pose(target_id, …) but takes the target mounting offsets directly (e.g. from get_target(target_id, subarray_id)); the string_view overload builds on this one.
- Parameters:
target – target mounting offsets (optionally already combined with a subarray offset)
sensor_data – Sensordata (heading/pitch/roll + depth/heave)
reference_heading_in_degrees – heading (deg) removed from the orientation (transmit heading)
- Returns:
target pose (position + ship-frame Rotation)
- compute_target_position(self, target_id: str, sensor_data: SensordataUTM) GeolocationUTM
- compute_target_position(self, target_id: str, sensor_data: SensordataLocal) GeolocationLocal
- compute_target_position(self, target_id: str, sensor_data: Sensordata) GeolocationLocal
- compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: SensordataLatLon) GeolocationLatLon
- compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: SensordataUTM) GeolocationUTM
- compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: SensordataLocal) GeolocationLocal
- compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: Sensordata) GeolocationLocal
Overloaded function.
compute_target_position(self, target_id: str, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataLatLon) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLatLon
Compute the position of the target “target_id” based on the sensor data “sensor_data”
- Parameters:
target_id – name of the target (e.g. “MBES”)
sensor_data – SensordataLatLon / this structure includes latitude and longitude information
- Returns:
datastructures::GeolocationLatLon / this structure includes latitude and longitude information
compute_target_position(self, target_id: str, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataUTM) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationUTM
Compute the position of the target “target_id” based on the sensor data “sensor_data”
- Parameters:
target_id – name of the target (e.g. “MBES”)
sensor_data – SensordataUTM / this structure includes northing/easting and utm zone or hemisphere information
- Returns:
datastructures::GeolocationUTM / this structure includes northing/easting and utm zone or hemisphere information
compute_target_position(self, target_id: str, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataLocal) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLocal
Compute the position of the target “target_id” based on the sensor data “sensor_data”
- Parameters:
target_id – name of the target (e.g. “MBES”)
sensor_data – SensordataLocal / this structure includes northing/easting but no zone or hemisphere information
- Returns:
datastructures::GeolocationLocal / this structure includes northing/easting but no zone or hemisphere information
compute_target_position(self, target_id: str, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.Sensordata) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLocal
Compute the position of the target “target_id” based on the sensor data “sensor_data”
- Parameters:
target_id – name of the target (e.g. “MBES”)
sensor_data – Sensordata / this structure includes no coordinate information
- Returns:
datastructures::GeolocationLocal / this structure includes northing and east, which are set relative to the sensor coordinate system center
compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataLatLon) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLatLon
Compute the position of a target from its mounting offsets and the sensor data.
- Parameters:
target – target mounting offsets (e.g. from get_target)
sensor_data – SensordataLatLon (latitude/longitude)
- Returns:
datastructures::GeolocationLatLon
compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataUTM) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationUTM
Compute the position of a target from its mounting offsets and the sensor data.
- Parameters:
target – target mounting offsets (e.g. from get_target)
sensor_data – SensordataUTM (northing/easting + utm zone/hemisphere)
- Returns:
datastructures::GeolocationUTM
compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.SensordataLocal) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLocal
Compute the position of a target from its mounting offsets and the sensor data.
- Parameters:
target – target mounting offsets (e.g. from get_target)
sensor_data – SensordataLocal (northing/easting, no zone/hemisphere)
- Returns:
datastructures::GeolocationLocal
compute_target_position(self, target: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose, sensor_data: themachinethatgoesping.navigation_nanopy.datastructures.Sensordata) -> themachinethatgoesping.navigation_nanopy.datastructures.GeolocationLocal
Compute the position of a target from its mounting offsets and the sensor data.
- Parameters:
target – target mounting offsets (e.g. from get_target)
sensor_data – Sensordata (no coordinate information)
- Returns:
datastructures::GeolocationLocal (relative to the position system center)
return a copy using the c++ default copy constructor
Get the attitude sensor offsets
- Returns:
const datastructures::SensorPose& offsets of the attitude sensor
Get the registered depth sensor offsets
- Returns:
const datastructures::SensorPose& offsets of the depth sensor
Get the registered compass offsets
- Returns:
const datastructures::SensorPose& offsets of the compass
Echosounder model name, or empty string if not set.
Get the registered position system offsets
- Returns:
const datastructures::SensorPose& offsets of the position system
Get whether the position source is motion compensated.
See set_position_source_motion_compensated.
- Returns:
true if the logged position is already re the vessel reference point
- get_target(self, target_id: str, subarray_id: str, subarray_pose: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose | None = None) themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Overloaded function.
get_target(self, target_id: str) -> themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Get stored target offsets of a specified target
- Parameters:
target_id – name of the registered target
- Returns:
const datastructures::SensorPose& offsets of the target
get_target(self, target_id: str, subarray_id: str, subarray_pose: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose | None = None) -> themachinethatgoesping.navigation_nanopy.datastructures.SensorPose
Get a target’s static pose, optionally combined with a subarray phase center (vessel-static frame).
Get the ids of the registered targets
- Returns:
std::vector<std::string_view>
Get a single registered subarray offset.
- Parameters:
target_id – parent target
subarray_id – name of the subarray
- Returns:
the subarray offset pose (throws std::out_of_range if not registered)
Ids of the subarray offsets registered for a target (empty if none).
Get all subarray offsets of a target.
- Parameters:
target_id – parent target
- Returns:
map<subarray_id, offset pose> (throws std::out_of_range if the target has none)
Get the map of stored target offsets objects
- Returns:
const std::unordered_map<std::string, datastructures::SensorPose>&
Transducer configuration string, or empty string if not set.
Get the receive transducer registered for a transducer channel.
- Parameters:
channel_id – The ID of the transducer channel.
- Returns:
The receive transducer as a (target_id, default_subarray) pair.
Get the receive target (mounting offsets) registered for a transducer channel.
Convenience wrapper that resolves get_transducer_receive_id(channel_id) and returns the matching target pose (get_target(target_id, subarray)).
- Parameters:
channel_id – The ID of the transducer channel.
- Returns:
The receive target offsets in the vessel-static frame.
Get the transmit transducer registered for a transducer channel.
- Parameters:
channel_id – The ID of the transducer channel.
sector – Optional transmit sector number. If set and per-sector subarrays are registered for the channel, the returned subarray is the one registered for that sector; otherwise (no sector given, or no per-sector subarrays registered) the default subarray is returned.
- Returns:
The transmit transducer as a (target_id, subarray) pair.
Get the combined transmit-receive transducer for a transducer channel.
- Parameters:
channel_id – The ID of the transducer channel.
- Returns:
The combined transmit-receive transducer as a (target_id, default_subarray) pair.
Get the combined transmit-receive target (mounting offsets) for a transducer channel.
Convenience wrapper that resolves get_transducer_transmit_receive_id(channel_id) and returns the matching target pose (get_target(target_id, subarray)).
- Parameters:
channel_id – The ID of the transducer channel.
- Returns:
The combined transmit-receive target offsets in the vessel-static frame.
Get the transmit target (mounting offsets) registered for a transducer channel.
Convenience wrapper that resolves get_transducer_transmit_id(channel_id, sector) and returns the matching target pose (get_target(target_id, subarray)).
- Parameters:
channel_id – The ID of the transducer channel.
sector – Optional transmit sector number (see get_transducer_transmit_id).
- Returns:
The transmit target offsets in the vessel-static frame.
Compute the offset-corrected vessel orientation as a Rotation.
Applies the registered sensor mounting offsets to the raw sensor_data attitude: the attitude source (IMU) mounting offset is removed with a rotation operation (raw ⊗ offset⁻¹, i.e. yaw/pitch/roll are NOT simply added) and the heading source offset is subtracted from the heading – both only when they are not already applied to the logged data (SensorPose::ypr_offsets_applied). The heading is then expressed relative to reference_heading_in_degrees. Use rotation.ypr() to obtain the {yaw, pitch, roll} angles.
- Parameters:
sensor_data – Sensordata (only heading, pitch and roll are used)
reference_heading_in_degrees – heading (deg) removed from the orientation so the result is expressed in the surface frame of that heading (0 = keep the absolute world heading); for a receive pose sampled after transmit this keeps the residual yaw (vessel turn since transmit)
- Returns:
vessel orientation (Rotation), heading measured relative to reference_heading
Get the waterline offset Negative waterline offset means that z=0 is below the waterline
- Returns:
waterline_offset
Checks if the sensor configuration has a target with the specified ID.
- Parameters:
target_id – The ID of the target to check for.
- Returns:
True if the sensor configuration has the target, false otherwise.
true if the target has a subarray offset with the given id.
true if the target has any registered subarray offsets.
Check if a transducer channel with the specified ID is registered.
- Parameters:
channel_id – The ID of the transducer channel.
- Returns:
True if the transducer channel is registered, false otherwise.
hash function implemented using binary_hash
Return object information as string
Print object information (optionA: True = one row per target, False = transposed table)
Register a transducer channel with its corresponding transducer IDs (tx, rx, trx), their default subarrays and optional per-transmit- sector subarrays.
- Parameters:
channel_id – The ID of the transducer channel.
tx_id – The ID of the transmit transducer.
rx_id – The ID of the receive transducer.
trx_id – The ID of the combined transmit-receive transducer.
tx_default_sub – The default subarray of the transmit transducer (empty for none).
rx_default_sub – The default subarray of the receive transducer (empty for none).
trx_default_sub – The default subarray of the transmit-receive transducer (empty for none).
tx_sector_subarrays – Optional subarray id per transmit sector. When non-empty, get_transducer_transmit_id(channel_id, sector) returns the subarray for that sector; when empty it always returns tx_default_sub.
Remove the target with the specified target_id
- Parameters:
target_id – name of the registered target
Remove all subarray offsets of a target.
Remove all stored targets
- set_attitude_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) None
Overloaded function.
set_attitude_source(self, name: str, yaw: float, pitch: float, roll: float) -> None
Set the attitude sensor offsets
- Parameters:
sensor_offsets – offsets structure (only yaw, pitch and roll are used)
set_attitude_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) -> None
Set the attitude sensor offsets
- Parameters:
yaw – yaw offset of the attitude sensor (right-handed around the z-axis) (in degrees, 90° = east)
pitch – pitch offset of the attitude sensor (right-handed around the y-axis) (in degrees, positive = bow up)
roll – roll offset of the attitude sensor (right-handed around the x-axis) (in degrees, positive = port up)
- set_depth_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) None
Overloaded function.
set_depth_source(self, name: str, x: float, y: float, z: float) -> None
Set the depth sensor offsets
- Parameters:
x – x-offset of the depth sensor (in meters, positive forward)
y – y-offset of the depth sensor (in meters, positive starboard)
z – z-offset of the depth sensor (in meters, positive down)
set_depth_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) -> None
Set the depth sensor offsets
- Parameters:
sensor_offsets – offsets structure (only x, y and z are used)
- set_heading_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) None
Overloaded function.
set_heading_source(self, name: str, yaw: float) -> None
Set the compass offsets
- Parameters:
yaw – yaw offset of the compass (right-handed around the z-axis) (in degrees, 90° = east)
set_heading_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) -> None
Set the compass offsets
- Parameters:
sensor_offsets – offsets structure (only yaw is used)
Set the echosounder model name (e.g. “EM2040”, “EM710”).
- set_position_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) None
Overloaded function.
set_position_source(self, name: str, x: float, y: float, z: float) -> None
Set the position system offsets
- Parameters:
x – x-offset of the depth sensor (in meters, positive forward)
y – y-offset of the depth sensor (in meters, positive starboard)
z – z-offset of the depth sensor (in meters, positive down)
set_position_source(self, sensor_offsets: themachinethatgoesping.navigation_nanopy.datastructures.SensorPose) -> None
Set the position system offsets
- Parameters:
sensor_offsets – offsets structure (only x, y and z are used)
Set whether the position source is motion compensated.
When true, the logged position is already referenced to the vessel reference point (the PU applied the antenna-to-reference-point lever arm, e.g. Kongsberg .all P{n}M=1 or .kmall POSI C=On). In that case compute_position_system_offset returns {0,0,0} instead of the geometric antenna lever arm, so beam positions referenced to the positioning system are not double-corrected.
- Parameters:
motion_compensated – true if the position is already re the vessel reference point
Select the print()/info_string() table layout: True = one row per target (default), False = transposed (fields x/y/z/… as rows, records as columns, explanation column).
Replace all subarray offsets of a target with the given map.
- Parameters:
target_id – parent target
subarrays – map<subarray_id, offset pose in the target frame>
Set the transducer configuration string (e.g. “DualRx”, “SingleTxSingleRx”, “STC0”).
Set the waterline offset Negative waterline offset means that z=0 is below the waterline
- Parameters:
waterline_offset
convert object to bytearray
Unregister all transducer channels.
Note
This will remove all registered transducer channels.
Unregister a transducer channel with the specified ID.
- Parameters:
channel_id – The ID of the transducer channel to unregister.
Return the SensorConfiguration object without registered targets
- Returns:
SensorConfiguration