Using Mavlink for avoidance via companion computer

Good day all

Getting my feet wet with Mavlink.

I would like to add object avoidance to my drone and I have been reading a few
posts on this topic. Including this one:

My setup -
pixhawk 2.4.8
450 frame
Sensor TFMiniPlus ( lidar )
companion computer : Teensy 4.0

( I actually have two quads. This one is based on the pixhawk 2.4.8 and I am
starting with this one as this is my “try-it-first-drone”. But ultimately I want
to transfer it to my other quad based on the Pixhack V3x )

On the 2.4.8 I am running copter 3.55 and on the pixhack V3 I am runing 4.06.

I have coded the sensor-interface code and I can also receive the heartbeat messages from the 2.4.8.

Port 2 on Teensy : connected to drone ( Mavlink )
Port 3 on Teensy : connected to TFmini+

I have checked the contents of the message been sent to the drone and it seems correct. BUt my MP still says : Bad LiDAR health. Which to me means it is not receiving the messages I am sending.

Oh… my settings are

Now my question:
From what I have been reading , certain commands ( like Param request ) will result in a response.
Does the mavlink message MAVLINK DISTANCE MESSAGE also yield a response that I can look out for ? If so, then I can use the response or lack thereof, to judge if the FC is receiving my message ?

I couldn’t find a place where MP can show me the mavlink messages, hoping I can use that to see if the FC is receiving my message.

Many thanks

Ok, I have just found something !

On Missionplanner “FLight Data” screen , press CTR-F
additional window pops up
Click on “Mavlink Ins” towards the middle of the screen
and it shows the screen that I have attached.

There is shows my distance sensor I #158 and if I hold my hand
in front of the sensor then the reading changes.

So this proves that my sensor data is being received by the FC.

Still it doesn’t show on the “Proximity” RADAR ??

Here the screenshot of what I see

Does anyone have a hint?
THanks !

Looking good
Now you have to tell the firmware to use the MavLink message as a proximity signal

Many thanks !

Yes we’re slowly getting there.

Currently I have -
Single sensor via Teensy 4.0 reporting to Pixhawk 2.4.8 and showing up on prox-radar.

I then played around with various options , UART-I2C and for that I moved to Arduino Mega simply because I know it better than the Teensy.

The setup currently is - 3 TFMini+ sensors connected to Arduino Mega and successfully reading 3 sensors. Currently the Mavlink to drone FC is disabled. Sensors reporting data at 50 Hz ( 50 readings
per second ). Baud rate 115200.

I am now playing around with some calculations - sensor-rate and mavlink-stream-rate vs acceptable speed of the drone. If I get data from the sensors at 50Hz, then there will be a dead-distance for the drone of 27cm at 50km/h.

The big question in my mind - what would be the best stream-rate to the FC of the drone of the collected sensor-data? Surely I cant just increase the stream-rate to the FC at will ??

many thanks !!!

I think it’s specified with at least 10 hz

For most of these type of controllers the sweet spot is around 20 Hz.

Thanks all

I shall have 20Hz as a target then.
I think my strategy will be to keep my data-rate at 50Hz while disconnected from the FC while I port
the code to the Teensy 4.0. If the Teensy doesn’t fall over with all these sensors at 50Hz then 20 Hz is
going to be a breeze.

At least I have enough time at hand - since we are all in Covid-lockdown here !!!

Best !

Yep like half of the planet… I wonder what the other half i doing :wink:

1 Like