Alignment#
yaw: Alignment offset applied to the yaw axis, in degrees.
pitch: Alignment offset applied to the pitch axis, in degrees.
roll: Alignment offset applied to the roll axis, in degrees.
Camera 1#
yaw:
get with method
CameraAlignment.Setting.yaw()
set with method
CameraAlignment.Setting.setYaw()
supported range given by
CameraAlignment.Setting.supportedYawRange()
pitch
get with method
CameraAlignment.Setting.pitch()
set with method
CameraAlignment.Setting.setPitch()
supported range given by
CameraAlignment.Setting.supportedPitchRange()
roll:
get with method
CameraAlignment.Setting.roll()
set with method
CameraAlignment.Setting.setRoll()
supported range given by
CameraAlignment.Setting.supportedRollRange()
Sample code to monitor alignment:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints alignment settings. */
fun monitorAlignmentSettings(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.apply {
// get alignment settings
alignment()?.run {
print("Alignment pitch: ${pitch()}")
print("Alignment roll: ${roll()}")
print("Alignment yaw: ${yaw()}")
} ?: print("Alignment not available")
}
}
}
Example of output:
Alignment pitch: 10
Alignment roll: 0
Alignment yaw: -20
Sample code to modify alignment settings:
/** Sets yaw alignment. */
fun setAlignmentYaw(drone: Drone, yaw: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// set setting value
alignment()?.setYaw(yaw)
}
}
/** Sets pitch alignment. */
fun setAlignmentPitch(drone: Drone, pitch: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// set setting value
alignment()?.setPitch(pitch)
}
}
/** Sets roll alignment. */
fun setAlignmentRoll(drone: Drone, roll: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// set setting value
alignment()?.setRoll(roll)
}
}
Trying to change the setting value outside of rang has no effect. Range supported by the camera are provided by:
yaw:
CameraAlignment.Setting.supportedYawRange()
.pitch:
CameraAlignment.Setting.supportedPitchRange()
.roll:
CameraAlignment.Setting.supportedRollRange()
.
Camera 2#
yaw: configured with parameter
Camera.Config.ALIGNMENT_OFFSET_YAW
pitch: configured with parameter
Camera.Config.ALIGNMENT_OFFSET_PITCH
roll: configured with parameter
Camera.Config.ALIGNMENT_OFFSET_ROLL
Sample code to monitor alignment parameters:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints alignment settings. */
fun monitorAlignmentSettings(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.run {
// get pitch parameter value
config[Camera.Config.ALIGNMENT_OFFSET_ROLL].run {
if (supportedValues(onlyCurrent = true) == DoubleRange.EMPTY) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Alignment pitch: no supported value in current configuration")
} else {
println("Alignment pitch: $value")
}
}
// get roll parameter value
config[Camera.Config.ALIGNMENT_OFFSET_ROLL].run {
if (supportedValues(onlyCurrent = true) == DoubleRange.EMPTY) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Alignment roll: no supported value in current configuration")
} else {
println("Alignment roll: $value")
}
}
// get yaw parameter value
config[Camera.Config.ALIGNMENT_OFFSET_YAW].run {
if (supportedValues(onlyCurrent = true) == DoubleRange.EMPTY) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Alignment yaw: no supported value in current configuration")
} else {
println("Alignment yaw: $value")
}
}
}
}
}
Example of output:
Alignment pitch: 10.0
Alignment roll: 0.0
Alignment yaw: -20.0
Sample code to modify alignment parameters:
/** Sets yaw alignment. */
fun setAlignmentYaw(drone: Drone, yaw: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.ALIGNMENT_OFFSET_YAW].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = yaw
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets pitch alignment. */
fun setAlignmentPitch(drone: Drone, pitch: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.ALIGNMENT_OFFSET_PITCH].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = pitch
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets roll alignment. */
fun setAlignmentRoll(drone: Drone, roll: Double) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.ALIGNMENT_OFFSET_ROLL].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = roll
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
Trying to change a parameter value outside of supported range has no effect.
Ranges supported by the camera are provided by parameters method configParam.supportedValues(onlyCurrent = false)
.