commonMain.com.divpundir.mavlink.definitions.ardupilotmega.Ahrs2.kt Maven / Gradle / Ivy
package com.divpundir.mavlink.definitions.ardupilotmega
import com.divpundir.mavlink.api.GeneratedMavField
import com.divpundir.mavlink.api.GeneratedMavMessage
import com.divpundir.mavlink.api.MavMessage
import com.divpundir.mavlink.serialization.MavDataDecoder
import com.divpundir.mavlink.serialization.MavDataEncoder
import com.divpundir.mavlink.serialization.encodeFloat
import com.divpundir.mavlink.serialization.encodeInt32
import com.divpundir.mavlink.serialization.safeDecodeFloat
import com.divpundir.mavlink.serialization.safeDecodeInt32
import com.divpundir.mavlink.serialization.truncateZeros
import kotlin.Byte
import kotlin.ByteArray
import kotlin.Float
import kotlin.Int
import kotlin.UInt
import kotlin.Unit
/**
* Status of secondary AHRS filter if available.
*
* @param roll Roll angle.
* units = rad
* @param pitch Pitch angle.
* units = rad
* @param yaw Yaw angle.
* units = rad
* @param altitude Altitude (MSL).
* units = m
* @param lat Latitude.
* units = degE7
* @param lng Longitude.
* units = degE7
*/
@GeneratedMavMessage(
id = 178u,
crcExtra = 47,
)
public data class Ahrs2(
/**
* Roll angle.
* units = rad
*/
@GeneratedMavField(type = "float")
public val roll: Float = 0F,
/**
* Pitch angle.
* units = rad
*/
@GeneratedMavField(type = "float")
public val pitch: Float = 0F,
/**
* Yaw angle.
* units = rad
*/
@GeneratedMavField(type = "float")
public val yaw: Float = 0F,
/**
* Altitude (MSL).
* units = m
*/
@GeneratedMavField(type = "float")
public val altitude: Float = 0F,
/**
* Latitude.
* units = degE7
*/
@GeneratedMavField(type = "int32_t")
public val lat: Int = 0,
/**
* Longitude.
* units = degE7
*/
@GeneratedMavField(type = "int32_t")
public val lng: Int = 0,
) : MavMessage {
override val instanceCompanion: MavMessage.MavCompanion = Companion
override fun serializeV1(): ByteArray {
val encoder = MavDataEncoder(SIZE_V1)
encoder.encodeFloat(roll)
encoder.encodeFloat(pitch)
encoder.encodeFloat(yaw)
encoder.encodeFloat(altitude)
encoder.encodeInt32(lat)
encoder.encodeInt32(lng)
return encoder.bytes
}
override fun serializeV2(): ByteArray {
val encoder = MavDataEncoder(SIZE_V2)
encoder.encodeFloat(roll)
encoder.encodeFloat(pitch)
encoder.encodeFloat(yaw)
encoder.encodeFloat(altitude)
encoder.encodeInt32(lat)
encoder.encodeInt32(lng)
return encoder.bytes.truncateZeros()
}
public companion object : MavMessage.MavCompanion {
private const val SIZE_V1: Int = 24
private const val SIZE_V2: Int = 24
override val id: UInt = 178u
override val crcExtra: Byte = 47
override fun deserialize(bytes: ByteArray): Ahrs2 {
val decoder = MavDataDecoder(bytes)
val roll = decoder.safeDecodeFloat()
val pitch = decoder.safeDecodeFloat()
val yaw = decoder.safeDecodeFloat()
val altitude = decoder.safeDecodeFloat()
val lat = decoder.safeDecodeInt32()
val lng = decoder.safeDecodeInt32()
return Ahrs2(
roll = roll,
pitch = pitch,
yaw = yaw,
altitude = altitude,
lat = lat,
lng = lng,
)
}
public operator fun invoke(builderAction: Builder.() -> Unit): Ahrs2 =
Builder().apply(builderAction).build()
}
public class Builder {
public var roll: Float = 0F
public var pitch: Float = 0F
public var yaw: Float = 0F
public var altitude: Float = 0F
public var lat: Int = 0
public var lng: Int = 0
public fun build(): Ahrs2 = Ahrs2(
roll = roll,
pitch = pitch,
yaw = yaw,
altitude = altitude,
lat = lat,
lng = lng,
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy