cprest1n
lvl.1
United States
Offline
|
If anyone else gets in this trap, the key is to look at the omnibus sample app Gimbal Capabilities screen, NOT the Gimbal Move screen which doesn't work on my device.
Here's some fairly clean gimbal move code that works:
private void changePitch(boolean up) {
Gimbal gimbal = FPVDemoApplication.getGimbalInstance();
if (gimbal == null) return;
Number rotValue;
if (up) {
rotValue = ((DJIParamMinMaxCapability) (gimbal.getCapabilities().get(CapabilityKey.ADJUST_PITCH))).getMax();
} else {
rotValue = ((DJIParamMinMaxCapability) (gimbal.getCapabilities().get(CapabilityKey.ADJUST_PITCH))).getMin();
}
Log.d("TAG", "rotation Value for cap-driven min/max " + rotValue);
Rotation.Builder builder = new Rotation.Builder().mode(RotationMode.ABSOLUTE_ANGLE).time(2);
builder.pitch(rotValue.floatValue());
final Rotation rotation = builder.build();
gimbal.rotate(rotation, new CommonCallbacks.CompletionCallback(){
@Override
public void onResult(DJIError djiError) {
if (djiError == null) {
Log.d("TAG", "rotate gimbal success");
showToast("rotate gimbal success");
}else {
Log.d("TAG", "rotate gimbal error " + djiError.getDescription());
showToast(djiError.getDescription());
}
}
});
}
|
|