Servers by jDrones

How to make the TFMINI rangefinder talk I2C

(ppoirier) #169

Did you know that I made the Multi-Sector TFMINI detector using ATtiny ?

(chris rey) #170

:clap: yes, WITH and Arduino Pro Mini as controller as I can read in your blog…

(ppoirier) #171

The Arduino acts a a multiplexer for the I2C bus and sends the rangefinder distance and corresponding angle signals to the FC over serial MavLink.

(.) #172

Hi to all.

I have a question about the arduino code for translate the serial output to i2c.
At the state of the art i can only read the distance measured from the lidar.
If it’s setted as “proximity sensor”, the drone can reach at minimum the distance written in the code.

Is it possible to upgrade the arduino code in order to send the readed distance to a pixhawk and let the drone to maintain that distance?

Thanx to all.

(ppoirier) #173

This is basicslly what avoidance is doing. Take a look on ardupilot avoidance wiki to see how to setup rangefinder and parameters

(.) #174

i can set the rangefinder as:

  1. terrain following;
  2. object avoidance

Setted on 1, it means that the drone maintain the heigh (for ex. during translation).
Setted on 2, it means that the drone doesn’t go nearest than the distance setted.

In other words, with option 1) the drone follow the terrain trend (maintain a distance); with option 2) the drone doesn’t follow the wall trend (avoid a distance < than the one setted).

Am i wrong?
If it doesn’t, the question is: Is there a way to implement a code that let the drone to maintain the setted distance, when it is on “proximity sensor” ?

Thanx to all.

(ppoirier) #175

Yes , I have one of my quad with 2 TFMINI installed and I set I2C address 70 to altitude and address 71 to avoidance.

Have you look at avoidance library ?

(.) #176

I try to redo my question in a better way.

If i install a lidar as altitude holder (pointing on the ground), and i move in a transaltion motion, the drone follows the ground and maintain the altitude.

If i install a lidar as proximity sensor pointing on the wall), and i move in a traslational motion, the drone doesn’t follow the wall. It only avoid to reach at least a distance from the wall, but it can get away form the wall (direction not parallel with the wall, wind gusts, etc…).

The question is: Is it possible to maintain constant the distance from the wall, during a translation?

Thanx to all.

(ppoirier) #177

Altitude is ‘‘easy’’ to detect because the IMU has a fixed vector called Gravity.
In the case of a wall following, it is different matter, because this surface is not in a fixed plane so in this case, you could use a scanning Lidar that would allow this type pf avoidance.

I suggest you open a new discussion in the forum, because the question is not directly related to the subject and you would benefit from more input with a new discussion

(Siya Liu) #178

Hi, friends on Ardupilot. I’m rather regret that we Benewake team did not reply your questions for long time, cause we are facing network connection problems all the time, even now, we still can not login when we are in office, and finally I’m able to log in here with my PC at home.

If you need any assistance from Benewake, pls contact in case we did not reply in time. Thank you : )

(Alfonso) #179

I only write here to thank everyone and especially to ppoirier the work done. Of course to thank also the whole community that makes Rover easier. I have only been with Pixhawk + Rover for a few months and it has been relatively easy for me to connect my TFMini to Pixhawk 1 through the I2C port and verify that it distanced from the wall in front of it.
PD1 .: To correctly configure the TFMini and from its WINCC TF V1.1.2 application, I had to enter the start cmd, wait for sampling to pass to 0, standard output cmd, output cmd to mm, and finally abandon cmd.
PD2 .: In Arduino sketch BeneWake_TFMINI_I2C_ProMini_Maxbotic_Fast_Blink I had to modify “uint8_t Scaling = 13;” because it means more than what the tape measure showed.
The next step is to put another TFMini in the back of the Rover.

(Luis Miguel González Fernández) #180

Hi everybody.
Just one question.
¿ This I2C aproach will work with standard arducopter 3.5.7 directly out of the box on my pixhawk 2.1 or a driver mod is needed ?

Thanks in advance.

(ppoirier) #181

Yes it is because it emulates a standard I2C device

(Luis Miguel González Fernández) #182

Thanks again. i will give it a try maybe tomorrow.

(Luis Miguel González Fernández) #183

Hi again.
Work in progress. I’ll upload some photos showing final product :smile::smile:.
Do you think that a UBEC rated for 5v 1Amp will be enough in order to power TFMINI + Arduino Pro Mini + Red Led ?

Thanks in advance.


(ppoirier) #184


Yes no problem, the TFMINI Average current is 120 mA

(Luis Miguel González Fernández) #185


Almost done.

I’ve made a minor modification to the arduino sketch in order to only toggle LED state every 5 samples read from the TFMini. Without this, LED keeps always on.

(Nathan E) #186

Hello @ppoirier,

Could you please give a recommendation for the min and max signal strength thresholds that you use and if you use a range limit? I seem to be having trouble with false intermediate-distance noise readings on arduplane causing incorrect ground distance readings momentarily.

I am able to send commands, but I’m not entirely sure what the best settings are. I’m also a bit confused about what to enter with the commands based on the user manual. EE and FF thresholds aren’t the most clear to me.

As of now, I am entering the following:
42 57 02 00 00 00 01 02 (Enter configuration mode)
42 57 02 00 00 00 04 06 (Pixhawk format)
42 57 02 00 00 00 07 11 (Long distance mode)
42 57 02 00 50 50 01 19 (Range limit enabled, threshold 50??)
42 57 02 00 50 00 00 20 (Lower limit of threshold 50??)
42 57 02 00 20 00 00 21 (Maximum signal strength threshold 200??, 0cm sent when max)
42 57 02 00 00 00 00 02 (Exit configuration)

Is this correct?

Ideally, I only need a very reliable reading between 0-6m. Right now even at 5m, I’m getting random noise down to 1.5m, etc. I am connected to a serial port, but my understanding is that the data should be the same.

(ppoirier) #187

It really depends on the use case; but basically what is the surface are you flying over ?
Did you check the signal with the Benewake GUI to confirm you have these glitches on the same surface ?
On the same interface you can see as well the signal strength, that may help setting values, but generally it works as factory default.
Most of my tests are done using a quadcopter tat low velocity (5-10 M/s) over grass and I can fly up to 6 Meter no problem.

(Nathan E) #188

Grass and 2m tall corn. I can’t seem to repeat the behavior on the ground with the GUI. I’m flying at 10-15 m/s