Optitrack on Raspberry Pi
(→Optitrack setup) |
(→Install) |
||
Line 9: | Line 9: | ||
The Git repository is maintained, so you should keep the modifications to this file small, so that future updates are easily integrated. | The Git repository is maintained, so you should keep the modifications to this file small, so that future updates are easily integrated. | ||
− | ==Install== | + | ==Install original sample version == |
Get client from https://github.com/b4be1/packet-client-linux | Get client from https://github.com/b4be1/packet-client-linux | ||
Line 35: | Line 35: | ||
add_executable(PacketClient PacketClient.cpp) | add_executable(PacketClient PacketClient.cpp) | ||
target_link_libraries(PacketClient pthread) | target_link_libraries(PacketClient pthread) | ||
+ | |||
+ | ==Install ASTA version == | ||
+ | |||
+ | The Asta version is adapted to the Asta optitrack version and includes data extraction for solid bodies, and should be easily to include in other projects. | ||
+ | |||
+ | Get the sourcecode | ||
+ | |||
+ | Install prerequisites. | ||
+ | |||
+ | sudo apt install subversion cmake | ||
+ | |||
+ | Get from repository | ||
+ | |||
+ | cd | ||
+ | svn co svn://repos.gbar.dtu.dk/jcan/asta optiAsta | ||
+ | cd optiAsta | ||
+ | mkdir build | ||
+ | cd build | ||
+ | cmake .. | ||
+ | make | ||
+ | |||
+ | It should produce an executable called optiAsta, run by: | ||
+ | |||
+ | cd ~/optiAsta/build/optiAsta | ||
== Raspberry setup == | == Raspberry setup == |
Revision as of 16:01, 19 May 2021
Using Optitrack and thin NatNet client using C++
Back to ASTA motion capture
Contents |
Use
The PacketClient described here is a "Direct Depacketization" code for NatNet and is not using the NatNat SDK, and thus have to be updated if the data structure used in NatNet is changed.
The Git repository is maintained, so you should keep the modifications to this file small, so that future updates are easily integrated.
Install original sample version
Get client from https://github.com/b4be1/packet-client-linux e.g. directly to the raspberry:
git clone https://github.com/b4be1/packet-client-linux.git cd packet-client-linux mkdir build cd build cmake .. make
Filelist:
NatNetClient.py - python client requirements.txt - almost empty CMakeLists.txt - cmake instructions PacketClient.cpp - source code README.md - how to use/compile
The CMakeLists.txt is rather short (only the pthread library is needed):
cmake_minimum_required(VERSION 2.8) project(PacketClient) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") add_executable(PacketClient PacketClient.cpp) target_link_libraries(PacketClient pthread)
Install ASTA version
The Asta version is adapted to the Asta optitrack version and includes data extraction for solid bodies, and should be easily to include in other projects.
Get the sourcecode
Install prerequisites.
sudo apt install subversion cmake
Get from repository
cd svn co svn://repos.gbar.dtu.dk/jcan/asta optiAsta cd optiAsta mkdir build cd build cmake .. make
It should produce an executable called optiAsta, run by:
cd ~/optiAsta/build/optiAsta
Raspberry setup
On the Raspberry Pi set the wireless network to access the dedicated Optitrack network
Modify the /etc/wpa_supplicant/wpa_supplicant.conf by adding the network groups. The 5Ghz SSID has in this case higher priority (higher number).
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev ctrl_interface_group=0 update_config=1 country=DK network={ ssid="asta_optitrack" psk="asta2020" priority=1 } network={ ssid="asta_optitrack_5G" psk="asta2020" priority=2 }
Restart the network by reboot or just restart the network:
sudo /etc/init.d/networking restart
Optitrack setup
In
- EDIT mode (bottom of window left)
In 'View' and 'Data streaming pane'
- select 'local interface' to the IP address of the server (192.168.1.129) and
- deselect other streaming services (VRPN and Trackd) if not used by others
In 'View' and 'Assets Pane'
- check the relevant rigid bodies
Then
- go live (bottom of window left)
and assuming there is at least one rigid body defined and visible, streaming should commence.
Modify source
The NatNet version should be changed - it is hard-coded in source file.
cd ~/packet-client-linux nano PacketClient.cpp
A bit down change the NatNetVersion to 3.1 (to fit Motive version 2.2)
// Versioning int NatNetVersion[4] = {3, 1, 0, 0}; int ServerVersion[4] = {0, 0, 0, 0};
The multicast address is "239.255.42.99" and should not be changed.
Compile the client
Compile
cd ~/packet-client-linux/build make
Run the client
cd ~/packet-client-linux/build ./PacketClient DESKTOP-OVLVRUD.local 192.168.1.136
where DESKTOP-OVLVRUD is the hostname of the Optitrack server (in ASTA) and 192.168.1.136 is the IP of the raspberry pi in this case.
Data in client
The client should then print package data on the console. The frame data packet looks like this:
Begin Packet ------- Message ID : 7 Byte count : 220 Frame # : 285290 Marker Set Count : 0 Rigid Body Count : 1 ID : 20 pos: [0.73,0.57,-0.15] ori: [-0.01,-0.00,1.00,0.02] Mean marker error: 0.00 Tracking Valid: True Skeleton Count : 0 Labeled Marker Count : 4 ID : [MarkerID: 1] [ModelID: 20] pos : [0.72,0.50,-0.15] size: [0.01] err: [0.00] ID : [MarkerID: 2] [ModelID: 20] pos : [0.78,0.53,-0.14] size: [0.01] err: [0.00] ID : [MarkerID: 3] [ModelID: 20] pos : [0.74,0.62,-0.15] size: [0.01] err: [0.00] ID : [MarkerID: 4] [ModelID: 20] pos : [0.66,0.64,-0.15] size: [0.01] err: [0.00] Timestamp : 2377.417 Mid-exposure timestamp : 12335057189261 Camera data received timestamp : 12335057223494 Transmit timestamp : 12335057235053 End Packet
The data is thus available in the client and should be integrated into the intended application (by further source code editing).