Я записываю информацию IMU от DJI Drone через iOS DJI UXSDKDemo.Используя метод, приведенный ниже, я могу получить журнал четырех желаемых значений (состояние IMU, счетчик IMU, гироскоп и акселерометр).Когда я запускаю приложение, подключенное к дрону, однако, журналы сохраняются, журналы от этих полетов перечисляют каждое из четырех значений как ноль.Дрон, к которому я подключаю приложение, не летает, но даже когда я перемещаю дрон, значения не меняются.
Нужно ли импортировать какие-либо файлы в DefaultLayoutViewController.m, кроме DefaultLayoutViewController.h?
Не верна ли моя методология?
- (void)showAlertViewWithMessage:(NSString *)message
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController* alertViewController = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertViewController addAction:okAction];
UIViewController *rootViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
[rootViewController presentViewController:alertViewController animated:YES completion:nil];
//Printing Keys to Log; download logs from the page for this app on Itunes
DJIFlightControllerKey *IMUStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUState);
}];
DJIFlightControllerKey *IMUsCountForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUsCount];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUsCountForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUsCountForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUsCountForLog);
NSLog(@"%@", DJIFlightControllerParamIMUsCount);
}];
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateGyroscopeStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUStateGyroscopeState);
}];
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"%@", IMUStateAccelerometerStateForLog);
NSLog(@"%@", DJIFlightControllerParamIMUAccelerometerState);
}];
});
}
РЕДАКТИРОВАТЬ / ОБНОВИТЬ: Я реализовалпредлагаемые изменения.Значения теперь печатаются, но они появляются нечасто и кажутся отличными от ожидаемой выходной мощности датчиков акселерометра и гироскопа.Разве акселерометр и гироскоп не должны выдавать три значения (x, y, z)?Код и скриншот журнала можно найти ниже.Есть предложения?
- (void)viewDidLoad
{
[super viewDidLoad];
//Please enter your App Key in the info.plist file.
[DJISDKManager registerAppWithDelegate:self];
//Printing Keys to Log; download logs from the page for this app on Itunes
//GYROSCOPE
DJIFlightControllerKey *IMUStateGyroscopeStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUStateGyroscopeState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateGyroscopeStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateGyroscopeStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: GYROSCOPE: %ld", newValue.integerValue);
}];
//ACCELEROMETER
DJIFlightControllerKey *IMUStateAccelerometerStateForLog = [DJIFlightControllerKey keyWithParam:DJIFlightControllerParamIMUAccelerometerState];
// Will get called once to get current value of the key
[[DJISDKManager keyManager] getValueForKey:IMUStateAccelerometerStateForLog withCompletion:^(DJIKeyedValue * _Nullable value, NSError * _Nullable error) {
}];
// Called only when the value for the key changes
[[DJISDKManager keyManager] startListeningForChangesOnKey:IMUStateAccelerometerStateForLog withListener:self andUpdateBlock:^(DJIKeyedValue * _Nullable oldValue, DJIKeyedValue * _Nullable newValue) {
NSLog(@"LOG: ACCELEROMETER: %ld", newValue.integerValue);
}];
}