Scanning rangefinder

testing with 2 rangefinders looks promising.

1 Like

@ppoirier I was thinking, what if we used your old POC sketch but simplified it, essentially plug 4 VL53L0 rangefinders along with an Arduino running a limited version of poc into the pixhawk i2c splitter then use the Arduino to change the i2c address of the sensors before ardupilot starts up? would they all be detected work natively?

#include <Wire.h>
#include <VL53L0X.h>

//#define XSHUT_pin6 A7  //not required for address change
//#define XSHUT_pin5 A6
#define XSHUT_pin4 A3
#define XSHUT_pin3 A2
#define XSHUT_pin2 A1
#define XSHUT_pin1 A0

//ADDRESS_DEFAULT 0b0101001 or 41
//#define Sensor1_newAddress 41 not required address change
#define Sensor2_newAddress 42
#define Sensor3_newAddress 43
#define Sensor4_newAddress 44
#define Sensor5_newAddress 45
#define Sensor6_newAddress 46

VL53L0X Sensor1;
VL53L0X Sensor2;
VL53L0X Sensor3;
VL53L0X Sensor4;
//VL53L0X Sensor5;
//VL53L0X Sensor6;

void setup()
{ /*WARNING*/
  //Shutdown pins of VL53L0X ACTIVE-LOW-ONLY NO TOLERANT TO 5V will fry them
  pinMode(XSHUT_pin1, OUTPUT);
  pinMode(XSHUT_pin2, OUTPUT);
  pinMode(XSHUT_pin3, OUTPUT);
  pinMode(XSHUT_pin4, OUTPUT);
//  pinMode(XSHUT_pin5, OUTPUT);
//  pinMode(XSHUT_pin6, OUTPUT);
  
  Serial.begin(115200);
  
  Wire.begin();
  //Change address of sensor and power up next one
 // Sensor6.setAddress(Sensor6_newAddress);//For power-up procedure t-boot max 1.2ms "Datasheet: 2.9 Power sequence"
 
 // pinMode(XSHUT_pin5, INPUT);
 // delay(10); 
 // Sensor5.setAddress(Sensor5_newAddress);
 
  pinMode(XSHUT_pin4, INPUT);
  delay(10);
  Sensor4.setAddress(Sensor4_newAddress);

  pinMode(XSHUT_pin3, INPUT);
  delay(10);
  Sensor3.setAddress(Sensor3_newAddress);
  
  pinMode(XSHUT_pin2, INPUT);
  delay(10);
  Sensor2.setAddress(Sensor2_newAddress);
  
  pinMode(XSHUT_pin1, INPUT);
  delay(10);
  //ADDRESS_DEFAULT 0b0101001 or 41
  

}

void loop()
{

    
}

It should work… unless the Arduino interfere with FC but probably not

If you have spares PWM out you could uses them as GPIO to set the address thus eliminating the Arduino

1 Like

not enough gpio for them all, there is something coming soon that will help.

Would this sketch work on the VL53L1? by changing VL53L0X.h for VL53L1X.h ?

I have ordered 8 VL53L0X for testing to see if its possible to change the address before startup.

I think the adress charge works the same
There’s one way to know,==test

1 Like

I have some VL53L1X ordered too lol.
I have tested 4 ultrasonic sensors and a radar this week and im waiting for VL53L1X VL53L0X, TFmini plus and A02YYUW ultrasonic sensor. im working my way through the driver library lol

1 Like

I have just added support for adding new rangefinder drivers purely using lua script: https://github.com/ArduPilot/ardupilot/pull/20015

@geofrancis might help you with your projects once this is merged

1 Like

@rishabsingh3003 I dont think that is quite what im looking for, I believe I need a lua proximity sensor rather than a lua rangefinder, as im essentially making a proximity sensor from a moving rangefinder.

what would be ideal is way to make a proximity sensor with more than 8 directions. The plan will be eventially to use @ppoirier idea of using the ADC to feedback position from the servo to better track its movement.

@geofrancis ah I posted on the wrong thread. I vaguely remember reading something from you where you wanted support for more rangefinders and wanted to write the drivers for them? This might help you out in that. This PR can also be used as a template to get proximity-based lua driver

2 Likes

yes that was something I was discussing before and now I have had some time to understand your pull I can see how it can be useful. It can be used to make drivers for rangefinders using just lua as a driver meaning adding a driver is just adding a script.

I had a discussion about this with @Yuri_Rage before, about how a lot of device drivers would be much better as lua drivers as they are very simple devices and very niche with few people using them so is it really a good idea using up space for a device that very few people will ever see.

winch, generator, sprayers, lawnmowers, these are all simple devices that could be run with some lua as its just simple GPIO, there is no complex math or timing requirements on these devices. im hoping to start replicating opensource versions when the i2c lua gpio port expander board becomes a reality.

2 Likes

@rishabsingh3003 I’ve got a couple of FMK24-E radars coming my way. Would be very happy to be able to integrate them via LUA rather than necessarily having to write a driver. Either way I’m sure we’ll get something working between myself, @Yuri_Rage and @geofrancis. If a few of us lead the way and agree on a sensor that many others may wish to use then a driver is worth doing.

1 Like

@rishabsingh3003, I took delivery of the FMK24-E5200 radar from @geofrancis yesterday and already have it working via your new Lua bindings on a Matek H743-Wing v2 (cloned your repo and switched to the lua_rangefinder branch).

Curiously, the rangefinder only seems to keep the last reported target as a persistent obstacle in the database. Since the 5200-series reports obstacles from nearest to distant, that means the farthest obstacle is the one that remains.

I found a workaround for that. I haven’t seen more than 5 target returns in a single message yet, so I just made 5 Lua rangefinder devices (RNGFND1-RNGFND5_TYPE=35). I index the returns in each message accordingly and ignore any beyond the fifth. It works!

image

Sample script attached (must be run on custom built firmware at present, using this branch).

FMK24-E5200.lua (2.7 KB)

2 Likes

very cool!, we just need it on a servo on we are there!

1 Like

With a 78°FOV, you might find yourself surrounded by obstacles :rofl:

2 Likes

it simplifies things a bit, with such a wide field of view it will only have to point in 4 directions to get 360 degrees.

My other idea was to rotate the radar 90 degrees, its vertical fov is only 23 degrees but im not sure how it would react to that.

1 Like

I have done some checking and the 30M version of that radar I am getting has a 26 degree vertical and horizontal FOV. so it should work ok.

1 Like

@ppoirier I didn’t realize someone was already working on addressing the Vl53l1x in autopilot automatically

Yes I remember , that was a very nice little sensor assembly

I don’t think its been developed much further, its a shame it’s not been added.

Still waiting on 2 x FMK24-E radars….with any luck by the time they arrive @Yuri_Rage will have a whole library of drivers ready to go :crossed_fingers::crossed_fingers::grin:

1 Like