|
FhSim
3.1.0
Marine systems simulation
|
#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. | |
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.
@group block and appears in no model list.
|
explicit |
Registers the body ports and reads the mounting parameters.
| creator | The creator of the owning SimObject. |
| 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.
| mountOffset | Sensor position in the body frame, m. |
| mountDirection | Beam direction in the body frame, need not be unit. |
| void SensorFrame::BeamDirection | ( | double | T, |
| const double * | X, | ||
| double | out[3] | ||
| ) | const |
Calculates the beam direction in NED from the body ports.
| T | The simulation time. |
| X | The state vector. |
| out | The beam direction in NED, same length as MountDirection. |
| void SensorFrame::BeamDirectionOf | ( | const double | bodyQuaternion[4], |
| double | out[3] | ||
| ) | const |
Calculates the beam direction in NED for a given body attitude.
| bodyQuaternion | The body attitude, [q0,q1,q2,q3]. |
| out | The beam direction in NED. |
| void SensorFrame::SensorPosition | ( | double | T, |
| const double * | X, | ||
| double | out[3] | ||
| ) | const |
Calculates the sensor position in NED from the body ports.
| T | The simulation time. |
| X | The state vector. |
| out | The sensor position in NED, m. |
| 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.
| bodyPosition | The body origin in NED, m. |
| bodyQuaternion | The body attitude, [q0,q1,q2,q3]. |
| out | The sensor position in NED, m. |