Benewake TFmini LIDAR works on Ardupilot

Hi @lucasdemarchi, great work!
I have no Plus to test, but I tried to get work the TFMini i2c (no plus) version, but for some reason with no luck.
The Plus version seems having different protocol, unfortunately.

What is the reason here to do two transfer() calls instead of single call?

void AP_RangeFinder_Benewake_TFMiniPlus::timer()
{ …
ret = _dev->transfer(CMD_READ_MEASUREMENT, sizeof(CMD_READ_MEASUREMENT), nullptr, 0);
if (!ret || !_dev->transfer(nullptr, 0, (uint8_t *)&u, sizeof(u))) {
return;
}

Good evening lucasdemarchi.

This is very interesting. Is this for collision avoidance (multiple TFMini plus) or altitude control?

Cheers.

Henri

Yes, with I2C you can use multiple devices for avoidance and altitude range

@Sergey_Zakhodylo TFmini has another protocol and the sensor that supports uart doesn’t support I2C. You need a TFmini Plus for it to work.

2 transfer calls because the sensor is not an usual I2C sensor with a regmap. Maybe it works with transfer only, but it’s not what is documented

@henrik04 can be used for either or both.

I mean your two lines are equivalent to
_dev->transfer(CMD_READ_MEASUREMENT, sizeof(CMD_READ_MEASUREMENT), (uint8_t *)&u, sizeof(u));

Either the single-line version doesn’t work for some reason or I missed something

if you do a combined r/w you will have only one stop at the end of the transaction in the I2C protocol.

we actually have support for “split-transfer”, but that just moves the double transfer to the lower layer (see the HAL implementation for I2CDevice):

    if (_split_transfers && send_len > 0 && recv_len > 0) {
        return transfer(send, send_len, nullptr, 0) &&
            transfer(nullptr, 0, recv, recv_len);
    }

What I may test is if the sensor support the repeated start… It’s not documented as supporting though.

You’re right, just checked TFMini Plus docs. There is a 100ms delay also required between W-stop and R-start.
The i2c protocol between not-plus and plus version is very different. Not-plus instead requires for a restart condition after command sent. Looks like FW for plus and not-plus was developed by different teams))

@lucasdemarchi @ppoirier

So as ppoirier described it in another thread: 3 TFmini at the front, one for above in relation to collision avoidance.

Now the bottom one: Can the same unit be used for precision altitude landing and collision avoidance or not?

In regard to the back of a multi rotor: Are three units at the back needed too?

This would make 8 or 9 units for complete collision avoidance!

Would a LeddarVu at the front one at the back and two TFmini for top and bottom would make sense?

(See attached pdf for LeddarVu)

Cheers

Henri

LeddarVu.pdf (1.47 MB)
LeddarVu

@henrik04, you can use whatever configuration you like as long as you provide proper supply and devices adressing. We have only the LeddarTech Leddar One driver for the moment, Rangefinders (landing page) — Copter documentation.

Have you looked at my blog ?

I certainly did! Thank you for answering.
Cheers

Henri

@lucasdemarchi what FC you used for testing the Plus driver?

This is a great idea !

Much easier to replicate now with the I2C sensors you can connect directly to the FC

Hey!
Wonderful work! Any estimate as to when this will be available in a stable release?

@sergbokh I used a Emlid Edge, but should work fine with any other FC we support in ardupilot.

@danielh after merging on master branch I will take a look on backporting it - when a stable release will be done I do not know, and it depends on the vehicle you want.

Thanks,
ordered one Plus to see if it will work with Pixracer.

I am interested in ArduCopter.

@ppoirier : Is this the unit you are referring to: Tfmini US$ 39.95 ?

How one change the I2C address of these (If you know)?

Thank you in advance.
Henri