posted 06/14/16
In my last post on the subject of Magnetometer Calibration, I described an entirely complete and wonderful calibration utility I wrote in C#/.NET using Windows Forms, an old version of devDept’s EyeShot 3D viewport library, and calls into the Octave libraries to execute a MATLAB calibration script. Unfortunately, at the end of the project I discovered to my horror that my redistribution rights for the EyeShot libraries had expired some time ago, and re-upping them was prohibitively expensive – so I could use my masterpiece, but no one else could! :-(.
So, it was ‘back to the drawing board‘ for me. I needed a (ideally free) 3D visualization capability with reasonably easy-to-implement view manipulation (pan, zoom, rotate, coordinate axis, etc) tools that was compatible with C#/.NET. After a fair bit of research, I found that Microsoft’s WPF (Windows Presentation Framework) platform advertised ‘full’ 3D visualization capability, so that was encouraging. Unfortunately, I had never used WPF at all, doing all my C#/.NET programming in the Windows.Forms namespace. There were some posts that suggested the ability to place a WPF 3D viewport window into a Forms-based app via a ‘WindowsFormsHostingWpfControl’ but after trying this a bit I decided it was going to be too hard to build up the required 3D viewport and associated view manipulation tools ‘from scratch’. Eventually I ran across the 3D Helix Toolkit at http://www.helix-toolkit.org/, and this looked very promising, but with the downside of having to re-create the entire application in WPF-land. Actually, this appealed to me in a masochistic sort of way, as I would have the opportunity to learn two completely new packages/skills – WPF programming in general (which I had been ignoring for years in the hopes it would go away) and the feature-rich (but somewhat rough around the edges) Helix Toolkit.
So, off I went, reading as much as I could get my hands on about WPF and .NET visual programming. It was initially very difficult to wrap my head around the way that WPF combines XAML with C# ‘code-behind’ to achieve the desired results. At first I started out trying desperately to stick to my WinForms technique of drag/dropping tools onto a work surface, and then modifying properties as desired. This worked up to a point, but I rapidly got lost due to the marked difference between WinForm’s ‘everything is a child of the main window’ and WPF’s hierarchical layout as described in XAML philosophy. So, my first effort to build a WPF app isn’t very pretty, and definitely violates any number of rules for WPF elegance! However, the use of WPF and the Helix Toolkit made it reasonably easy to implement the ‘raw’ and ‘calibrated 3D views, and I had no real trouble porting the comm port and Octave implementation logic from my previous app to this one. And of course, the entire object of the exercise was to create an app that could be shared, and the WPF version (hopefully) does that.
My plan for the future – at least with respect to the Magnetometer Calibration Utility, is to share the app within the robotics/drone community, and to continue to support it as necessary to fix bugs and/or implement requested enhancements. I also plan to set up a public GitHub repository as soon as I can figure out how to do it ;-).
Pingback: Magnetometer Calibration Tool, Part IV - Paynter's Palace
I can not get any serial date to show up in the calibration tool. I arduino this is the code I use to send data:
Serial.print(IMU.getMagX_uT(),6);
Serial.print(“,”);
Serial.print(IMU.getMagY_uT(),6);
Serial.print(“,”);
Serial.println(IMU.getMagZ_uT(),6);
//Serial.println(“,”);
//Serial.print(“\n”);
delay(100);
When I use serial monitor in Arduino IDE I get lines of date which look like this:
-3.596192,-27.509111,-1.043716
-2.697144,-18.641042,2.609289
When I click open port, i get message that port was opened, but nothing happens. I get no date from my arduino to the calibration tool.
Any idea what i might be doing wrong?