Optitrack on Raspberry Pi

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Raspberry setup)
(Raspberry setup)
Line 38: Line 38:
 
On the Raspberry Pi set the wireless network to access the dedicated Optitrack network
 
On the Raspberry Pi set the wireless network to access the dedicated Optitrack network
  
Modify the  
+
Modify the '''/etc/wpa_supplicant/wpa_supplicant.conf''' by adding the network groups, maybe the 5Ghz SSID should have the highest priority.
/etc/wpa_supplicant/wpa_supplicant.conf  
+
by adding the network groups, maybe the 5Ghz SSID should have the highest priority.
+
  
 
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
Line 59: Line 57:
 
  }
 
  }
  
Restart the network by reboot or just restart the network
+
Restart the network by reboot or just restart the network:
  
 
  sudo /etc/init.d/networking restart
 
  sudo /etc/init.d/networking restart

Revision as of 07:58, 13 May 2021

Using Optitrack and thin NatNet client

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

Get client from https://github.com/b4be1/packet-client-linux e.g. from 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)

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, maybe the 5Ghz SSID should have the highest priority.

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

In 'View' and 'Data streaming pane' select local interface to the IP address of the server and deselect other streaming services (VRPN and Trackd)

Then go live, and assuming there is rigid bodys, 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};

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, like

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 in the intended application (by further source code editing).

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox