using RobotNet10.Shared.Geometry; namespace RobotNet10.Shared.Sensor; /// /// Imu message (sensor_msgs/Imu) /// Contains data from an IMU (Inertial Measurement Unit) /// /// Accelerations should be in m/s^2 (not g's), and rotational velocity should be in rad/sec /// /// If the covariance of the measurement is known, it should be filled in (if all you know is the /// variance of each measurement, e.g. from the datasheet, just put those along the diagonal) /// A covariance matrix of all zeros will be interpreted as "covariance unknown", and to use the /// data a covariance will have to be assumed or gotten from some other source /// /// If you have no estimate for one of the data elements (e.g. your IMU doesn't produce an orientation /// estimate), please set element 0 of the associated covariance matrix to -1 /// If you are interpreting this message, please check for a value of -1 in the first element of each /// covariance matrix, and ignore the associated estimate. /// public struct Imu { /// /// Header with timestamp and frame ID /// public Header Header { get; set; } /// /// Orientation quaternion (geometry_msgs/Quaternion) /// public Quaternion Orientation { get; set; } /// /// Orientation covariance matrix (row-major about x, y, z axes) /// Size: 9 (3x3 matrix) /// public double[] OrientationCovariance { get; set; } /// /// Size of orientation covariance matrix (3x3 = 9 elements) /// public const int OrientationCovarianceSize = 9; /// /// Angular velocity (geometry_msgs/Vector3) /// public Vector3 AngularVelocity { get; set; } /// /// Angular velocity covariance matrix (row-major about x, y, z axes) /// Size: 9 (3x3 matrix) /// public double[] AngularVelocityCovariance { get; set; } /// /// Size of angular velocity covariance matrix (3x3 = 9 elements) /// public const int AngularVelocityCovarianceSize = 9; /// /// Linear acceleration (geometry_msgs/Vector3) /// public Vector3 LinearAcceleration { get; set; } /// /// Linear acceleration covariance matrix (row-major about x, y, z axes) /// Size: 9 (3x3 matrix) /// public double[] LinearAccelerationCovariance { get; set; } /// /// Size of linear acceleration covariance matrix (3x3 = 9 elements) /// public const int LinearAccelerationCovarianceSize = 9; /// /// Default constructor /// public Imu() { Header = new Header(); Orientation = new Quaternion(); OrientationCovariance = new double[OrientationCovarianceSize]; AngularVelocity = new Vector3(); AngularVelocityCovariance = new double[AngularVelocityCovarianceSize]; LinearAcceleration = new Vector3(); LinearAccelerationCovariance = new double[LinearAccelerationCovarianceSize]; } /// /// Constructor with parameters /// public Imu( Header header, Quaternion orientation, double[] orientationCovariance, Vector3 angularVelocity, double[] angularVelocityCovariance, Vector3 linearAcceleration, double[] linearAccelerationCovariance) { Header = header; Orientation = orientation; if (orientationCovariance == null || orientationCovariance.Length != OrientationCovarianceSize) { throw new ArgumentException($"Orientation covariance array must have {OrientationCovarianceSize} elements", nameof(orientationCovariance)); } OrientationCovariance = orientationCovariance; AngularVelocity = angularVelocity; if (angularVelocityCovariance == null || angularVelocityCovariance.Length != AngularVelocityCovarianceSize) { throw new ArgumentException($"Angular velocity covariance array must have {AngularVelocityCovarianceSize} elements", nameof(angularVelocityCovariance)); } AngularVelocityCovariance = angularVelocityCovariance; LinearAcceleration = linearAcceleration; if (linearAccelerationCovariance == null || linearAccelerationCovariance.Length != LinearAccelerationCovarianceSize) { throw new ArgumentException($"Linear acceleration covariance array must have {LinearAccelerationCovarianceSize} elements", nameof(linearAccelerationCovariance)); } LinearAccelerationCovariance = linearAccelerationCovariance; } }