User Tools

Site Tools


doc:lighthouse:setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:lighthouse:setup [2019-03-08 07:52]
arnaud
doc:lighthouse:setup [2020-05-12 14:35] (current)
kimberly
Line 1: Line 1:
 +<WRAP center round important 60%>
 +This page has deprecated and moved to the new documentation framework of the main Bitcraze website. Please go to [[https://www.bitcraze.io/documentation/system/]]
 +</WRAP>
 +
 ====== Setting up the lighthouse deck ====== ====== Setting up the lighthouse deck ======
  
Line 5: Line 9:
 The lighthouse deck allows to use the HTC-Vive/SteamVR lighthouse tracking system to fly Crazyflie autonomously. The easiest to get started is to have an HTC Vive VR system already up and running using Basestation V1. It is possible to setup the system with only 2 Basestation V1 and one Vive controller or tracker. The lighthouse deck allows to use the HTC-Vive/SteamVR lighthouse tracking system to fly Crazyflie autonomously. The easiest to get started is to have an HTC Vive VR system already up and running using Basestation V1. It is possible to setup the system with only 2 Basestation V1 and one Vive controller or tracker.
  
-The VR computer must have [[https://www.python.org/|Python 3 64Bit]] installed and in the path in order to be able to extract the base-station position. When everything is setup, teamVR and the VR computer are not required anymore: the Crazyflie will autonomously estimate its position from the lighthouse signals.+The VR computer must have [[https://www.python.org/|Python 3 64Bit]] installed and in the path in order to be able to extract the base-station position. When everything is setup, steamVR and the VR computer are not required anymore: the Crazyflie will autonomously estimate its position from the lighthouse signals.
  
-In order to setup the system you must also be able to compile a custom firmware for your Crazyflie and to program your Crazyflie 2.X. To do so youcan follow the [[https://www.bitcraze.io/getting-started-with-the-crazyflie-2-0/|Getting started with Crazyflie 2.X]] and [[https://www.bitcraze.io/getting-started-with-development/|Getting started with development]] guides.+In order to setup the system you must also be able to compile a custom firmware for your Crazyflie and to program your Crazyflie 2.X. To do so you can follow the [[https://www.bitcraze.io/getting-started-with-the-crazyflie-2-0/|Getting started with Crazyflie 2.X]] and [[https://www.bitcraze.io/getting-started-with-development/|Getting started with development]] guides.
  
 ===== Setting up SteamVR without Head Mounted Display ===== ===== Setting up SteamVR without Head Mounted Display =====
Line 13: Line 17:
 If you already have a setup VR system jump to the next section. If you already have a setup VR system jump to the next section.
  
-It is possible to setup the SteamVR without a Head Mounted Display (HDM). This allows to setup a minimal system with just two Base stations and one controller or tracker. It can be quite useful when a full VR system is not needed or to setup a system at fairs or conference.+It is possible to setup the SteamVR without a Head Mounted Display (HMD). This allows to setup a minimal system with just two Base stations and one controller or tracker. It can be quite useful when a full VR system is not needed or to setup a system at fairs or conference.
  
-Follow the guide from Triad: [[http://help.triadsemi.com/steamvr-tracking/steamvr-tracking-without-an-hmd|SteamVR Tracking without an HMD]]. This has been tested to work on Windows and Linux.+Follow the guide from Triad: [[http://help.triadsemi.com/steamvr-tracking/steamvr-tracking-without-an-hmd|SteamVR Tracking without an HMD]] (the steps after 14 is optional). This has been tested to work on WindowsLinux and Mac.
  
-The only difference with an HDM setup is the orientation of the space: with an HDM the space will be oriented when you setup the room. Without an HDM the slave base station (the one in Mode A or C) will be at the origin of the space and the Z axis will be normal to the base station window.+<WRAP center round info> 
 +**OSX**
  
-===== Setting up the space origin and orientation with an HDM =====+The osx implementation seems to be a bit shaky, but it is possible to make it work. I used the "macos_beta" flavour. 
 + 
 +The paths in the triad instructions are for Windows. On Mac OSX you will find the files to update in 
 + 
 +<code> 
 +/Users/<your user>/Library/Application Support/Steam/steamapps/common/SteamVR/SteamVR.app/Contents/MacOS/runtime/drivers/null/resources/settings/default.vrsettings 
 + 
 +/Users/<your user>/Library/Application Support/Steam/steamapps/common/SteamVR/SteamVR.app/Contents/MacOS/runtime/resources/settings/default.vrsettings 
 +</code> 
 + 
 +</WRAP> 
 + 
 + 
 +For the floor to be flat, it is good to start steamVR with the controller placed on the floor. The only difference with an HMD setup is the orientation of the space: with an HMD the space will be oriented when you setup the room. Without an HMD the master base station (the one in Mode B) will be at the origin of the space. The Z axis will be the vector normal to the base station window, pointing toward the inside of the base station and rotated around X to be parallel with the floor. 
 + 
 +{{:doc:lighthouse:coordinate_orign.png?200|}} 
 + 
 + 
 +<WRAP center round info> 
 +**Troubleshooting** 
 + 
 +If you get the following message when running the tracker_test.py script of the tutorial (step 16): 
 + 
 +''openvr.OpenVRError: b'VRInitError_Init_VRClientDLLNotFound' (error number 102)'' 
 + 
 +Or this when running the script from the Crazyflie firmware repos: 
 + 
 +<code> 
 +$ python3 get_bs_position.py  
 +Openning OpenVR 
 +python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime' 
 +Segmentation fault (core dumped) 
 +</code> 
 + 
 +Then you are maybe missing some essential packages for openvr: 
 + 
 +  * libudev-dev 
 +  * libvulkan-dev 
 +  * libsdl2-dev 
 + 
 +On Ubuntu: 
 + 
 +<code> 
 +$ sudo apt-get install libudev-dev  libvulkan-dev  libsdl2-dev 
 +$ python3 -m pip uninstall openvr 
 +$ python3 -m pip install openvr 
 +</code> 
 + 
 +if this still doesn't work, please check this forum-thread for other options: 
 +[[https://github.com/cmbruns/pyopenvr/issues/30]] 
 + 
 +</WRAP> 
 + 
 +<WRAP center round info> 
 +**Troubleshooting²** 
 + 
 +When running SteamVR on Linux, by default the access right to USB device might not be configured right. If you have problem connecting the tracker/controller/HMD you can add a udev rules that gives full access to any USB Valve hardware to all users on your system: 
 +<code> 
 +# cat > /etc/udev/rules.d/99-steamvr.rules << EOF 
 +KERNEL=="hidraw*", ATTRS{idVendor}=="28de", MODE=="0666" 
 +EOF 
 +</code> 
 + 
 +You may need to restart SteamVR to see the connected devices. 
 +</WRAP> 
 + 
 +===== Setting up the space origin and orientation with an HMD =====
  
 When using a full VR setup, SteamVR has a developer menu that allows to quickly and accurately setup the system origin and orientation. By default the system origin is going to be placed in the center of the playground and the orientation will depend of the shape and of where the monitor is located. When using a full VR setup, SteamVR has a developer menu that allows to quickly and accurately setup the system origin and orientation. By default the system origin is going to be placed in the center of the playground and the orientation will depend of the shape and of where the monitor is located.
  
-To set the orientation and origin yourself, you can go to the SteamVR settings, to the developer subscreen and you can display the room overview. Then you can place the HDM on the floor, with the front pointing at where you want the Crazyflie X axis to point, and then click 'Quick Calibrate':+To set the orientation and origin yourself, you can go to the SteamVR settings, to the developer subscreen and you can display the room overview. Then you can place the HMD on the floor, with the front pointing at where you want the Crazyflie X axis to point, and then click 'Quick Calibrate':
 {{:doc:lighthouse:quit_calibrate_space.png|}} {{:doc:lighthouse:quit_calibrate_space.png|}}
  
 ===== Getting the base station position and programming the Crazyflie ===== ===== Getting the base station position and programming the Crazyflie =====
  
-Launch SteamVR and make sure at least one controller or the HDM is tracking:+Launch SteamVR and make sure at least one controller or the HMD is tracking:
  
 {{:doc:lighthouse:steamvr_tracking.png|}} {{:doc:lighthouse:steamvr_tracking.png|}}
Line 34: Line 105:
 Clone or download the latest version or the [[https://github.com/bitcraze/crazyflie-firmware|Crazyflie firmware]] on the VR computer, open a command line window and navigate to the Crazyflie firmware. There you can make sure you have the openVR python package and run the script to get the basestation position: Clone or download the latest version or the [[https://github.com/bitcraze/crazyflie-firmware|Crazyflie firmware]] on the VR computer, open a command line window and navigate to the Crazyflie firmware. There you can make sure you have the openVR python package and run the script to get the basestation position:
 <code> <code>
-pip install openvr+python3 -m pip install openvr
 cd tools\lighthouse cd tools\lighthouse
-python get_bs_position.py+python3 get_bs_position.py
 </code> </code>
  
Line 51: Line 122:
 </code> </code>
  
-<WRAP center round info 80%+<WRAP center round info> 
-**Note**: If you have a setup without HDM and you want to set the origin of the space on the floor, you can open the get_bs_position.py script and modify the top of it to set "CENTER_AROUND_CONTROLLER = True". Be aware that this will put the SteamVR and your space out of sync, so none of the example using the SteamVR coordinate will work correctly.+**Note**: If you have a setup without HMD and you want to set the origin of the space on the floor, you can open the get_bs_position.py script and modify the top of it to set "CENTER_AROUND_CONTROLLER = True". Be aware that this will put the SteamVR and your space out of sync, so none of the example using the SteamVR coordinate will work correctly.
 </WRAP> </WRAP>
  
  
-Copy the last two lines and, on the computer or virtual machine you use for Crazyflie development, past them in the file 'src/deck/drivers/src/lighthouse.c'. It should replace the content of //baseStationsGeometry[]// and the line "#define DISABLE_DRIVER" should be commented to enable the driver:+Copy the last two lines and, on the computer or virtual machine you use for Crazyflie development, past them in the file 'src/deck/drivers/src/lighthouse.c'. It should replace the content of //baseStationsGeometry[]// and the line "#define DISABLE_LIGHTHOUSE_DRIVER" should be commented to enable the driver:
 {{:doc:lighthouse:modified_lighthouse_code.png|}} {{:doc:lighthouse:modified_lighthouse_code.png|}}
 <code c> <code c>
-// #define DISABLE_DRIVER+// #ifndef DISABLE_LIGHTHOUSE_DRIVER 
 +//   #define DISABLE_LIGHTHOUSE_DRIVER 1 
 +// #endif
  
 baseStationGeometry_t baseStationsGeometry[] = { baseStationGeometry_t baseStationsGeometry[] = {
Line 67: Line 140:
 </code> </code>
  
-Now that the Crazyflie firmware is modified accordingly you can save, compile and program the Crazyflie. For example this can be done from command line with:+Now that the Crazyflie firmware is modified you can save, compile and program the Crazyflie. For example this can be done from command line with:
 <code> <code>
 make make
Line 75: Line 148:
 ===== Space orientation, startup position ===== ===== Space orientation, startup position =====
  
-The orientation of the flying space will follow the orientation of the OpenVR space but in more 'robotic' coordinate system (ie. Crazyflie wants Z to point up!). +The OpenVR uses different coordinate system than the Crazyflie. The Crazyflie coordinate system is used through out the Bitcraze code, but if you want to convert between the two, the following rotation is done from the OpenVR space to the Crazyflie coordinate system:
- +
-The following translation is done from the OpenVR space to the Crazyflie coordinated system:+
 ^  Crazyflie  ^  OpenVR  ^ ^  Crazyflie  ^  OpenVR  ^
 |             -Z     | |             -Z     |
Line 83: Line 154:
 |              Y     | |              Y     |
  
-This allows to easily orient the Crazyflie when setting up the system with an HDM.+The Lighthouse deck has 4 receivers and can recover its orientation. The Crazyflie can be started in any orientation when using the lighthouse system.  
 + 
 +You can test if the positioning is working by starting the Crazyflie facing X and using the clients "Position hold" mode, this should drift a little bit (mostly in Z) due to an estimator bug, though you should be able to get a quite stable flight and be able to control the Crazyflie position with the gamepad. 
 + 
 +===== The number of basestations and frame synchronization ===== 
 + 
 +The lighthouse deck works with one or two V1 basestations but the estimated position will be better and more stable with two basestations. When using two basestations, one of them may be occluded temporarily, and the Crazyflie will use the other one for positioning.  
 + 
 +The protocol for the lighthouse is composed of frames starting with sync pulses from the basestations. The sync pulses are used to identify which basestation the frame is originating from and this information is essential for correct positioning. When one basestation is occluded, only sync pulses from the visible basestation will be available to the system, which is fine as long as the the system can keep track of the frames. If we loose track of the frames, for instance if both basestations are occluded, the system has to re-synch again to function, but this is a quick process when the basestations are visible. 
 +Due to the design of the lighthouse protocol, visibility to both basestations is always required for synchronization or re-synchronization in a two basestation system. 
 + 
 +===== Position estimation methods =====
  
-While the Lighthouse deck has 4 receiver and so can recover its orientation, this is not implemented yet. So, similarly to when flying in the LPS it is very important to start the Crazyflie with a correct orientation. It should be started with the antenna in the direction of X positive: +There are currently two ways of calculating the position using the lighthouse.
-{{:doc:lps:crazyflie_isometric_drawing_2.png?300|}}+
  
-The safest way to verify the orientation of the space is to look at the estimated position. In the client you can create a new log block in "settings/logging configurationcontaining "stateEstimate.x/y/z". You can then look at it in the plotter and move the Crazyflie around to understand how is X positive oriented:+The first method that was implemented calculates two vectors (or beams) from the basestations, based on the sweep angles measured by the sensors on the Crazyflie. The intersection point between the beams is the position of the Crazyflie, and this point is pushed into the estimatorWe call this method the "crossing beammethod 
 +A more recent implementation pushes the sweep angles from the base stations into the estimator and lets the kalman filter calculate the position based on this information. This method is called the "sweep angle" method and also works if only one basestation is available.  
 +It is possible to change positioning method "on the fly" by setting the lighthouse.method parameter. The sweep angle method is the default.
  
-{{:doc:lighthouse:estimated_potision.png?400|}} 
  
-Once you have located X positive, you can test if the positioning is working by starting the Crazyflie facing X and using the clients "Position hold" mode, this should drift a little bit (mostly in Z) due to an estimator bug, though you should be able to get a quite stable flight and be able to control the Crazyflie position with the gamepad. 
  
  
doc/lighthouse/setup.1552027943.txt.gz · Last modified: 2019-03-08 07:52 by arnaud