Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Supporting Visual Studio on Windows
kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Thu Sep 26, 2019 6:54 am

Hi Patrick,
This might be it! However, the compasscalibator.exe (I have no Examples folder for some reason, I found it in C:\Program Files\Phidgets\Phidgets22) cannot find the Phidget Spatial. The info values are empty and not editable, no graphics is rendered. I can fill in the local field strength but that doesn't cause the start button to become active. There doesn't seem to be a way to give the calibrator hints on where to find the magnetometer.

Do I need a different version that supports the vint Hub? If it works, will the calibration be written to the device or will I have to integrate calibration into my software?

Best,
-martin

User avatar
Patrick
Lead Developer
Posts: 3199
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby Patrick » Thu Sep 26, 2019 9:56 am

The compass calibrator should pick up the MOT1101. If it's not, make sure you don't still have it open in Unity or elsewhere. Once calibration is finished, the values are written to the device, so you don't need to worry about it after that.

Keep in mind that it doesn't take a lot to interfere with the magnetometer, which can lead to error in the absolute yaw. You will want to calibrate the magnetometer for the environment in which it will be used - if it will be fixed to something, make sure to calibrate after mounting it.

-Patrick

kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Thu Sep 26, 2019 10:44 am

No, nothing. Unity closed, control panel closed. Still not finding the spatial.

The vint-hub does have a preset password. It doesn't take no password in the configuration. Without password, I cannot access the spatial from the control panel, is the same true for compasscalibration.exe? If so, how do I provide the password?

User avatar
Patrick
Lead Developer
Posts: 3199
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby Patrick » Thu Sep 26, 2019 1:15 pm

Ok, I have re-watched your video and it looks like your MOT1101 is attached to a HUB5000?

The compass calibrator program is looking for locally attached Spatials, so it won't open one that's on the network.

I'm going to add the ability to calibrate remote spatials to the next library release. Should be out in the next couple of days.

You will be able to right-click the spatial device in the control panel and select 'calibrate magnetometer...' in the dropdown.

-Patrick

kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Fri Sep 27, 2019 2:50 am

Thank you very much, Patrick!
This should work for the decision wether we can use the phidget in this project. In the long run, it would make sense to locate compass calibration in the control panel...

User avatar
Patrick
Lead Developer
Posts: 3199
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby Patrick » Fri Sep 27, 2019 2:56 pm

The new control panel is up.

-Patrick

kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Tue Oct 01, 2019 3:12 am

Thanks, you even included it into the control panel, very convenient.

I Mananged to calibrate the compass and the data is looking good in the Control Panel. I was just wondering if anything else was changed in the new driver package as I cannot connect to the device any more ever since I calibrated.

After calling spatial.open() I'm not receiving a spatial.attach or spatial.SpatialData any more. When I close and call spatial.close() the object doesn't appear to be cleaned up properly. The next time I try to start, unity will crash.

I have also performed a firmware upgrade for the hub, imported the new Phidgets22.Net.dll to unity (to see if this one would be working), Access data (channel, serial no, etc.) has not been changed from the working version and doublechecked.
Not sure what is going wrong....

User avatar
Patrick
Lead Developer
Posts: 3199
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby Patrick » Tue Oct 01, 2019 3:28 pm

Hi,

I'd like you to enable library logging in your Unity app, this should have some clues at to what's going on.

As for using Phidgets in Unity, see: https://www.phidgets.com/?view=articles ... sWithUnity

It's important to make sure you have this bit of code, because of how the library is loaded into the Unity editor:

Code: Select all

void OnApplicationQuit()
{
   if (Application.isEditor)
      Phidget.ResetLibrary();
   
}

This makes sure that Phidgets are properly cleaned up between runs.

-Patrick

kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Thu Oct 03, 2019 7:44 am

Hi Patrick,

I finally had time to go back a version in Unity (2019.1.14) and made a very barebone test project to make sure nothing is interfering)
The cleanup procedure is promising and implemented, now Unity is not freezing any more but crashing properly (progress.. :-)

Apparently there is an access violation when calling spatial.open, specifically when the spatial is trying to asign spatial_attach(which in my barbone-case is just setting a bool)

There seems to be a timing-issue. When I debug in visual Studio and step through the code, it's working fine, I'm even getting "spatial_data".. , when I exit debugging, everything is running fine. Only when starting normally, I get this crash. I'm not sure how to resolve this...

This is the actual crash-log:

Unity Editor by Unity Technologies [version: Unity 2019.1.14f1_148b5891095a]

phidget22.DLL caused an Access Violation (0xc0000005)
in module phidget22.DLL at 0033:a61c80c4.

Error occurred at 2019-10-03_143112.
C:\Program Files\Unity\Hub\Editor\2019.1.14f1\Editor\Unity.exe, run by conta.

56% physical memory in use.
32730 MB physical memory [14352 MB free].
1964 MB process peak paging file [1709 MB used].
1017 MB process peak working set [1016 MB used].
System Commit Total/Limit/Peak: 34927MB/65460MB/46419MB
System Physical Total/Available: 32730MB/14352MB
System Process Count: 354
System Thread Count: 6378
System Handle Count: 221669
Disk space data for 'C:\Users\conta\AppData\Local\Temp\Unity\Editor\Crashes\Crash_2019-10-03_123104468\': 63713464320 bytes free of 1010640150528 total.

Read from location 00000000DEADBF0F caused an access violation.

Context:
RDI: 0x0000000000000000 RSI: 0x0000000000000000 RAX: 0x00000000deadbeef
RBX: 0x00000211a1399980 RCX: 0x00000211a1399980 RDX: 0x00000211a1399980
RIP: 0x00000211a61c80c4 RBP: 0x00000041b05ff830 SegCs: 0x0000021100000033
EFlags: 0x0000000000010297 RSP: 0x00000041b05ff758 SegSs: 0x000002110000002b
R8: 0x0000000000000000 R9: 0x0000000000000001 R10: 0x00000211ec13b7c0
R11: 0x00000211a61160f5 R12: 0x0000000000000000 R13: 0x0000000000000000
R14: 0x0000000000000000 R15: 0x00000211a1399980


Bytes at CS:EIP:
48 ff 60 20 cc cc cc cc cc cc cc cc 48 8b d1 48

Mono DLL loaded successfully at 'C:\Program Files\Unity\Hub\Editor\2019.1.14f1\Editor\Data\MonoBleedingEdge\EmbedRuntime\mono-2.0-bdwgc.dll'.


Stack Trace of Crashed Thread 27744:
0x00000211A61C80C4 (phidget22) PhidgetLock
0x00000211A62028C2 (phidget22) Phidget_setOnAttachHandler
0x000002119ECC1B8A (Phidget22.NET) Phidget22.Phidget22Imports.Phidget_setOnAttachHandler()
0x00000211A6B469BB (Phidget22.NET) Phidget22.Phidget.uninitializeBaseEvents()
0x00000211A6B4672B (Phidget22.NET) Phidget22.Spatial.uninitializeEvents()
0x00000211A6B4650F (Phidget22.NET) Phidget22.Spatial.Finalize()
0x00000211A96E94DC (mscorlib) System.Object.runtime_invoke_virtual_void__this__()
0x00007FFFC7CA2EE9 (mono-2.0-bdwgc) mono_gc_reference_queue_new
0x00007FFFC7E9ACD2 (mono-2.0-bdwgc) GC_gcj_malloc
0x00007FFFC7CA1DA9 (mono-2.0-bdwgc) mono_callspec_parse
0x00007FFFC7C65268 (mono-2.0-bdwgc) mono_threads_set_shutting_down
0x00007FFFC7C64FF6 (mono-2.0-bdwgc) mono_threads_set_shutting_down
0x00007FF840367BD4 (KERNEL32) BaseThreadInitThunk
0x00007FF841D4CEE1 (ntdll) RtlUserThreadStart
....


kiu
Phidgetly
Posts: 24
Joined: Mon Aug 19, 2019 10:28 am
Contact:

Re: Absolute Rotation Quaternion From Phidgets Spatial MOT1101_0 in Unity3d??

Postby kiu » Mon Oct 07, 2019 5:25 am

I'm aware of the threading problems that might occur with phidgets. In your example it seems that you're avoiding this by using a"methodInvoker" in visual Studio. Unfortunately, these don't exist in Unity.

Obviously, spatial.open() is called from the main thread and then throwing an access violation exception. I'm doing my best to keep everything clean and threadsafe and never had this happen using other phidgets. Is there a recommended procedure to initialize the spatial in Unity?


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 2 guests