I have been struggling to implement kalman-ios into my Swift project. The kalman-ios project is written entirely in Objective-C++.
I recently learned how to call Objective-C++ functions from this video guide
Issue
My issue is that I can make calls to normal functions, but none that are within an @implementation. Ex: I cannot successfully bridge Swift to didReadAccelerometer
@interface KFAppDelegate ()
...
- (void)didReadAccelerometer:(CMAccelerometerData *)data;
@implementation KFAppDelegate
...
- (void)didReadAccelerometer:(CMAccelerometerData *)data
{
// gyro or compass data not available yet, wait until next update
if (!self.gyroData || !self.magnetometerData)
return;
self.accelData = data;
// run filter
[self performKalmanUpdate];
// send state to server
[self transmitState];
// discard old data
self.accelData = nil;
self.gyroData = nil;
}
I can successfully bridge Swift to getTime as it is not inside an @implementation
double getTime()
{
// mach_absolute_time() returns billionth of seconds
const double kOneBillion = 1000000000.0;
return getTime_ns() / kOneBillion;
}
With bridging header file that contains:
#ifdef __cplusplus
extern "C" {
#endif
double getTime();
#ifdef __cplusplus
}
#endif
I need to get at the functions within @implementation because they use class-level variables throughout.
Is there a way to use these functions in Swift?
Thank you for any help you can provide!