Possible bug with optitrack on 4.5.0

Hello,

I am trying to configure my drone to work with optitrack but facing issues.

I have tried with Mavproxy both an Linux and on Windows and the output is the following:
On Linux

  • I get optitrack [Errno 11] Resource temporarily unavailable

On Windows

  • I don’t get any output on mavproxy but I am almost sure that its not working properly.

So far I am looking at the GPS status and I dont get GPS Fix. I have also checked XKF1 message but PE,PD, and PN are 0. Is this the correct way of checking or perhaps is there a way to directly check MAVLINK traffic for ATT_POS_MOCAP messages? Also I do not see any “EKF3 IMU0 is using external nav data” sort of message.

Up to this point I ve tried almost every possible combination and I am not sure how to further debug this. Is this something on my side or possibly a bug on Mavproxy/Firmware? Any recommentations are highly appreciated!

Let me know if you need more info from my side.

EDIT 1

Using Optitrack’s NatNet SDK OptiTrack - NatNet SDK - Stream motion tracking data across networks I am able to send data from the server to my pc (client). So this means that the architecture + Motive configuration are correctly set.

EDIT 2

This is one log 2 01-01-1980 01-00-00.bin - Google Drive.

1 Like

I’m having the same problem on Linux. Did you find a solution?

It turns out that the optitrack module can not be used as it is with Arduplane. The reason being, the EKF needs GPS to work properly in Arduplane. Arducopter does not require this. This module feeds postion with ATT_POS_MOCAP mavlink message.

Only way to make it work is build your own module using mavlink library (python version for easier use) and feed position as a fake GPS using the GPS_INPUT message. I tried but at the end couldn’t make the EKF use the GPS’s yaw. Long story short, I admitted defeat.

I’m trying to use the optitrack module with Arducopter. When I ran MavProxy on Windows everything worked fine but now I switched to Linux because I want to do everything on board with Nvidia Jetson Nano. I did everything the same on Linux but when I run the command “optitrack start” i get “optitrack [Errno 11] Resource temporarily unavailable”. Did you find a solution to this regardless of the Arduplane compatibility issue?

No. That’s was my first reason on switching to a custom solution. The error message is quite cryptic and unless you are willing to debug the code from the optitrack module I would say that the most straight forward solution would be to write your own module. Use ATT_POS_MOCAP messages and feed position data with pymavlink library. It ll save you time in the end.

How do you get the position data from Motive and feed it to ATT_POS_MOCAP in your module? I haven’t used the mavlink library before so I would appreicate it if you could share your code with me if you still have it.

Also, do you run your custom module from the Mavproxy terminal? If so, how do you do it? Or should I connect to the vehicle in the mavlink script and do everything there?

GitHub - tudelft/UnifiedOptitrackClients: Goal: one codebase to stream optitrack to all autopilots used in the MAVLab This is the repo where me and other researchers at TU Delft are developing a unified way to use optitrack from linux with all major autopilot systems.

Support for mavlink (so for Ardupilot) is the latest development so not documented yet.

Build with

mkdir build && cd build
cmake -D'CLIENTS=mavlink' .. && make

Run with (for example; need to check the arguments yourself)

./mocap2mavlink -s 123 -f 20

Tested in arducopter and works fine.

  • /clients directory has the “frontend” code where data is received from optitrack and mavlink messages are built and sent
  • The rest directories contain code for pose calculations and the “backend” code where the API provided by optitrack is used to utilize the communication stream.
1 Like

Thank you so much for sharing this! You saved me a ton of time. I’ll try this and let you know

I built by using the commands you shared but when I run ./mocap2mavlink -s 123 -f 20, I get:

‘Support for client "mocap2mavlink"was not compiled into the program.’

What am I missing here?

Hi, I fixed the problem with not compiling correctly. How can I send the optitrack data to the flight controller via USB connection instead of UDP? I want to stream the optitrack data to the companion computer on my drone and then send it to Pixhawk via USB connection. Does your Mavlink client work with serial connections too or just with UDP connection?

Hi good to hear you are progressing. Serial can be used with mavlink-router repo I think, which can redirect UDP traffic to serial.

I finally managed to get everything working by using my laptop as the host! Now I am facing another issue with running your code on Nvidia Jetson Orin Nano. When I try to build the environment with ‘make’ command, I get the following error:

/usr/bin/ld: _deps/natnet_sdk_content-src/lib/libNatNet.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/client.dir/build.make:132: client] Error 1
make[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/client.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

This probably happens because the architecture of libNatNet.so is x86-64 but my system is Aarch64. Do you have any idea how I can solve this problem?

Perhaps you are right but never tried it on that architecture so cant really help here.

We use PC as a host always. Maybe involve you laptop in the loop and reroute packets if you cant figure out how to overcome this. I am not even sure if optitrack provides library for that architecture. Have a look at their site.

What if i were to use the ROS2 client in your code? Do i still need NatNet SDK to build it?

Yes. NatNet SDK is the library provided by optitrack to get data from motive software as far as I understand.

Do you know which Mavros topic should I publish Optitrack location data to for Pixhawk to recognize it?

No, I dont use Mavros but should be some indo in there documentation. Lots of people use ros with ardupilot for that reason.