Problems to implement ObstacleData Sensors
CompletedHello, I am trying to implement the obstacle detection sensor as it is done in DJI Pilot 2 using a Matrice 350 RTK, obtaining the braking warning distance and the anti-collision braking distance for each position of the drone: HORIZONTAL, UPWARD, and DOWNWARD. For this, I am implementing the following to store the information in PerceptionInfo:
public class PositionObstacleWidget extends WidgetModel {
public DataProcessor<PerceptionInfo> perceptionInfoProcessor = DataProcessor.create(new PerceptionInfo());
private PerceptionManager perceptionManager = (PerceptionManager) PerceptionManager.getInstance();
private PerceptionInformationListener perceptionInformationListener = new PerceptionInformationListener() {
@Override
public void onUpdate(@NonNull PerceptionInfo information) {
perceptionInfoProcessor.onNext(information);
}
};
protected PositionObstacleWidgetModel(@NonNull DJISDKModel djiSdkModel, @NonNull ObservableInMemoryKeyedStore uxKeyManager) {
super(djiSdkModel, uxKeyManager);
}
@Override
protected void inSetup() {
perceptionManager.addPerceptionInformationListener(perceptionInformationListener);
}
@Override
protected void inCleanup() {
perceptionManager.removePerceptionInformationListener(perceptionInformationListener);
}
public Completable setObstacleAvoidanceEnabled(boolean enabled, PerceptionDirection direction) {
return Completable.create(emitter -> {
perceptionManager.setObstacleAvoidanceEnabled(enabled, direction, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
emitter.onComplete();
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
emitter.onError((Throwable) idjiError);
}
});
});
}
public Completable setObstacleAvoidanceBrakingDistance(double distance, PerceptionDirection direction) {
return Completable.create(emitter -> {
perceptionManager.setObstacleAvoidanceBrakingDistance(distance, direction, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
emitter.onComplete();
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
emitter.onError((Throwable) idjiError);
}
});
});
}
public Completable setWarningDistance(double distance, PerceptionDirection direction) {
return Completable.create(emitter -> {
perceptionManager.setObstacleAvoidanceWarningDistance(distance, direction, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
emitter.onComplete();
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
emitter.onError((Throwable) idjiError);
}
});
});
}
}
All of this goes through PositionObstacleVM and PositionObstacleWidget where the sensor value and true/false are obtained in case of enabled/disabled, or the distance value in case of setObstacleAvoidanceWarningDistance or setObstacleAvoidanceBrakingDistance.
After that, debugging the code in the HSIPerceptionLayer class, I see that in the onStart() method, the information is obtained through CompositeDisposable, where the information for the HORIZONTAL sensor is correctly retrieved. However, the part of RadarInformation and ObstacleData that the DataProcessor gets and adds in this CompositeDisposable comes empty, with the methods of the ObstacleData class returning null or 0.
Similarly, in the AttitudeDashBoard class, in its onAttachedToWindow() method, the values from the PerceptionInfo for the UPWARD and DOWNWARD sensors are correctly retrieved, but then these variables that get the data are not used in the methods related to draw.
If the information from PerceptionInfo comes correctly, my question is how can I implement these values to make the distance alert and anti-collision braking work, and how is it displayed, through the HSIView in the radar, with an alert message?
Please sign in to leave a comment.
Comments
1 comment