Integration of ArduPilot and VIO tracking camera (Part 4): non-ROS bridge to MAVLink in Python

PZ is negative due to how the coordinate frame is defined (NED-north east down, so positive z is pointing down). After the crash, the tracking data from the T265 was not reliable anymore (the position rapidly increased despite the actual movement, and the tracking confidence became FAIL), hence if the controller used that wrong data the behavior would be erratic.

This is one area of improvement that will come in future developments on the ArduPilot side (disregards bad data from the camera, uses the right kind of data when needed etc.). At the moment though, just keep in mind that the camera has limitations and always be ready to retake control during flight.

hi, I was able to get out and do some more testing on the weekend. Still had the same problems I’ve been having with the quad copter loosing track. It seems I may be an issue with my flight controller as is switches IMU just before I get the error. I’ve attached a video of the flight and the log files I have collected. Any advice would be welcome.

Regards
Paul


Hello
As @LuckyBird wrote in the method, once the HOME position set, did you “walked” the vehicle in Loiter mode (like a square or figure 8) to check system before arming?

Then you can takeoff in loiter and do simple manoeuvre before going more challenging.

I think the T265 is getting lost by lack of visual references in the near surroundings as it is green grass. Don’t trust the confidence level for this as it will send HIGH even if it has skipped tracking many meters. Thanks for testing :smile:

Hi @lipp8888, it seems the error is related to yaw. Were you flying with compass enabled? Could you try again without it?

HI, I have tried to disable my compass in the past with the same results. I also get large EKF errors and a compass fail warning (very annoying). I found if I enable one compass I get the most stable EKF.

It might be a while before i can do any more testing but I’ll make sure I get some logs for flying with the compass disabled. I’ll also try enabling LOG_REPLAY and see if I can get some more details about the failure.

Out of interest can you tell me what setting you are using for EK2_IMU_MASK,? mine is currently set to 3 so it is using both IMUs. I was thinking of trying to use just one IMU.

Regards
Paul

Hey Thien,

I have complete the ROS part, and I want to autonomous flights , like this .
But I found this tutorial is use ROS, if I want to use this (in this page) , how should I do?

Any help would be much appreciated!

thanks!

hello,im using raspy 3B+ and Px4 2.1 with fimware 4.0 ver
when im running t265_to_mavlink.py i get error message wrong elfclass:ELFCLASS64
im downloading the same pyrealsense2.so and librealsense same as the tutorial and place it in the usr/local/lib and librealsense/build but still getting error wrong elfclass
please tell me whats wrong.
thanks and wish to hear the answer soon

I have not encountered this error before, but a quick search seems to indicate that this might be an architecture error (examples 1, 2). I suggest posting the error on the RPi forum to get better help for this issue. Otherwise, reinstalling OS might be of help.

@rajas How did you fix the HIGH_GPS_HDOP prearm? I’m facing the same warning…

Are you running T265 based system?

Yes, the setup is the same as described in the page: T265 + RPI3b connected to the FCU. I’m using Arducopter v4.0.7 running on a Pixhawk4. I have set the parameters as described in the wiki (EK2_GPS_TYPE = 3, GPS_TYPE = 0) to avoid gps usage. The GPS hardware is connected to the FCU as in pixhawk 4 this module includes the safety switch to arm the quadcopter.

You should use EKF3 for this configuration and disable GPS as well with EK3_GPS_TYPE=3

The matrices (1) and (3) are H_aeroRef_T265Ref and H_T265body_aeroBody , respectively, and are defined in the earlier part of the code . You can figure out the meaning of their names in a similar way to (2) . Their values depend on the initial orientation of the camera and do not change throughout the operation.

Is that true order about variable name (1) H_aeroRef_T265Ref, (3) H_T265body_aeroBody? or vice versa

What the effect if we are not sending vision_speed_estimate to FCU or vice versa ?

Hello, I’m stuck when running the code t265_to_mavlink.py. I’m using an intel NUC and it is already running Mavlink router, which means that I can connect to it with MP in the GCS. Once I run the aforementioned python script it gives me the following error: serialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
I tried to stop Mavlink router and the error doesn’t arise anymore: the problem now is that I can’t anymore connect to the drone with MP, it says “connection failed”.
Do you have any idea?

Looks like a USB ressource conflict… How do you connect Mavlink ?

My px4 mini 3dr is connected through micro usb to the USB 3.0 of the intel NUC
Then to activate it I run the following command: sudo systemctl start mavlink-router

And when you start the router the camera get the error?

What about realsense viewer , is it crashing too?

realsense viewer start without any problem and it works even with MavlinkRouter running.
The problem arises when both the MavlinkRouter and the script t265_to_mavlink.py run together. I get the following error:

~/Documents/vision_to_mavros/scripts$ python3 t265_to_mavlink.py --connect /dev/ttyACM0 --baudrate 57600
INFO: Using connection_string /dev/ttyACM0
INFO: Using connection_baudrate 57600.0
INFO: Using default vision_position_estimate_msg_hz 30.0
INFO: Using default vision_position_delta_msg_hz 30.0
INFO: Using default vision_speed_estimate_msg_hz 30.0
INFO: Using camera position offset: Disabled
INFO: Using compass: Disabled
INFO: Using default scale factor 1.0
INFO: Using default camera orientation 0
INFO: Starting Vehicle communications
INFO: Connecting to camera...
INFO: Camera connected.
INFO: Sending vision messages to FCU
INFO: Tracking confidence: Medium
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "t265_to_mavlink.py", line 264, in mavlink_loop
    m = conn.recv_match(type=interesting_messages, timeout=1, blocking=True)
  File "/home/wines-nuc10/.local/lib/python3.8/site-packages/pymavlink/mavutil.py", line 457, in recv_match
    m = self.recv_msg()
  File "/home/wines-nuc10/.local/lib/python3.8/site-packages/pymavlink/mavutil.py", line 420, in recv_msg
    s = self.recv(n)
  File "/home/wines-nuc10/.local/lib/python3.8/site-packages/pymavlink/mavutil.py", line 965, in recv
    ret = self.port.read(n)
  File "/home/wines-nuc10/.local/lib/python3.8/site-packages/serial/serialposix.py", line 595, in read
    raise SerialException(
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
^CClosing the script...
INFO: Realsense pipeline and vehicle object closed.

If I don’t execute MavlinkRouter there is no error but I’m not able to connect MP to the drone, and so I’m not able to view the VISION_POSITION_ESTIMATE data in the MAVlink inspector. It seems that both the python script and mavlink router want to use the same USB resource.

To recap: I’m trying to connect to the NUC to MP in my GCS (in my Windows PC) using TCP or UDP connection through the WIFI (looking the guide of this project I suppose you did the same). Is my setup correct (MavlinkRouter + t265_to_mavlink.py)? or do you use something else to connect the RPi (in my case the intel NUC) to MP in the GCS?

Ahhh OK, you are not using the t265_test_streams.py as you show at the beginning

This is quite normal that you are conficting with the t265_to_mavlink.py as it tries to initiate Mavlink from the script == You obviously have to disable one of them :wink: