psmoveservice / PSMoveService

A background service that communicates with the psmove and stores pose and button data.
Apache License 2.0
587 stars 148 forks source link

linux bluetooth stubs need to be filled in #441

Open Olm-e opened 7 years ago

Olm-e commented 7 years ago

hello, when trying to compile on linux I see there are errors is the libusb package in the include names and path there are also no def for linux in some of the files ... f.ex. when fixing the include for libusb.h, it still gives this error

make
[  2%] Built target PSMoveProtocol
[  4%] Built target PSMoveMath
[  4%] Building CXX object src/psmoveservice/CMakeFiles/PSMoveService.dir/Device/USB/LibUSBBulkTransferBundle.cpp.o
/media/bla/psmove/PSMoveService/PSMoveService/src/psmoveservice/Device/USB/LibUSBBulkTransferBundle.cpp: In member function ‘virtual bool LibUSBBulkTransferBundle::initialize()’:
/media/bla/psmove/PSMoveService/PSMoveService/src/psmoveservice/Device/USB/LibUSBBulkTransferBundle.cpp:68:67: error: ‘memset’ was not declared in this scope
             memset(bulk_transfer_requests, 0, xfer_array_byte_size);
                                                                   ^
/media/bla/psmove/PSMoveService/PSMoveService/src/psmoveservice/Device/USB/LibUSBBulkTransferBundle.cpp:85:56: error: ‘memset’ was not declared in this scope
             memset(transfer_buffer, 0, xfer_buffer_size);
                                                        ^
src/psmoveservice/CMakeFiles/PSMoveService.dir/build.make:566: recipe for target 'src/psmoveservice/CMakeFiles/PSMoveService.dir/Device/USB/LibUSBBulkTransferBundle.cpp.o' failed
make[2]: *** [src/psmoveservice/CMakeFiles/PSMoveService.dir/Device/USB/LibUSBBulkTransferBundle.cpp.o] Error 1
CMakeFiles/Makefile2:174: recipe for target 'src/psmoveservice/CMakeFiles/PSMoveService.dir/all' failed
make[1]: *** [src/psmoveservice/CMakeFiles/PSMoveService.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

can someone take a look at this GNU-Linux compling process ??? (I'm ok finding errors sometimes, not really good at fixing - more user than dev ;) )

thanks you very much

(debian / mint 18)

cboulay commented 7 years ago

memset isn't found. That's odd. What's your gcc --version? I might have to add some compiler flags for setting the STL version, but memset is ancient.

Can you try adding #include <cstring> to the top of LibUSBBulkTransferBundle.cpp? I imagine you'll get another error somewhere else because memset is probably used elsewhere, but at least we'll know if this fixed your problem.

Edit: Actually, #include <cstring> should only be relevant for std::memset. Without that, we should just be using C's memset, which I thought was a core part of the language. Maybe I only ever use memset when I'm operating on strings so I include cstring anyway. I'll give this a try on my Ubuntu 16.04 box a little later today.

HipsterSloth commented 7 years ago

Unfortunately Linux isn't a supported platform at the moment. The major issue is that the Bluetooth pairing code for the controllers doesn't have a Linux implantation at the moment. I started work on this a while ago, but then got pulled away to work on other features. I've been hoping someone who does Linux development regularly would be willing to help out with this. In the meantime, you might give http://github.com/thp/psmoveapi a try. It's the predecessor to psmoveservice and it has proper Linux support.

Olm-e commented 7 years ago

thanks for the answers, I use GCC 5 on linux mint, and compile other things without problems... I'll take a look at this cstring, maybe it's a question of environment...

so if it's the bluetooth stack, whynot still use the one of psmoveapi that works ? (stupid question maybe ... ?) I'll see if I can find help by here...

I have installed psmoveapi and OSVR-psmoveapi, but these doen't give sthe same kind of control and multi-cam support, nor the option for virtual HMD. it looks like making it evolve with the functionnalities of psmoveservice is interresting for many reasons ;) thanks for the answers and the work

HipsterSloth commented 7 years ago

"so if it's the bluetooth stack, whynot still use the one of psmoveapi that works ? (stupid question maybe ... ?)"

Not a stupid question at all. That's actually what I was doing but just didn't have time to finish it up. In theory once the one Bluetooth pairing code was ported and the other small compile errors are fixed it should work. We've tried to keep everything we do cross platform as possible.

cboulay commented 7 years ago

I've been working on catching up the linux build: https://github.com/cboulay/PSMoveService/tree/linux_catchup

As of right now, everything builds except test_psmove_controller fails at linking due to libPSMoveClient_CAPI.so having undefined reference to shm_open.

Even though PSMoveService and client build and link ok, BluetoothRequestsLinux.cpp and BluetoothQueriesLinux.cpp are nothing more than stubs, so they don't actually do anything. I would be happy to yield to you @Olm-e if you want to take over filling this in, probably using https://github.com/thp/psmoveapi/blob/master/src/platform/psmove_port_linux.c as a reference.

@HipsterSloth , I made a lot of changes to the various CMakeLists files and I had to make a few other tiny changes here and there to make gcc happy. Edit: Without plugging in hardware to test, it still builds fine on Mac. Can you test this branch on Windows? If it still works then I'd like to merge for the sake of the CMake changes, even if it remains non-functional in Linux.

HipsterSloth commented 7 years ago

@cboulay Thanks for working on this Chad! I'm a big fan of the cmake cleanup changes. I just checked in a few minor build breaks (MSVC specific path issues for protocolbuf and opencv). Other than that it builds and runs fine.

Olm-e commented 7 years ago

Hi, I took a look at the bluetooth files and I'm sorry to say it's a bit over my competencies in C and protocol programing ... I can barely understand the in and out from the lib, I am not able to filter one into the other (to my own disapointment) in compiling, I got the same linking error to shm_open, as well as a missing SDL2 path in cmakeconfig that makes it break if not added by hand. and an error in renderer.cpp probably also linked to path (here it seems to look for my system SDL2...) from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/Renderer.cpp:12: /usr/include/eigen3/Eigen/src/Core/util/Constants.h:432:3: error: expected identifier before numeric constant it looks like it's not far from working, it'll make it ...

Olm-e commented 7 years ago

correction : it was Eigen3 of course , and changing it's path in the cmakecache.txt gives the same error result with some conflict with the system (x11???)

In file included from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/Core:360:0,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/../../src/psmovemath/MathEigen.h:5,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/GeometryUtility.h:10,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/Renderer.cpp:14:
/media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/src/Core/util/Constants.h:429:2: error: #error The preprocessor symbol 'Success' is defined, possibly by the X11 header file X.h
 #error The preprocessor symbol 'Success' is defined, possibly by the X11 header file X.h
  ^
[ 98%] Building CXX object src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/psmove_config_tool.cpp.o
[ 98%] Building CXX object src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/__/__/thirdparty/imgui/imgui.cpp.o
[ 99%] Building CXX object src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/__/__/thirdparty/imgui/imgui_demo.cpp.o
[ 99%] Building CXX object src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/__/__/thirdparty/imgui/imgui_draw.cpp.o
In file included from /usr/include/X11/Xlib.h:44:0,
                 from /usr/include/SDL2/SDL_syswm.h:72,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/Renderer.cpp:12:
/media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/src/Core/util/Constants.h:436:3: error: expected identifier before numeric constant
   Success = 0,        
   ^
/media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/src/Core/util/Constants.h:436:3: error: expected ‘}’ before numeric constant
/media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/src/Core/util/Constants.h:436:3: error: expected unqualified-id before numeric constant
In file included from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/Core:360:0,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/../../src/psmovemath/MathEigen.h:5,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/GeometryUtility.h:10,
                 from /media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/src/psmoveconfigtool/Renderer.cpp:14:
/media/user/b054eade-bc03-4776-add8-c93f00d9e768/psmove/PSMoveServiceLinux/thirdparty/eigen/Eigen/src/Core/util/Constants.h:549:1: error: expected declaration before ‘}’ token
 } // end namespace Eigen
 ^
src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/build.make:662: recipe for target 'src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o' failed

and still the shm_open error too

cboulay commented 7 years ago

Can you try #undef Success before the Eigen includes here?

I wonder why I didn't encounter this on my system. Maybe I'm using apt-get Eigen. Sorry I can't investigate right now.

Olm-e commented 7 years ago

I think it helps a bit, doesn't make that error again, but now it's reference to SDL that are missing... (also I'm seeing these while compiling with thread, if not, the process stops at the shm_open ref error)

[ 59%] Linking CXX executable test_console_CAPI
../psmoveclient/libPSMoveClient_CAPI.so: undefined reference to `shm_open'
collect2: error: ld returned 1 exit status
src/tests/CMakeFiles/test_console_CAPI.dir/build.make:95: recipe for target 'src/tests/test_console_CAPI' failed
make[2]: *** [src/tests/test_console_CAPI] Error 1
CMakeFiles/Makefile2:561: recipe for target 'src/tests/CMakeFiles/test_console_CAPI.dir/all' failed
make[1]: *** [src/tests/CMakeFiles/test_console_CAPI.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 60%] Linking CXX executable PSMoveConfigTool
[ 60%] Linking CXX executable PSMoveService
/usr/bin/ld: CMakeFiles/PSMoveService.dir/Device/View/ServerTrackerView.cpp.o: undefined reference to symbol 'shm_unlink@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/librt.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
src/psmoveservice/CMakeFiles/PSMoveService.dir/build.make:1381: recipe for target 'src/psmoveservice/PSMoveService' failed
make[2]: *** [src/psmoveservice/PSMoveService] Error 1
CMakeFiles/Makefile2:174: recipe for target 'src/psmoveservice/CMakeFiles/PSMoveService.dir/all' failed
make[1]: *** [src/psmoveservice/CMakeFiles/PSMoveService.dir/all] Error 2
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `Renderer::init()':
Renderer.cpp:(.text+0x24a): undefined reference to `SDL_CreateWindow'
Renderer.cpp:(.text+0x2c8): undefined reference to `SDL_GL_CreateContext'
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `Renderer::destroy()':
Renderer.cpp:(.text+0x650): undefined reference to `SDL_GL_DeleteContext'
Renderer.cpp:(.text+0x679): undefined reference to `SDL_DestroyWindow'
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `Renderer::renderUIBegin()':
Renderer.cpp:(.text+0xa1b): undefined reference to `SDL_GetWindowSize'
Renderer.cpp:(.text+0xb06): undefined reference to `SDL_GetWindowFlags'
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `Renderer::renderEnd()':
Renderer.cpp:(.text+0xd20): undefined reference to `SDL_GL_SwapWindow'
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `ImGui_ImplSdl_GetClipboardText()':
Renderer.cpp:(.text+0x4979): undefined reference to `SDL_GetClipboardText'
CMakeFiles/PSMoveConfigTool.dir/Renderer.cpp.o: In function `ImGui_ImplSdl_SetClipboardText(char const*)':
Renderer.cpp:(.text+0x4993): undefined reference to `SDL_SetClipboardText'
collect2: error: ld returned 1 exit status
src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/build.make:879: recipe for target 'src/psmoveconfigtool/PSMoveConfigTool' failed
make[2]: *** [src/psmoveconfigtool/PSMoveConfigTool] Error 1
CMakeFiles/Makefile2:328: recipe for target 'src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/all' failed
make[1]: *** [src/psmoveconfigtool/CMakeFiles/PSMoveConfigTool.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
cboulay commented 7 years ago

What does dpkg -L libsdl2-dev give you? (Please paste results inside triple backtick)

cboulay commented 7 years ago

Also, can you copy-paste the lines from cmake output about finding third party packages? Here are mine:

-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0") 
-- “UsingOpenCVin/usr/local/share/OpenCV”
-- Found OpenCV: /usr/local (found version "3.2.0") 
-- Boost version: 1.64.0
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found Protobuf: /usr/local/lib/libprotobuf.a  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libudev'
--   Found libudev, version 229
-- Checking for module 'bluez'
--   Found bluez, version 5.37
-- Found LIBUSB: debug;/usr/lib/x86_64-linux-gnu/libusb-1.0.a;optimized;/usr/lib/x86_64-linux-gnu/libusb-1.0.a  
cboulay commented 7 years ago

I fixed the Success problem with X11/Eigen, and a Status problem with X11/OpenCV. I fixed an SDL2 include problem. I fixed the shmem problem (need to link librt). Now, on my system, everything builds without any special cmake options. (bluetooth entries are still stubs so they don't do anything). Do a git checkout .. && git fetch && git pull. I think the instructions on the Wiki are up-to-date with my system, but it's possible that I installed some libraries on my system that you do not have.

Olm-e commented 7 years ago

ok ! now it builds ! ... :D

cboulay commented 7 years ago

OK I just merged and deleted the linux branch. I'll need to make another branch if/when I find time to get the bluetooth functionality working. I just re-read an old comment mentioning that psmoveapi's approach to bluez config might not be ideal, so maybe more investigation is needed. I'm changing the title of this issue to reflect the current status.

Olm-e commented 6 years ago

just to know : any news on this ? (one year later) ;) OpenHMD is recognising the PSVR, would be great to add the position tracking and controllers from here ... :D