main.com.divpundir.mavlink.definitions.common.ViconPositionEstimate.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of definitions Show documentation
Show all versions of definitions Show documentation
A modern MAVLink library for the JVM written in Kotlin.
package com.divpundir.mavlink.definitions.common
import com.divpundir.mavlink.api.GeneratedMavField
import com.divpundir.mavlink.api.GeneratedMavMessage
import com.divpundir.mavlink.api.MavDeserializer
import com.divpundir.mavlink.api.MavMessage
import com.divpundir.mavlink.serialization.decodeFloat
import com.divpundir.mavlink.serialization.decodeFloatArray
import com.divpundir.mavlink.serialization.decodeUInt64
import com.divpundir.mavlink.serialization.encodeFloat
import com.divpundir.mavlink.serialization.encodeFloatArray
import com.divpundir.mavlink.serialization.encodeUInt64
import com.divpundir.mavlink.serialization.truncateZeros
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.Byte
import kotlin.ByteArray
import kotlin.Float
import kotlin.Int
import kotlin.UInt
import kotlin.ULong
import kotlin.Unit
import kotlin.collections.List
/**
* Global position estimate from a Vicon motion system source.
*/
@GeneratedMavMessage(
id = 104u,
crcExtra = 56,
)
public data class ViconPositionEstimate(
/**
* Timestamp (UNIX time or time since system boot)
*/
@GeneratedMavField(type = "uint64_t")
public val usec: ULong = 0uL,
/**
* Global X position
*/
@GeneratedMavField(type = "float")
public val x: Float = 0F,
/**
* Global Y position
*/
@GeneratedMavField(type = "float")
public val y: Float = 0F,
/**
* Global Z position
*/
@GeneratedMavField(type = "float")
public val z: Float = 0F,
/**
* Roll angle
*/
@GeneratedMavField(type = "float")
public val roll: Float = 0F,
/**
* Pitch angle
*/
@GeneratedMavField(type = "float")
public val pitch: Float = 0F,
/**
* Yaw angle
*/
@GeneratedMavField(type = "float")
public val yaw: Float = 0F,
/**
* Row-major representation of 6x6 pose cross-covariance matrix upper right triangle (states: x,
* y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW,
* etc.). If unknown, assign NaN value to first element in the array.
*/
@GeneratedMavField(
type = "float[21]",
extension = true,
)
public val covariance: List = emptyList(),
) : MavMessage {
public override val instanceMetadata: MavMessage.Metadata = METADATA
public override fun serializeV1(): ByteArray {
val outputBuffer = ByteBuffer.allocate(SIZE_V1).order(ByteOrder.LITTLE_ENDIAN)
outputBuffer.encodeUInt64(usec)
outputBuffer.encodeFloat(x)
outputBuffer.encodeFloat(y)
outputBuffer.encodeFloat(z)
outputBuffer.encodeFloat(roll)
outputBuffer.encodeFloat(pitch)
outputBuffer.encodeFloat(yaw)
return outputBuffer.array()
}
public override fun serializeV2(): ByteArray {
val outputBuffer = ByteBuffer.allocate(SIZE_V2).order(ByteOrder.LITTLE_ENDIAN)
outputBuffer.encodeUInt64(usec)
outputBuffer.encodeFloat(x)
outputBuffer.encodeFloat(y)
outputBuffer.encodeFloat(z)
outputBuffer.encodeFloat(roll)
outputBuffer.encodeFloat(pitch)
outputBuffer.encodeFloat(yaw)
outputBuffer.encodeFloatArray(covariance, 84)
return outputBuffer.array().truncateZeros()
}
public companion object {
private const val ID: UInt = 104u
private const val CRC_EXTRA: Byte = 56
private const val SIZE_V1: Int = 32
private const val SIZE_V2: Int = 116
private val DESERIALIZER: MavDeserializer = MavDeserializer { bytes ->
val inputBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN)
val usec = inputBuffer.decodeUInt64()
val x = inputBuffer.decodeFloat()
val y = inputBuffer.decodeFloat()
val z = inputBuffer.decodeFloat()
val roll = inputBuffer.decodeFloat()
val pitch = inputBuffer.decodeFloat()
val yaw = inputBuffer.decodeFloat()
val covariance = inputBuffer.decodeFloatArray(84)
ViconPositionEstimate(
usec = usec,
x = x,
y = y,
z = z,
roll = roll,
pitch = pitch,
yaw = yaw,
covariance = covariance,
)
}
private val METADATA: MavMessage.Metadata = MavMessage.Metadata(ID,
CRC_EXTRA, DESERIALIZER)
public val classMetadata: MavMessage.Metadata = METADATA
public fun builder(builderAction: Builder.() -> Unit): ViconPositionEstimate =
Builder().apply(builderAction).build()
}
public class Builder {
public var usec: ULong = 0uL
public var x: Float = 0F
public var y: Float = 0F
public var z: Float = 0F
public var roll: Float = 0F
public var pitch: Float = 0F
public var yaw: Float = 0F
public var covariance: List = emptyList()
public fun build(): ViconPositionEstimate = ViconPositionEstimate(
usec = usec,
x = x,
y = y,
z = z,
roll = roll,
pitch = pitch,
yaw = yaw,
covariance = covariance,
)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy