FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SensorFrame Class Reference

#include <SensorFrame.h>

Public Member Functions

 SensorFrame (ISimObjectCreator *creator)
 
 SensorFrame (const double mountOffset[3], const double mountDirection[3])
 
void SensorPosition (double T, const double *X, double out[3]) const
 
void BeamDirection (double T, const double *X, double out[3]) const
 
void SensorPositionOf (const double bodyPosition[3], const double bodyQuaternion[4], double out[3]) const
 
void BeamDirectionOf (const double bodyQuaternion[4], double out[3]) const
 
const double * MountOffset () const
 The mounting offset in the body frame, m.
 
const double * MountDirection () const
 The beam direction in the body frame.
 

Detailed Description

Locates a sensor that is rigidly mounted on a moving body.

Every AUV sensor needs the same four things: the carrier body's position and attitude, and its own mounting offset and beam direction in the body frame. A sensor holds one SensorFrame instead of repeating that plumbing.

The constructor creates the Pos(3) and Quater(4) inports on the owning SimObject and reads the MountOffset(3) and MountDirection(3) parameters, so the owner only has to keep the member alive.

The quaternion convention is scalar first, [q0,q1,q2,q3] = [w,x,y,z], which is what the FhSim 6-DOF bodies publish. The quaternion is normalised defensively on every use; if it ever deviates from unit length by more than kQuaternionTolerance a single warning is emitted for the lifetime of the object, because a drifting quaternion is a modelling fault worth one message and not worth a message per time step.

Note
This is a helper, not a SimObject, so it has no @group block and appears in no model list.

Constructor & Destructor Documentation

◆ SensorFrame() [1/2]

SensorFrame::SensorFrame ( ISimObjectCreator *  creator)
explicit

Registers the body ports and reads the mounting parameters.

Parameters
creatorThe creator of the owning SimObject.

◆ SensorFrame() [2/2]

SensorFrame::SensorFrame ( const double  mountOffset[3],
const double  mountDirection[3] 
)

Constructs a frame with the mounting geometry given directly.

No ports are registered, so SensorPosition and BeamDirection must not be called; use SensorPositionOf and BeamDirectionOf instead. This constructor exists so the geometry can be unit tested without a host simulation.

Parameters
mountOffsetSensor position in the body frame, m.
mountDirectionBeam direction in the body frame, need not be unit.

Member Function Documentation

◆ BeamDirection()

void SensorFrame::BeamDirection ( double  T,
const double *  X,
double  out[3] 
) const

Calculates the beam direction in NED from the body ports.

Parameters
TThe simulation time.
XThe state vector.
outThe beam direction in NED, same length as MountDirection.

◆ BeamDirectionOf()

void SensorFrame::BeamDirectionOf ( const double  bodyQuaternion[4],
double  out[3] 
) const

Calculates the beam direction in NED for a given body attitude.

Parameters
bodyQuaternionThe body attitude, [q0,q1,q2,q3].
outThe beam direction in NED.

◆ SensorPosition()

void SensorFrame::SensorPosition ( double  T,
const double *  X,
double  out[3] 
) const

Calculates the sensor position in NED from the body ports.

Parameters
TThe simulation time.
XThe state vector.
outThe sensor position in NED, m.

◆ SensorPositionOf()

void SensorFrame::SensorPositionOf ( const double  bodyPosition[3],
const double  bodyQuaternion[4],
double  out[3] 
) const

Calculates the sensor position in NED for a given body pose.

Parameters
bodyPositionThe body origin in NED, m.
bodyQuaternionThe body attitude, [q0,q1,q2,q3].
outThe sensor position in NED, m.

The documentation for this class was generated from the following file: