Skip to content

AP_RangeFinder: add DTS6012M driver support#32188

Merged
peterbarker merged 4 commits intoArduPilot:masterfrom
FractalEngineer:DTS6012M
Feb 27, 2026
Merged

AP_RangeFinder: add DTS6012M driver support#32188
peterbarker merged 4 commits intoArduPilot:masterfrom
FractalEngineer:DTS6012M

Conversation

@FractalEngineer
Copy link
Copy Markdown
Contributor

@FractalEngineer FractalEngineer commented Feb 13, 2026

This PR adds UART support for this cute 1.35g, 20m rangefinder.

Spec sheet (english)

Datasheet (chinese)

Configuration:

Software
SERIALn_PROTOCOL = 9 (rangefinder)
SERIALn_BAUD = 921 (set by driver)
RNGFND1_TYPE = 47 (current latest is 46)
RNGFND1_MIN = 0.2
RNGFND1_MAX = 20

Hardware
Pull Pin 5 down for UART mode

Tested on copter micoairH743v2, returns accurate distance in configurator.

@Hwurzburg
Copy link
Copy Markdown
Contributor

Hwurzburg commented Feb 13, 2026

do not use merge commits...rebase (not normally needed unless failing CI for something this PR changes)...must pass CI

Has this been tested on a plane as a downward facing RF over grass?it would be interesting to check its range in that environment as a landing assist RF.... if you would like that tested, I would be happy to test

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Feb 13, 2026
@FractalEngineer FractalEngineer force-pushed the DTS6012M branch 2 times, most recently from 64357df to a0bb954 Compare February 13, 2026 14:19
@FractalEngineer
Copy link
Copy Markdown
Contributor Author

do not use merge commits...rebase (not normally needed unless failing CI for something this PR changes)...must pass CI

Has this been tested on a plane as a downward facing RF over grass?it would be interesting to check its range in that environment as a landing assist RF.... if you would like that tested, I would be happy to test

Understood and done thank you; first PR on this repo

I have not yet tested it in flight; it was definitely going into some of my wings for autoland, but needed the driver support to start; thought I might as well PR it for the code review first in case I might have something horribly wrong in there 😄

@FractalEngineer
Copy link
Copy Markdown
Contributor Author

Looking at precedent RF PR I went ahead with the sim autotest already

Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs adding to ./Tools/scripts/build_options.py so it appears at https://custom.ardupilot.org

Looking good.

Comment thread libraries/AP_RangeFinder/AP_RangeFinder_config.h Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.h Outdated
Comment thread libraries/SITL/SIM_RF_DTS6012M.cpp Outdated
Comment thread libraries/SITL/SIM_RF_DTS6012M.cpp Outdated
Comment thread libraries/SITL/SIM_RF_DTS6012M.h
@FractalEngineer FractalEngineer force-pushed the DTS6012M branch 2 times, most recently from 3adfe3f to 507de09 Compare February 14, 2026 11:57
@FractalEngineer
Copy link
Copy Markdown
Contributor Author

Thanks @peterbarker all CR implemented, also here's a hardware demo

https://youtube.com/shorts/7XKdobkM1h8

@NDevDrone
Copy link
Copy Markdown
Member

NDevDrone commented Feb 25, 2026

@FractalEngineer Nice demo! I'll try to get this guy over here too, it seems like he'd be happy to check out your work :) https://github.com/PlaneStuffRC/DTS6012M_to_TFmini

Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fix the return value checking and the bad zeroing-of-memory and we're good.

Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.h Outdated
Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.h
Comment thread libraries/SITL/SIM_RF_DTS6012M.cpp Outdated
Comment thread libraries/SITL/SIM_RF_DTS6012M.h Outdated
@FractalEngineer
Copy link
Copy Markdown
Contributor Author

Alright all changes implemented, autotest passed, still running fine on hardware.

Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Tested locally with valgrind, all good

Comment thread libraries/AP_RangeFinder/AP_RangeFinder_DTS6012M.cpp
*/
void AP_RangeFinder_DTS6012M::send_start_command()
{
static const uint8_t cmd[] = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const uint8_t cmd[] = {
static const uint8_t cmd[] {

@peterbarker peterbarker merged commit be90f61 into ArduPilot:master Feb 27, 2026
107 checks passed
@peterbarker
Copy link
Copy Markdown
Contributor

Merged, thanks!

@FractalEngineer FractalEngineer deleted the DTS6012M branch March 1, 2026 15:43
@rmackay9
Copy link
Copy Markdown
Contributor

rmackay9 commented Mar 3, 2026

This looks suspiciously similar to the Benewake TF20-L. I wonder if it uses the same protocol

@FractalEngineer could you check this?

We already have a lot of rangefinder drivers so we definitely don't need duplicates!

@FractalEngineer
Copy link
Copy Markdown
Contributor Author

FractalEngineer commented Mar 3, 2026

This looks suspiciously similar to the Benewake TF20-L. I wonder if it uses the same protocol

@FractalEngineer could you check this?

We already have a lot of rangefinder drivers so we definitely don't need duplicates!

man wouldn't I have wished it did that would have saved me the trouble lol

But not in my understanding; other than the choice of going serial vs i2c (for which they seem to have mismatched addresses anyway, 0x51 vs 0x10) the register layout appears fundamentally incompatible

image image

Also mismatched units; mm vs cm

Bunch of tiny unfortunate discrepancies; could almost pass as intentional eh

@rmackay9
Copy link
Copy Markdown
Contributor

rmackay9 commented Mar 3, 2026

Hi @FractalEngineer,

sorry, I pointed you at the wrong driver. Our serial driver for the TFS20-L is here.

PeterB and I looked into after my comment above and we think that the protocol is actually different. From my point of view, it must be the same hardware, it can't be a coincidence but I guess the software is different for whatever reason.

@FractalEngineer
Copy link
Copy Markdown
Contributor Author

Ok I just looked up the TFS20 hardware and I'm very aggravated now.

Seems like identical hardware indeed, all the way down to the PCB marking (DT011B v2). Most upsetting.

But yea looks like a couple software discrepancies;

  • Benny looks for a pair of 0x59 bytes to start frame whereas DTS heads with 0xA5
  • DTS needs a 0x01 start command to even initialize whereas Benny starts streaming on powerup
  • And the checksums are completely different.

The mind boggles as to why did it have to be that way. Ohwell.

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

Labels

WikiNeeded needs wiki update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants