[Vm-dev] MadgwickAHRS plugin and support code (was: Building a linux/Pi library to call via FFI)

Ben Coman btc at openinworld.com
Sun Sep 13 15:26:45 UTC 2015


(whoops, vm-dev slipped off address list, resent)

On Sun, Sep 13, 2015 at 9:47 AM, David T. Lewis <lewis at mail.msen.com> wrote:
> On Thu, Sep 10, 2015 at 10:29:24AM -0700, tim Rowledge wrote:
>>
>> On 09-09-2015, at 6:53 PM, David T. Lewis <lewis at mail.msen.com> wrote:
>>
>> > On Wed, Sep 09, 2015 at 11:17:08AM -0700, tim Rowledge wrote:
>> >> I?m trying - and so far failing - to do what should surely be a very simple
>> >> thing. This isn?t a new situation?  especially on unix.
>> >>
>> >> I have a single C file with just two functions. I have a matching H file.
>> >> I want to make them into a dynamic library that I can call via FFI. This
>> >> really shouldn?t be rocket science stuff!
>> >
>> > <OT>
>> > I assume there is some good reason that you would not do an end run
>> > around all that rocket science and just write a plugin?
>>
>> Well I *did* originally point out that there was probably a really stupid mistake in my process and that is pretty much it. In my defence I was in the midst of FFI-ing to multiple external libraries for assorted Pi add-on doohickeys and getting somewhat inured to the idea.
>>
>> But I think I may re-do it as a plugin today, not least because it seems that the ARM ffi interface has a problem with returning floats; they come back as Character null. I may not be a great IEEE floating point standard expert but that doesn?t seem quite right.
>>
>
> I don't know what got into me, but I brewed up a nice pot of coffee this
> morning and ended up with http://squeaksource.com/MadgwickAHRS/
>
> This is a plugin, accessor class, and unit tests that claim to demonstrate
> that the plugin works.
>
> I used FloatArray for parameter passing, on the theory that users of the
> plugin may be doing float (not double) arithmetic, so it may be more
> efficient to pass values in that manner.
>
> It works with 32/64 bit image and host, and the plugin builds without complaint
> (trunk with Ian's Cmake build) if you put the library source files
> MadgwickAHRS.c and MadgwickAHRS.h in platforms/Cross/plugins/MadgwickAHRS/
>
> The MadgwickAHRS library is licensed GPL, so it would be best to link
> the plugin dynamically to e.g. /usr/local/iib/libwmadgwickIMU.so.1
> rather than static link to the C code as I have done so far.

Unfortunately the distinction you make between static and dynamic
linking is incorrect for GPL code [1][2], and true only for LGPL code.

Now I notice that although [3] indicates the license is GPL, [3]
points to original post [4] which was LGPL.   A little confusing since
neither [3] nor [4] state a license in the C source files.  It seems
[4] is the same author, so maybe its worth a polite query as to why
the license changed from LGPL to GPL.

[1] http://www.gnu.org/licenses/gpl-faq.html#GPLStaticVsDynamic
[2] http://www.dwheeler.com/essays/floss-license-slide.html
[3] http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/
[4] https://code.google.com/p/imumargalgorithm30042010sohm/

cheers -ben


More information about the Vm-dev mailing list