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:
configured with field
CameraAlignment.yaw
supported range given by
CameraExposureSettings.supportedYawRange
pitch
configured with field
CameraAlignment.pitch
supported range given by
CameraExposureSettings.supportedPitchRange
roll:
configured with field
CameraAlignment.roll
supported range given by
CameraExposureSettings.supportedRollRange
Sample code to monitor alignment:
/// Keep reference on MainCamera peripheral to get notified of changes.
private var cameraRef: Ref<MainCamera>?
/// Monitors and prints alignment settings.
func monitorAlignmentSettings(drone: Drone) {
cameraRef = drone.getPeripheral(Peripherals.mainCamera) { camera in
// called on main thread when the camera peripheral changes
if let camera = camera {
// get alignement settings
if let alignmentSettings = camera.alignment {
print("Alignment pitch: \(alignmentSettings.pitch)")
print("Alignment roll: \(alignmentSettings.roll)")
print("Alignment yaw: \(alignmentSettings.yaw)")
} else {
print("Alignment not available")
}
}
}
}
Example of output:
Alignment pitch: 10
Alignment roll: 0
Alignment yaw: -20
Sample code to modify alignment settings:
/// Set yaw alignment
func setAlignmentYaw(drone: Drone, yaw: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera) {
// set setting value
camera.alignment?.yaw = yaw
}
}
/// Set pitch alignment
func setAlignmentPitch(drone: Drone, pitch: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera) {
// set setting value
camera.alignment?.pitch = pitch
}
}
/// Set roll alignment
func setAlignmentRoll(drone: Drone, roll: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera) {
// set setting value
camera.alignment?.roll = roll
}
}
Trying to change the setting value outside of rang has no effect. Range supported by the camera are provided by:
yaw:
CameraAlignment.supportedYawRange
.pitch:
CameraAlignment.supportedPitchRange
.roll:
CameraAlignment.supportedRollRange
.
Camera 2#
yaw: configured with parameter
Camera2Params.alignmentOffsetYaw
pitch: configured with parameter
Camera2Params.alignmentOffsetPitch
roll: configured with parameter
Camera2Params.alignmentOffsetRoll
Sample code to monitor alignment parameters:
/// Keep reference on MainCamera2 peripheral to get notified of changes.
private var cameraRef: Ref<MainCamera2>?
/// Monitors and prints alignement setting.
func monitorAlignmentSettings(drone: Drone) {
cameraRef = drone.getPeripheral(Peripherals.mainCamera2) { camera in
// called on main thread when the camera peripheral changes
if let camera = camera {
// get pitch parameter
if let pitchParam = camera.config[Camera2Params.alignmentOffsetPitch] {
print("Alignment pitch: \(pitchParam.value)")
}
// get roll parameter
if let rollParam = camera.config[Camera2Params.alignmentOffsetRoll] {
print("Alignment roll: \(rollParam.value)")
}
// get yaw parameter
if let yawParam = camera.config[Camera2Params.alignmentOffsetYaw] {
print("Alignment yaw: \(yawParam.value)")
}
}
}
}
Example of output:
Alignment pitch: 10
Alignment roll: 0
Alignment yaw: -20
Sample code to modify alignment parameters:
/// Sets yaw alignment.
func setAlignmentYaw(drone: Drone, yaw: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
// create configuration editor, starting from current configuration
let editor = camera.config.edit(fromScratch: false)
// retrieve configuration parameter
if let configParam = editor[Camera2Params.alignmentOffsetYaw] {
// 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.
func setAlignmentPitch(drone: Drone, pitch: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
// create configuration editor, starting from current configuration
let editor = camera.config.edit(fromScratch: false)
// retrieve configuration parameter
if let configParam = editor[Camera2Params.alignmentOffsetPitch] {
// 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.
func setAlignmentRoll(drone: Drone, roll: Double) {
if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
// create configuration editor, starting from current configuration
let editor = camera.config.edit(fromScratch: false)
// retrieve configuration parameter
if let configParam = editor[Camera2Params.alignmentOffsetRoll] {
// 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 field configParam.overallSupportedValues
.