Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver for VL53L1x #16055

Merged
merged 1 commit into from
Oct 27, 2020
Merged

Driver for VL53L1x #16055

merged 1 commit into from
Oct 27, 2020

Conversation

shizacat
Copy link
Contributor

Driver for distance sensor: vl53l1x
The second attempt
Single commit from #15565

@dagar
Copy link
Member

dagar commented Oct 27, 2020

Given the relatively huge number of registers and the poorly documented nature of this device did you consider leaving the ST ultra lite driver mostly intact and writing a simple wrapper to make it use PX4 I2C within a typical module?

@shizacat
Copy link
Contributor Author

I decided this will be not comfortably and excessively for code. The most functions repeat standard functional any I2C device (read, write). All settings registry stored in VL51L1X_DEFAULT_CONFIGURATION and they don't have need to change them.

I actually followed the guide UM2510:

6 Reducing the driver size to its absolute minimum

Although ST have attempted to create a small driver, it might not be small enough for some applications. To
create the smallest possible driver, try the following approach:
• Use the current driver and configure the parameters as required. Start ranging (to show that it works).
• When satisfied that ranging works, dump the contents of the sensor from the location 0x2D through to 0x87.
• Replace the default register settings in the the array VL51L1X_DEFAULT_CONFIGURATION[] which is located in the file VL53L1X_api.c.
• This makes your settings the default settings
• Your main routine then needs only to call the the VL53L1X_SensorInit() function and VL53L1X_StartRanging().
• Most other functions can then be removed

@dagar
Copy link
Member

dagar commented Oct 27, 2020

I decided this will be not comfortably and excessively for code. The most functions repeat standard functional any I2C device (read, write). All settings registry stored in VL51L1X_DEFAULT_CONFIGURATION and they don't have need to change them.

It's not too much code, and I'm not worried about the I2C functions. What I don't particularly like is all the registers and bits that as far as I can tell are undocumented. Anyway, my gripe is with ST and this device, thanks for your effort.

Can you comment on testing and share a test log if you have one (https://logs.px4.io/)? I'm happy to merge this if it's otherwise working.

@shizacat
Copy link
Contributor Author

EKF2_HGT_MODE - set to use range sensor. And I look at the plot 'distance sensor'. May be have errors in setup, or need check some thing, tell me.
https://logs.px4.io/plot_app?log=2b4681da-9c1d-49ac-8d74-1614d0cd5889

@dagar
Copy link
Member

dagar commented Oct 27, 2020

EKF2_HGT_MODE - set to use range sensor. And I look at the plot 'distance sensor'. May be have errors in setup, or need check some thing, tell me.
https://logs.px4.io/plot_app?log=2b4681da-9c1d-49ac-8d74-1614d0cd5889

It appears to be working, although clearly not as well as other common range finders. Perhaps not bad for a $4 sensor...

For your setup I would suggest using range aid (EKF2_RNG_AID) rather than EKF2_HGT_MODE and then make sure you tune the noise and gate appropriately for this sensor.

Thanks @shizacat

@dagar dagar merged commit 2e98c64 into PX4:master Oct 27, 2020
@dagar
Copy link
Member

dagar commented Oct 27, 2020

@shizacat FYI your git commit is missing your email address.

@dagar
Copy link
Member

dagar commented Oct 27, 2020

Note, for regular users to actually make use of this we'll need to add a parameter to actually start it (eg SENS_EN_VL53L1X).

@orkunasa
Copy link
Contributor

orkunasa commented Dec 7, 2020

#16346 @dagar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants