Is it possible to put a virtual sensor on the hull and measure the distance of this point to the water surface while taking into account the wave height?
Alternatively, you can also use the custom block SonicDist01.js
below which computes the altitude of a point Pos
defined in a input Frame
.
*.bic
Including the custom block in the *.bic file using:
dofile(spec.boatPath + "Blocks/SonicDist01.js");
The wave height altitude can then be defined as:
"Heave": BL.SonicDist01({
Pos: sensorSpec.rIMU,
}),
Where the sensorSpec.IMU
is the 3D position of the sensor in the input Frame
.
SonicDist01.js
Block.registerNewType("SonicDist01", function(name, r) {
var pos = clone(r.Pos);
var inputs = [
"InertialFrame",
"Frame",
"Ocean",
];
var fUpdate = function(input, callType) {
var sensorPosInInertial = input.Frame.pointInFrame(pos, input.InertialFrame);
var oceanHeight = input.Ocean.height(sensorPosInInertial[0], sensorPosInInertial[1]);
return sensorPosInInertial[2] - oceanHeight;
}
return {
block : Block.JS(name, inputs, fUpdate),
config : {
inputs : r.Inputs
},
};
});
The ocean model enables to query the altitude ocean-z at any x,y location using the ‘height()’ method. Hence, you can create a frame {YourFrame} with origin located at the virtual sensor position, get the world x,y for that frame, and then query the altitude ocean-z:
“myX” : “{YourFrame}.originInFrame({Root.InertialFrame})[0]”,
“myY” : “{YourFrame}.originInFrame({Root.InertialFrame})[1]”,
“myOceanZ” : “{Root.Ocean}.height({myX},{myY})”,
The distance from that frame origin (virtual sensor) to the ocean is finally obtained by subtracting the two z’s (ocean-z and frame-z):
“SensorWaterDistance” : “{myOceanZ} – {YourFrame}.originInFrame({Root.InertialFrame})[2]”
Note: to avoid creating unnecessary additional channels, variables can be written in a one line