Wow! Thanks a lot!!!
class CMRotationRate (Structure):
fields = [('x', c_double), ('y', c_double), ('z', c_double)]
and
gyro_data.rotationRate(argtypes=[], restype=CMRotationRate)
was exactly the answer I searched for.
It was my last open issue impementing an AHRS algorithm on Pythonista.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.

Latest posts made by gyronaut
-
RE: Get Data from objc_util.__Structure
-
Get Data from objc_util.__Structure
I would like to read the raw gyroscope data via objc_util. Generally it seems to work. The problem is that the return value is a Object-C structure resulting in a obc_util.__Structure class. The question is how I can the fetch the values of this structure. Appending a simple ".x" does not work.
-
RE: Python Objective-C Bridge
Wow. It works. Thanks, Ole!
The coding changes are indicated by ">>> Bridge":
// // AppDelegate.m // Pythonista // // Created by Ole Zorn on 1/19/15. // // #import "AppDelegate.h" #import "PythonistaAppViewController.h" // >>> Bridge #import "Python.h" // <<< Bridge PyMODINIT_FUNC init_sensor(void); @implementation AppDelegate - (void)applicationDidFinishLaunching:(UIApplication *)application { // >>> Bridge struct _inittab pyqt_inittab[] = { {"_sensor", init_sensor},{0,0}}; PyImport_ExtendInittab( pyqt_inittab); // <<< Bridge NSFileManager *fm = [NSFileManager defaultManager]; NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
-
RE: Python Objective-C Bridge
Thanks, for the reply, but it's still not working.
This my test coding of _sensor.m :
// // _sensor.m // PilotsApp // // // #import <Foundation/Foundation.h> #import "Python.h" PyObject* sensor_get(PyObject* self, PyObject* pArgs) { NSString *stringValue = @"done"; return PyUnicode_FromString([stringValue UTF8String]); } static PyMethodDef Methods[] = { {"get", sensor_get, METH_NOARGS, "get() -- Get the clipboard's text content as a string"}, // [...] {NULL, NULL, 0, NULL} //sentinel }; PyMODINIT_FUNC init_sensor() { Py_InitModule("_sensor", Methods); }
Then I implemented the file sensor.py :
from _sensor import *
And extacly this statement ends in "No module named _sensor"
Do I have to change any compiling or linking flags ?
-
RE: Python Objective-C Bridge
Sorry for the naive question, but I :
- Included the “Python.h”- directory to the header include option
- Implemented such a coding like the clipboard example , called the module “_sensors”
Compiling and linking was done without any errors.
Then I added “import sensors” to my main.py file and got the error during runtime that the module is not defined.
What is missing ?
For any suggestions grateful
Stefan -
Template 1.6 and objc_util
Yesterday I tried to access objc_util from a xcode ( import objc_util) . But this does not work.
Is it not possible ? -
RE: New Xcode Template (beta)
I would like to compile and run the template under Xcode 7.1 and iOS 9 but get such an error:
Undefined symbols for architecture arm64:
"_ffi_prep_closure_loc", referenced from:
__ctypes_alloc_callback in liblibpythonista.a(callbacks.o)
"_ffi_prep_cif", referenced from:
__ctypes_callproc in liblibpythonista.a(callproc.o)
__ctypes_alloc_callback in liblibpythonista.a(callbacks.o)
"_ffi_call", referenced from:
__ctypes_callproc in liblibpythonista.a(callproc.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)Are there any ideas, what will be wrong ?
THX, Stefan
-
Raw Data of Sensors requested
I'm programming a prototyp for a flight navigational software and I would like to use Pythonista. Although you added functions for reading sensor data by introducing the motion module, this functions are not usable if the iphone is in a vertical position, which is the normal case. Hence it makes sense, just to provide the raw data of acceleration and gyroscope.
As an example of the accelerator:
- (void)startAccelerometer { if ([self.motionManager isAccelerometerAvailable] == YES) { [self.motionManager startAccelerometerUpdatesToQueue:queue withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) { self.ac_x = accelerometerData.acceleration.x; self.ac_y = accelerometerData.acceleration.y; self.ac_z = accelerometerData.acceleration.z; }]; } }