Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to test the tracking in SteamVR without an HMD? #2

Closed
Isopodus opened this issue Feb 6, 2022 · 21 comments
Closed

Is there a way to test the tracking in SteamVR without an HMD? #2

Isopodus opened this issue Feb 6, 2022 · 21 comments

Comments

@Isopodus
Copy link

Isopodus commented Feb 6, 2022

First of all thank you for this cool project, it looks very promising!

I already have the working headtracker with the Razor firmware and modified Output.ino file (as per your tutorial), but sadly I do not have any MIPI display yet.

SteamVR won't let setup and run the VR scene without an HMD attached, so I tried to use the null driver and "allowMultipleDrivers" in steamvr.vrsettings to launch the scene without a physical HMD, but looks like your driver is not being loaded if there is no physical display active (i.e. Arduino LEDs are not flashing as when COM port connection establishes, as well as I can connect to this COM port with another program, meaning it is not actively used).

Any other settings (like setting the COM port etc) are done per tutorial as well, so should be good to go.

Did you have any experience with settings this up without a real HMD? A friend of mine says he can borrow me a real helmet to test this, but I guess it will just use it's internal headtracker and drivers which will not work either. The null driver solution looks promising, but strangely the driver is not activated (though I can see it's being loaded in log files and debug console).

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

I played with this around a bit more, setting the matching render and window size for the null driver and arduinohmd driver allowed me to display the scene on the primary monitor.

Here are some logs saying there were no suitable devices found form arduinohmd. Does this mean it can't connect to an arduino, or it just says there is no HMD found? Anyway, I guess this message tells exactly why the driver doesn't stratup.

driver arduinohmd implements interfaces IVRSettings_003 ITrackedDeviceServerDriver_005 IVRDisplayComponent_002 IVRDriverDirectModeComponent_007 IVRCameraComponent_003 IServerTrackedDeviceProvider_004 IVRWatchdogProvider_001 IVRVirtualDisplay_002 IVRDriverManager_001 IVRResources_001 IVRCompositorPluginProvider_001 
Loaded server driver arduinohmd (IServerTrackedDeviceProvider_004) from J:\Games\Steam\steamapps\common\SteamVR\drivers\arduinohmd\bin\win64\driver_arduinohmd.dll
Driver arduinohmd has no suitable devices.

@r57zone
Copy link
Owner

r57zone commented Feb 6, 2022

Hello, there is no need for a null driver, this driver supports image output without a second display. You just need to set windows = 0, windows = 0, as well as windowWidth and windowHeight according to the resolution of your monitor, then you will get a stereo image running on your main screen, as in my videos.

You should also disable the null driver, otherwise a conflict will occur, I'm not sure they will work.

@r57zone
Copy link
Owner

r57zone commented Feb 6, 2022

It turns out that you need to unpack the Arduino driver again, delete the steamvr file.vr settings, change the resolution in the config (...\Steam\steamapps\common\SteamVR\drivers\arduinohmd\resources\settings) (if your monitor is not at 1920x1080) and just launch Steam. You will also need calibration (next, 170cm, next, finish).

Have you recently bought a GY 85 board? have there been any problems with the data? Is there any drifting?

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

Just tried it out, disabled the null driver but unfortunately SteamVR said "no helmet recognized".

Will try the full re-setup solution now. EDIT: Do I need to change the render width as well?

The GY 85 works well, tested on two different projects already and there was no drifting whatsoever.

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

I deleted steamvr config file (in Steam/config) and reinstalled the driver, set COM port, restarted steam. The window size matches my monitor (Full HD) except the renderWidth, as its 1080 by 1080 and not 1980 by 1080 in driver steamvr block. This didn't work, then tried with 1920 render width, nothing as well. SteamVR is just waiting for me to connect a helmet when I start it up.

I also tried to set the window size in Steam/config/steamvr.vrsettings like this:

      "renderHeight" : 1080,
      "renderWidth" : 1920,
      "windowHeight" : 1080,
      "windowWidth" : 1920,
      "windowX" : 0,
      "windowY" : 0

But no luck as well :(

@r57zone
Copy link
Owner

r57zone commented Feb 6, 2022

You also need to change the com port number

{
   "arduinohmd" : {
      "COMPort" : 3,
      "CenteringKey" : 101,
      "CrouchPressKey" : 111,
      "CrouchOffset" : 0.7
   },

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

Yep I did this as well :) Do I understand properly that COM12 will be "COMPort" : 12?

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

Take a look at full settting, my monitor is exact 1920 by 1080:
Steam/config/steamvr.vrsettings

{
   "DesktopUI" : {
      "pairing" : "568,271,800,600,0",
      "settings_desktop" : "568,271,800,600,0"
   },
   "steamvr" : {
      "installID" : "3172820467828783888",
      "lastVersionNotice" : "1.20.4",
      "lastVersionNoticeDate" : "1634679606",
      "renderHeight" : 1080,
      "renderWidth" : 1080,
      "windowHeight" : 1080,
      "windowWidth" : 1920,
      "windowX" : 0,
      "windowY" : 0
   }
}

Steam\steamapps\common\SteamVR\drivers\arduinohmd\resources\settings\default.vrsettings

{
   "arduinohmd" : {
      "COMPort" : 12,
      "CenteringKey" : 101,
      "CrouchPressKey" : 111,
      "CrouchOffset" : 0.7
   },
   "steamvr" : {
      "DebugMode" : false,
      "Stereo" : true,
      "DistanceBetweenEyes" : 0,
      "DistortionK1" : 0.91,
      "DistortionK2" : 0.93,
      "ScreenOffsetX" : 0,
      "ZoomHeight" : 0.8,
      "ZoomWidth" : 0.8,
      "FOV" : 57.296,
      "displayFrequency" : 60,
      "renderHeight" : 1080,
      "renderWidth" : 1080,
      "secondsFromVsyncToPhotons" : 0.004999999888241291,
      "serialNumber" : "1001",
      "windowHeight" : 1080,
      "windowWidth" : 1920,
      "windowX" : 0,
      "windowY" : 0
   }
}

@r57zone
Copy link
Owner

r57zone commented Feb 6, 2022

Yep, everything looks right

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

Sadly it doesn't work :( SteamVR is still waiting for me to connect the helmet :(
Have you ever managed to get it working without an HMD?

@r57zone
Copy link
Owner

r57zone commented Feb 6, 2022

Sometimes I run it with the second display turned off, there are no problems.

My configs:
steamvr.vrsettings

{
   "dashboard" : {
      "enableDashboard" : false
   },
   "steamvr" : {
      "activateMultipleDrivers" : true,
      "allowSupersampleFiltering" : false,
      "background" : "#A0A0A0FF",
      "enableHomeApp" : false,
      "installID" : "6804186197516517200",
      "lastVersionNotice" : "1.20.4",
      "lastVersionNoticeDate" : "1634679606",
      "showAdvancedSettings" : true,
      "showMirrorView" : false
   }
}

default.vrsettings

{
   "arduinohmd" : {
      "COMPort" : 3,
      "CenteringKey" : 101,
      "CrouchPressKey" : 111,
      "CrouchOffset" : 0.7
   },
   "steamvr" : {
      "DebugMode" : false,
      "Stereo" : true,
      "DistanceBetweenEyes" : 17,
      "DistortionK1" : 0.9100000262260437,
      "DistortionK2" : 0.93000000715255737,
      "ScreenOffsetX" : 0,
      "ZoomHeight" : 0.92000001668930054,
      "ZoomWidth" : 0.92000001668930054,
      "FOV" : 60,
      "displayFrequency" : 60,
      "renderHeight" : 1080,
      "renderWidth" : 1080,
      "secondsFromVsyncToPhotons" : 0.004999999888241291,
      "serialNumber" : "1001",
      "windowHeight" : 1440,
      "windowWidth" : 2560,
      "windowX" : 1920,
      "windowY" : 0
   }
}

When I need to display an image on the first main monitor, I just replace windowX to 0, as well as windowWidth to 1920, and windowHeight to 1080.

You can also try changing DebugMode to true.

@Isopodus
Copy link
Author

Isopodus commented Feb 6, 2022

Still no luck, "Awaiting helmet". Web console outputs Driver arduinohmd has no suitable devices. as before. Somehow for the null driver it was displaying the image on my main monitor, but it doesn't work here... I'm out of any ideas 😢

@Isopodus
Copy link
Author

Isopodus commented Feb 7, 2022

Took a look at the code a bit and it seems there is something wrong about the ArduinoIMUStart function at driver_arduinohmd.cpp... First of all I can notice the port baud rate is set to 115200 while the Razor tracker sketch has this value set to 57600, but that not the root of the problem. Most likely the serial connection fails before that when checking the hSerial status for INVALID_HANDLE_VALUE or other errors, here's the whole function so you don't need to search for it:

void ArduinoIMUStart() {
TCHAR PortName[15] = { 0 };
_stprintf(PortName, TEXT("COM%d"), comPortNumber);
//CString sPortName;
//sPortName.Format(_T("COM%d"), IniFile.ReadInteger("Main", "ComPort", 2));
hSerial = ::CreateFile(PortName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hSerial != INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_NOT_FOUND) {
DCB dcbSerialParams = { 0 };
dcbSerialParams.DCBlength = sizeof(dcbSerialParams);
if (GetCommState(hSerial, &dcbSerialParams))
{
dcbSerialParams.BaudRate = CBR_115200;
dcbSerialParams.ByteSize = 8;
dcbSerialParams.StopBits = ONESTOPBIT;
dcbSerialParams.Parity = NOPARITY;
if (SetCommState(hSerial, &dcbSerialParams))
{
HMDConnected = true;
PurgeComm(hSerial, PURGE_TXCLEAR | PURGE_RXCLEAR);
pArduinoReadThread = new std::thread(ArduinoIMURead);
}
}
}
}

Arduino always does blink when a new serial connection gets active, so this might be the case why it doesn't for me - its not connecting.
Especially the HMDConnected = true only gets called when a serial connection establishes, so that's why I'm getting no device error and SteamVR is waiting for an HMD to be connected, I think.

I tried to build the project with CMake file you provided but couldn't make it into .dll's as needed, so it would be great if you give me any instructions/compiler params on this, then I could play around with it a bit to try find the issue.

OR

I will be very thankful if you have any ideas about this code part and could recompile it. I took a look at different serial connection examples and most of them use additional slashes before the COM Port like this:

HANDLE serialHandle;

serialHandle = CreateFile("\\\\.\\COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

Could this be a reason why it's not working on my machine? Btw I'm running Win 10.

Thank you for your patience so far!

@r57zone
Copy link
Owner

r57zone commented Feb 8, 2022

Maybe change the Razor imu sketch, make the speed 115200?

@Isopodus
Copy link
Author

Isopodus commented Feb 8, 2022

Already did that, didn't work. It's not the problem with arduino or something, it just doesn't connect.

@Isopodus
Copy link
Author

Isopodus commented Feb 8, 2022

Okay, looks like I found a way to compile everything, I'll play around with it a bit and say if there is a solution that worked for me.

@Isopodus
Copy link
Author

Isopodus commented Feb 8, 2022

Yes! Adding those slashes (\.\COM123) did the thing! I'm not sure if this will work on your machine as well, so would be great if you can try it out. Can you add me as a repo contributor so I can push a branch and create a pull request with a fix?

Here is the recompiled x64 dll for you to test, but would be great if you could recompile a win32 one for a release version as well!
driver_arduinohmd.zip

Also, regarding Razor Output.ino: I can see it has a changed output format, even though there is a config var in the main sketch file as well. So because we need to change the baudrate anyway there's no need to change the Output.ino file, just change the output format (I checked, it works).

So the new RazorAHRS.ino config before flashing would be:

  1. Uncomment the proper magnetometer model at line 161 (10736 for GY-85)
    #define HW__VERSION_CODE 10736 // SparkFun "9DOF Razor IMU" version "SEN-10736" (HMC5883L magnetometer)

  2. Change the output baud rate to 115200 at line 170
    #define OUTPUT__BAUD_RATE 115200

  3. Change the output format to OUTPUT__FORMAT_BINARY at line 189
    int output_format = OUTPUT__FORMAT_BINARY;

And no need to replace Output.ino file!

@r57zone
Copy link
Owner

r57zone commented Feb 8, 2022

It looks like the problem occurs if you use a port higher than 9. I'll fix it as soon as I have time.

You can also simply change the com port in the properties and change the number of the com port to 3-4-5 or something like that.

@Isopodus
Copy link
Author

Isopodus commented Feb 8, 2022

Yes, changing the port number to COM4 reconnecting the tracker and using the old (not recompiled) driver works too.

@r57zone
Copy link
Owner

r57zone commented Feb 12, 2022

Added a fix, everything should be fine now. If you can check it out, it would be great.
https://github.com/r57zone/OpenVR-ArduinoHMD/releases

@Isopodus
Copy link
Author

Yep, works like a charm! Thank you for you cooperation and support! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants