-
Notifications
You must be signed in to change notification settings - Fork 15
Vision Widget
The DUXBetaVisionWidget
shows the current state of the vision system. There are two different vision systems that are used by different aircraft. Older aircraft use the DUXBetaVisionSystemStatus
which has three states that indicate whether the system is enabled and working correctly. Newer aircraft such as the Mavic 2 and Mavic 2 Enterprise have an omnidirectional vision system, which means they use statuses that begin with DUXBetaVisionStatusOmni
to indicate which directions are enabled and working correctly.
Image | State | Description |
---|---|---|
DUXBetaVisionStatusNormal |
The vision system is functioning normally. | |
DUXBetaVisionStatusDisabled |
The vision system is not available. This could be due to the flight mode, TapFly mode, Active Track mode, or hardware failure. | |
DUXBetaVisionStatusClosed |
Obstacle avoidance is disabled by the user. | |
DUXBetaVisionStatusOmniAll |
Product has omnidirectional obstacle avoidance sensors and all vision systems are available. | |
DUXBetaVisionStatusOmniFrontBack |
Product has omnidirectional obstacle avoidance sensors and only forward and backward vision systems are available. Left and right vision systems are only available in ActiveTrack mode and Tripod mode. | |
DUXBetaVisionStatusOmniDisabled |
Product has omnidirectional obstacle avoidance sensors and the vision system is not available. This could be due to the flight mode, tap mode, tracking mode, draw status, or hardware failure. | |
DUXBetaVisionStatusOmniClosed |
Product has omnidirectional obstacle avoidance sensors and obstacle avoidance is disabled by the user. |
The icon is tinted gray when no product is connected:
Note: The iOS vision widget does not support draw flight mode.
If creating the vision widget through code it can be added using the convenience method:
- (void)installInViewController:(nullable UIViewController *)viewController
which adds the widget the method is called on as a subview of the ViewController that is passed in as an argument. Following this add constraints to the widget using its widgetSizeHint
property to determine width, height and aspect ratio constraints.
If creating the widget through storyboard use the object library to drag a container view controller into the desired view controller like so:
Following this make sure to change the class of the child view controller to be DUXBetaVisionWidget
. From here you can create the constraints on the container view using the Vision Widget's widgetSizeHint
property.
The Vision Widget supports customization of its image icon. An example of a customized vision widget showing the vision is in an enabled state could look something like this:
To get this effect we would use the following code:
visionWidget.setImage(UIImage(named: "CustomVisionNormal")!, for: .normal)
visionWidget.setImage(UIImage(named: "CustomVisionDisabled")!, for: .disabled)
[visionWidget setImage[UIImage imageNamed:@"CustomVisionNormal"] for:DUXBetaVisionStatusNormal];
[visionWidget setImage[UIImage imageNamed:@"CustomVisionDisabled"] for:DUXBetaVisionStatusDisabled];
List of customization methods and properties
-
@property (nonatomic, strong) UIColor *iconBackgroundColor;
The color of the background of the icon. -
@property (nonatomic, strong) UIColor *disconnectedIconColor;
The color of the vision icon when the product is disconnected. -
- (void)setImage:(UIImage *)image forVisionStatus:(DUXBetaVisionStatus)status;
Set image for given vision status. -
- (UIImage *)imageForVisionStatus:(DUXBetaVisionStatus)status;
Get image for given vision status.
The widget provides hooks for users to add functionality based on state changes in the widget. The GPS signal widget provides the following hooks
-
VisionModelState
- Provides hooks for events received by the widget from the widget model.
-
+ (instancetype)productConnected:(BOOL)isConnected;
- Event when product is connected or disconnected. -
+ (instancetype)visionSystemStatusUpdated:(DUXBetaVisionStatus)visionStatus;
- Event when visionSystemStatus is updated. -
+ (instancetype)userAvoidanceEnabledUpdated:(BOOL)isUserAvoidanceEnabled;
- Event when user avoidance is enabled or disabled. -
+ (instancetype)visibilityUpdated:(BOOL)isVisible;
- Event when the visibility of the widget changes based on whether the product supports it or not.
-
VisionUIState
- Provides hooks for events received by the widget from user interactions.
-
+ (instancetype)widgetTapped;
- Event when user taps the widget.
DJI UX SDK Version 5 Beta 4.1