TF-mini Lidar sensor does not work properly on pixhawk

It looks like with firmware version 16x they replaced mode 02, 07 by mode 00, 03, 07.

Sparkfun delivered a Tfmini with 160 firmware recently.
It works fine with an Arduino serial-i2c converter based on https://github.com/opensensinglab/tfmini . From what I have seen in this Arduino-lib they do no distance scaling according to the mode at all. Returns always cm.

In contrary AP_RangeFinder_Benewake.cpp scales distance by factor 0.1 in mode 2.
But mode 2 does not exist with firmware 16x devices anyway.

1 Like

@RainFly,

Thanks for looking into this. So I guess during the test the sonar was much more than the 9cm to 12cm shown in the log? ā€¦ and presumably we think the issue is that the mode is coming out of the sensor as ā€œ2ā€ and is being made 10x smaller than it should be? If true this is a bit of an issue because Iā€™d say this would be a ā€œbreaking changeā€ by benewake. In that itā€™s not backwards compatible.

I made a short bench test with a spare Tfmini (160 firmware) with a spare X2.1.

mRoX21 00570033 3236510B 36363331
ChibiOS: ff603d11
ArduCopter V3.6.2-rc3 (0e61bbe6)

Short and longrange measurement are correct!

Maybe mode 2 works as before. They just donā€™t use it any more with 16x firmware.

@rmackay9 ok will test tonight

Rainer, looking at opensensinglab link , it seems to be a serial-to-serial conversion , no I2C ( include <Wire.h) driver involvedā€¦?

@ppoirier
Right, this is just the lib to read TFmini device. I didnā€™t want to fight with the TFmini protocol in my sketch. I took one of the example Sketches and merged it, I think it was your Sketch, to run on a Arduino Pro Mini 8MHz 3,3V.
TFmini is connected via softserial Pin 10/11 @57600 baud. (8 MHz Pro Mini canā€™t handle 115200 baud softserial)

I donā€™t know, if it is the right place, but anyway ā€¦ here is the sketch Iā€™m currently using with an Omnibus F4 Nano.
TFMINI-I2C-RW.zip (2.0 KB)

Cool , you could upload on github and make a link on my blog as an ā€˜ā€˜alternative codeā€™ā€™ :slight_smile:

Patrick
After all this can you translate. As you know I am a TF Mini ownerā€¦but not sure what if anything I need to do to ensure I am successful in my use of it.

cheers

1 Like

Ricky, We are still testin the new driver. It might be workin ok now but I have not tested it yet. Iā€™ll let you know when fully ready :slight_smile:

1 Like

You da man.
thank you sirā€¦I am in no hurry. My machine is down with a gps issue so there is time, just thought i would ask.

1 Like

@rmackay9 here is the result , looking good ā€¦BUT I had to disable the short distance mode in order to make good readings.

Then I upgraded both TFMINI (from Version 1156 to latest: 2156) and according to @RainFly note:
ā€¦with firmware version 16x they replaced mode 02, 07 by mode 00, 03, 07.

I had to change line 125 to
if (linebuf[6] == 0x03 ) {
and it worked.

May I suggest that we just remove this distance compensation (lines 123-126) check ?

Hummm it seems it is still 02-07 mode

Hi Randy

RNGFND_ORIENT=25 is only work
Others donā€™t work, so i couldnā€™t test the obstacle avoidance

(TF-mini/Pixhawk/Copter 3.6.2rc3)

I also would suggest to comment out or remove the special mode 2 handling.
This is what you already did, if you changed 2 --> 3 and the device sends mode 2 measurements.
None of the Arduino libs I looked at have a special handling like this.
Also in the data sheet I canā€™t find any information, that tfmini sends different units for different modes. Just a global setting for mm and cm.

Maybe I find time tonight to check my tfmini with Realterm.

2 Likes

@SpaceGCT,

Txs for testing. So you found that the distances were reported accurately and reliably as far as you could tell? How about a distances below 1m? Also do you know if your lidar has firmware version 15 or 16? Sorry for the questions, thanks for the feedback in any case.

Re other orientations not working, I suspect itā€™s a setup issue with the Avoidance and/or Proximity parameters. If youā€™ve got a dataflash log I can have a look

1 Like

@ppoirier, @RainFly,

Thanks very much for all this detailed analysis. Itā€™s really helpful.

OK, Iā€™ll push out a 3.6.2-rc4 (hopefully tomorrow) that has the mode-2 scaling thing removed. Iā€™ve looked at the datasheets as well and Iā€™m not quite sure why we thought this was necessary.

1 Like

Hi Randy

TF-mini firmware 1156 -> 2156 upgrade.

but, same result.

I think that 1m over is reliable.

still have problems within 1m.

Only when RNGFND_ORIENT = 25, distance measurements can be seen on the mission planner.

Iā€™ve just tested without flying

Arming and spinning motors and moving distance measurements.

Here is the setting for object avoidance

and log.

2018ė…„ 11ģ›” 20ģ¼ (ķ™”) ģ˜¤ķ›„ 4:32, rmackay9 noreply@ardupilot.orgė‹˜ģ“ ģž‘ģ„±:

58 1980-01-01 ģ˜¤ģ „ 9-00-00.bin (656 KB)

58 1980-01-01 ģ˜¤ģ „ 9-00-00.bin.log (1.52 MB)

Iā€™ve put a patched version of 3.6.2-rc3 here which simply has the ā€œmode 2ā€ handling removed.

It really should perform just like @ppoirier found I thinkā€¦ if anyone would like to double check then that would be greatly appreciated. sincere apologies for the number of attempts this is taking.

Txs againā€¦

P.S. PR is here to put this change in master.

1 Like

Hello Randy,
Yes this mod works OK.
I will test the TF02 as well and report after a test flight with both sensor.
Thanks again for you availability and dedication (thanks to @OXINARF too) :wink:

2 Likes

Hi all
I have mounted the Benewake TF mini lidar in SERIAL4 / 5, I have the following configuration:

SERIAL4_PROTOCOL = 9 (Lidar)
SERIAL4_BAUD = 115 (115200 baud)
RNGFND_TYPE = 8 (LightWareSerial)
RNGFND_MIN_CM = 30
RNGFND_MAX_CM = 600
RNGFND_GNDCLEAR = 10

Iā€™ve been using it since the version copter 3.5.0
Recently I flew with the version copter 3.5.7, working very well

A few days ago I upgraded to the copter version 3.6.1. and testeand in mission planer seems to work well

I hope to contribute my little grain of sand

regards to all

2 Likes