forked from robosavvy/vive_ros
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f763e16
Showing
15 changed files
with
687 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0bb4", MODE="0666" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="28de", MODE="0666" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="0424", MODE="0666" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(vive_ros) | ||
|
||
## Find catkin macros and libraries | ||
find_package(catkin REQUIRED COMPONENTS | ||
roscpp | ||
tf | ||
std_srvs | ||
geometry_msgs | ||
) | ||
|
||
set(CMAKE_BUILD_TYPE "Release") | ||
|
||
# TODO: make find script, to use find_package(openvr REQUIRED) | ||
set(OPENVR "$ENV{HOME}/libraries/openvr") | ||
find_library(OPENVR_LIB openvr_api "${OPENVR}/lib/linux64" NO_DEFAULT_PATH) | ||
message("Found libopenvr_api: ${OPENVR_LIB}") | ||
|
||
|
||
################################### | ||
## catkin specific configuration ## | ||
################################### | ||
catkin_package() | ||
|
||
########### | ||
## Build ## | ||
########### | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ") | ||
|
||
## Specify additional locations of header files | ||
## Your package locations should be listed before other locations | ||
# TODO: find openvr | ||
include_directories( | ||
include | ||
${catkin_INCLUDE_DIRS} | ||
${OPENVR}/headers | ||
) | ||
|
||
# VIVE node: | ||
add_executable(vive_node | ||
src/vive_node.cpp | ||
src/vr_interface.cpp | ||
) | ||
target_link_libraries(vive_node ${catkin_LIBRARIES} ${OPENVR_LIB}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Installation instructions | ||
|
||
Installation instructions based on: `https://www.gamingonlinux.com/articles/first-steps-with-openvr-and-the-vive-on-linux.7229` | ||
|
||
|
||
## Download and build Christoph's OpenVR SDK fork: | ||
|
||
cd ~ | ||
mkdir libraries | ||
cd libraries | ||
git clone https://github.com/ChristophHaag/openvr.git | ||
cd openvr | ||
mkdir build | ||
cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release ../ | ||
make | ||
|
||
## Allow hardware access | ||
Then plug-in VIVE to your computer and make sure you can see the devices on `/dev/hidraw[1-6]`. | ||
|
||
Copy the file `88-vive.rules` to the folder `/etc/udev/rules.d`. Then run: | ||
|
||
sudo /etc/init.d/udev restart | ||
|
||
## Install Steam and SteamVR | ||
|
||
Go to `http://store.steampowered.com/` and download Steam for Linux. | ||
After successfully installing and running Steam, it should store its files on: `~/.local/share/Steam` | ||
|
||
Install SteamVR by using this URL `steam://install/250820`. | ||
Files should be located on: `~/.local/share/Steam/steamapps/common/SteamVR` | ||
|
||
## Configure display. | ||
|
||
Go to your OS display options to enable HMD's display. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Copyright (c) 2016, RoboSavvy | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of rosserial_tivac_tutorials nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Installation instructions can be found on `INSTALL.md`. | ||
|
||
# Usage | ||
|
||
Before start: | ||
|
||
* Make sure VIVE is present as several `/dev/hidraw*` and you have access permissions. | ||
* Make sure VIVE display is enabled as extended view. | ||
* Libraries and Steam are present on the folders described by `INSTALL.md`. | ||
|
||
Procedure: | ||
|
||
1. Start a `roscore` | ||
2. Launch the SteamVR's `vrserver` by launching the file: `roslaunch vive_ros server_vr.launch` | ||
3. Launch the node: `roslaunch vive_ros vive.launch` | ||
4. To close the node you can `Ctrl+C`. To close the vr server you have to kill the process. For convenience: `rosrun vive_ros close_servervr.sh` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef _VR_INTERFACE_H_ | ||
#define _VR_INTERFACE_H_ | ||
|
||
#include <openvr.h> | ||
#include <boost/function.hpp> | ||
|
||
typedef boost::function<void(const std::string&)> DebugMsgCallback; | ||
typedef boost::function<void(const std::string&)> InfoMsgCallback; | ||
typedef boost::function<void(const std::string&)> ErrorMsgCallback; | ||
|
||
|
||
class VRInterface | ||
{ | ||
public: | ||
VRInterface(); | ||
~VRInterface(); | ||
|
||
bool Init(); | ||
void Shutdown(); | ||
|
||
void Update(); | ||
void UpdateCalibration(); | ||
|
||
int GetDeviceMatrix(int index, double pMatrix[3][4]); | ||
int GetDeviceVel(int index, double lin_vel[3], double ang_vel[3]); | ||
bool IsDeviceConnected(int index); | ||
|
||
|
||
void setErrorMsgCallback(ErrorMsgCallback fn); | ||
void setInfoMsgCallback(InfoMsgCallback fn); | ||
void setDebugMsgCallback(DebugMsgCallback fn); | ||
|
||
|
||
private: | ||
vr::IVRSystem *pHMD_; | ||
vr::IVRChaperone *pChaperone_; | ||
|
||
uint max_devices_; | ||
vr::TrackedDevicePose_t device_poses_[vr::k_unMaxTrackedDeviceCount]; | ||
|
||
private: | ||
DebugMsgCallback debug_; | ||
InfoMsgCallback info_; | ||
ErrorMsgCallback error_; | ||
|
||
vr::ChaperoneCalibrationState cal_state_; | ||
float play_area_[2]; | ||
vr::HmdQuad_t play_quat_; | ||
|
||
std::string GetTrackedDeviceString(vr::IVRSystem *pHmd, vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError = NULL); | ||
}; | ||
|
||
#endif // _VR_INTERFACE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<env name="OPENVR" value="$(env HOME)/libraries/openvr"/> | ||
<env name="STEAM" value="$(env HOME)/.local/share/Steam"/> | ||
<env name="STEAMVR" value="$(env HOME)/.local/share/Steam/steamapps/common/SteamVR"/> | ||
<env name="LD_LIBRARY_PATH" value="$(env LD_LIBRARY_PATH):$(env HOME)/libraries/openvr/lib/linux32:$(env HOME)/libraries/openvr/lib/linux64/:\$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu:$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux64:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux64:"/> | ||
|
||
<node name="check_vr" pkg="vive_ros" type="check_vr.sh" output="screen" required="true"/> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<env name="OPENVR" value="$(env HOME)/libraries/openvr"/> | ||
<env name="STEAM" value="$(env HOME)/.local/share/Steam"/> | ||
<env name="STEAMVR" value="$(env HOME)/.local/share/Steam/steamapps/common/SteamVR"/> | ||
<!-- Everything! --> | ||
<!-- | ||
<env name="LD_LIBRARY_PATH" value="$(env LD_LIBRARY_PATH):$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu:$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux64:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux64:"/> | ||
--> | ||
<!-- For a 64bit system --> | ||
<env name="LD_LIBRARY_PATH" value="$(env LD_LIBRARY_PATH):$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux64:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux64"/> | ||
|
||
<node name="server_vr" pkg="vive_ros" type="launch_servervr.sh" output="screen" required="true"/> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<env name="OPENVR" value="$(env HOME)/libraries/openvr"/> | ||
<env name="STEAM" value="$(env HOME)/.local/share/Steam"/> | ||
<env name="STEAMVR" value="$(env HOME)/.local/share/Steam/steamapps/common/SteamVR"/> | ||
<!-- Everything! --> | ||
<!-- | ||
<env name="LD_LIBRARY_PATH" value="$(env LD_LIBRARY_PATH):$(env HOME)/libraries/openvr/lib/linux32:$(env HOME)/libraries/openvr/lib/linux64/:\$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/i386/lib/i386-linux-gnu:$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux64:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux32:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux64:"/> | ||
--> | ||
<!-- For a 64bit system --> | ||
<env name="LD_LIBRARY_PATH" value="$(env LD_LIBRARY_PATH):$(env HOME)/libraries/openvr/lib/linux64:$(env HOME)/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/bin/linux64:$(env HOME)/.local/share/Steam/steamapps/common/SteamVR/drivers/lighthouse/bin/linux64"/> | ||
|
||
<rosparam param="/vive/world_offset">[0, 0, 2]</rosparam> | ||
<rosparam param="/vive/world_yaw">0.0</rosparam> | ||
|
||
<node name="vive_node" pkg="vive_ros" type="vive_node" output="screen" required="true"/> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<package> | ||
<name>vive_ros</name> | ||
<version>0.0.1</version> | ||
<description>The vive_ros package</description> | ||
<author>Vitor Matos</author> | ||
<author email="[email protected]">Vitor Matos</author> | ||
|
||
<license>BSD</license> | ||
<url type="website">http://wiki.ros.org/vive_ros</url> | ||
<url type="repository">https://github.com/robosavvy/vive_ros</url> | ||
<maintainer email="[email protected]">Vitor Matos</maintainer> | ||
|
||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
|
||
|
||
<build_depend>roscpp</build_depend> | ||
<build_depend>geometry_msgs</build_depend> | ||
<build_depend>std_srvs</build_depend> | ||
<build_depend>tf</build_depend> | ||
|
||
<run_depend>geometry_msgs</run_depend> | ||
<run_depend>std_srvs</run_depend> | ||
|
||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
${STEAMVR}/bin/linux64/vrcmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
killall -9 vrserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
${STEAMVR}/bin/linux64/vrserver --keepalive |
Oops, something went wrong.