LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mtw xsens

Hello there

 

I'm posting this question because I'm having a real bad time trying to acquire measurements from a Xsens MTw. There are existing "friendly" drivers for the MTi and MTi-G, but not the MTw (or at least I haven't found any). The cd that comes with the sensors has some examples, but only to read orientation (I need data from the accelerometers, gyroscopes and magnetometers) and is programmed at a really really low level and can't deduce a way to include those measurements to the example on the cd.

 

The problem is that the VI loads tons of methods and start working with them, but no idea on how to use them. At first impression one could simply think to add methods as you need, but won't work. Don't know if it is a good idea to upload the VIs because of copyright and stuff... but has anyone ever used MTws at their full potential with LabVIEW?

 

Regards!

0 Kudos
Message 1 of 14
(5,138 Views)

Hello Alejo;

 

As you mention, there is indeed no Instrument Driver for the MTw. However you can use the xsens_cmt.dll  inluded in the MT Software Development Kit

You can use the included examples after you install the package in the following path:  <C:\Program Files (x86)\Xsens\MT SDK\Software Development>

I was checking the example code and indeed, the DLL uses methods only....I tried adding property nodes but had no luck.

 

However it works if you open the Main.vi and reuse the InitializeAwindaStation.vi and start measurement method; and then the OUTPUTMODE_XXXX methods to generate signals or the datacointainsXXX followed by  datagetXXX and so on for the desired readings.

 

You can find the classes description in the path:  file:///C:/Program%20Files%20%28x86%29/Xsens/MT%20SDK%203.8.1%20for%20MTw/Software%20Development/do...

 

Hope this info helps.

 

Good luck

0 Kudos
Message 2 of 14
(5,076 Views)

Hello I have same problem. Do you have solution of Xsens MTW use by labview? thank you!!

0 Kudos
Message 3 of 14
(5,041 Views)

Hello,

 

I've also been struggling with the XSens SDK for MTw for the last couple of days. I've decided to go straight to SDK v 4.2 (latest), though there is no Labview example and the company are not planning to support LV going forward. Here are my findings:

 

Option 1: Use the Componet Object Model and the ActiveX Labview VIs (advice from XSens): xsensdeviceapi_com32.dll

This process starts off fine and the XsControl.setSerialKey works. However, as soon as you need to use 'XsScanner.scanPorts', you hit issues with the variant data types being returned. Reverting back to SDK v3.8.1 and looking at the Matlab example in SDK v4.2, it is demonstrated that the equivalent variant type returned by this function is a 2 D array of int32 which is equivalent to the XsPortInfoArray. There appears to be no way to actually generate an XsPortInfoArray. This issue with unknown data types is putting me off this approach big time as each time we get an object returned, its an email to XSens as the API doesn't give sufficient info to make intelligent guesses.

 

 

Option 2: Wrap the CPP classes in dotNet

Again using the XsControl.setSerialKey as an example, I tried wrapping the CPP function inside a dotNetWrapper and using a dotNet Handle to pass System.String across the interface. Within my XsensDotNet::XsControl class, the new setSerialKey looked like this.

 

int XsensDotNet::XsControl::setSerialKey(String ^ myKey) {
    pin_ptr<const wchar_t> wch = PtrToStringChars(myKey);
    std::wstring basicstring(wch);
    ::XsString newString(basicstring);

    return ::XsControl::setSerialKey(newString);
}

 

This approach worked fine, but its going to take a long time to write wrappers for every call needed, plus its a lot of overhead to get to the low level c function.

 

 

Option 3: Call the xsensdeviceapi32.dll and xstypes32.dll directly in LV using Call Library Function Nodes

So this time, I'm going directly for the C API and essentially writting the dotNet/CPP wrapper in LV. Unfortunately my LV skills fail me here. Once again, using the XsControl_setSerialKey example, we hit a snag in that the required key parameter is of type 'const XsString &key'. So I then turned to the xstypes32 dll and attempted to create an XsString type and discover that you need to generate a struct in LV first. Please help with this challenge.

 

My final roll of the dice: use the Tools->Import->Shared Library(.dll) wizard. Unfortunately, entering either of the dll's and the associated high level header file causes the wizard to crash and my assumption is that there are too many dll interfaces for it to generate. However, specifying the individual header files one at a time is slightly more successful. I did try rebuilding the .dll through visual studio in case that was the issue, but the same problems arise.

 

 

I'd welcome any suggestions on the 3 approaches attempted so far. Happy to battle this further.

 

Thanks,

 

Phil

0 Kudos
Message 4 of 14
(4,959 Views)

Hi all,

 

I've resurrected this topic two years later as it seems to be the only hit regarding this issue and I'm hoping some of the previous posters might have found a solution.

 

I'm currently working with the Xsens MTw SDK 4.3, and have had some success calling the xsensdeviceapi64.dll into Labview via the Invoke Node (Methods) function.

 

I started with the Data Streaming example in Matlab (mainMTwRTdataViewer.m), and translated that into Labview. By doing so, I was able to progress though most of the workflow from setting the serial key, turning on the filters, scanning the COM ports, opening the ports, getting the deviceID, going into config mode, enabling the radio, setting the output mode and update rate,  and going into measurement mode.

 

However at this point, I am supposed to create a callback event that triggers on dataavailable (from the sensor), and generates data containing the device number, and datapacket number. The problem I am having is that the callback function appears to trigger, but no data actually gets created for me to use downstream in the workflow. I have read several articles regarding callbacks and passing outputs from callbacks, but at this point, it just seems like the data variable simply is not created.

 

I would greatly appreciate any help regarding this.

 

Thanks!

 

Matt

0 Kudos
Message 5 of 14
(4,296 Views)

Can you post the callback VI the event calls (either the VI or a snippet of its contents)?

0 Kudos
Message 6 of 14
(4,289 Views)

Capture.JPG

I've attached the callback vi and included this image of the main vi where it gets called.

Please note that the unbundle by name and subsequent code in the callback vi was added by me in an attempt to see if I could appropriately parse out the cluster of variant data. The callback vi by default, simply produces the Event Common Data, Control Ref, Event Data, and User Parameter nodes with nothing else.

 

In the Matlab portion of the code, this guy:

 

h.registerevent({'onDataAvailable',@handleData});

 

calls this guy:

 

function handleData(h,eventID,data,varargin)

 

and it is at this time where the variable "data" first shows up, leading me to believe that the callback vi should create that variable for use downstream, but I just have no way of actually seeing that data in labview at the moment.

0 Kudos
Message 7 of 14
(4,284 Views)

Have you ever confirmed that the callback VI is being called at all?  Just adding a one-button dialog box to make it generate a popup should do this.

 

Have you confirmed that the variant converts to the array in the manner in which you think it should?

 

How did you plan on getting the information out of the callback VI?  There's no messaging code in there.

0 Kudos
Message 8 of 14
(4,272 Views)

Yep I've created a mesaging dialog in previous iterations that pops up when the callback is being called. It popped up several times before it crashed labview because the device updates data at 100 Hz. I then created a more controlled messaging dialog which worked as well. I have removed it since.

 

I cannot be 100% sure that the variant converts to the array, as I have not seen anything come out of it. When I probe that datastream, it looks like nothing ever comes out of the Event Data node.

 

I have tried creating messaging code to return the "extracted" Event Data but again nothing shows up in the main vi.

 

I guess there's a few things I'm not fully understanding about callback vis.

First, are callback vis capable of creating and extracting data from external devices?

Second, is that data always going to be created at the Event Data node as a cluster of variant?

Third, how can I best return that data to the main vi? I've tried something like the below to return the data from Event Data, but again I think the problem is that Event Data doesn't actually seem to generate anything.

Capture.JPG

 

.

0 Kudos
Message 9 of 14
(4,268 Views)

Have you tried flattening the variant to a string or using the "Get variant type info" included in vi.lib (but hidden, see snippet below) to see if you can get information about the data contained in the variant?

 

Variant info.png

0 Kudos
Message 10 of 14
(4,259 Views)