-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Pr tfminiplus and command support #13831
base: main
Are you sure you want to change the base?
Conversation
I can arrange tfmini testing. |
Instead of passing through raw commands did you consider making them a bit higher level? For example requesting the version, configuring the frame rate, etc. |
Tks @dagar for all your comments. I have pushed 4 commits to answer your reports.
I had the feeling that I should try to minimize the amount of code written, to avoid increasing the final binary size. If a higher level code is provided, it would means translating around 10 commands per devices, same amount of answers, plus the variant of each commands (on/off, or frequency, etc..) If you feel this is required (at least for interesting commands), it may be better to bring this in a separate pull request? |
Thanks, there's still a bit too much inconsistency at the moment. Nearly all the printfs should be removed.
Certainly not required, I was mainly trying to gauge if there's a subset of commands worth implementing directly to actually make the functionality accessible. |
The PR checks out well with a pixhawk 4 and tfmini plus. I'll make a few comments in the code but it looks to be in good shape from my perspective! Nice work! |
Configure TFMINI-Plus Frame Rate: (0x5A 0x06 0x03 0xLL 0xHH 0xSU) - Example for 100Hz | ||
$ tfmini command -c 5A06036400C7 | ||
Apply and Save Settings for TFMINI-Plus: (0x5A 0x04 0x11 0x6F) | ||
$ tfmini command -c 5A04116F |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are a limited number of commands available, it might be easier for the user to abstract the hex values here by giving them variables/names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are a limited number of commands available, it might be easier for the user to abstract the hex values here by giving them variables/names.
The commands are not limited to any subset. They will be validated for TFmini and TFmini-plus (header and lenght only) and will be rejected if model is not defined.
I will take into account your comments and will push more changes.
Thanks a lot @mcsauder !
I have commited autosetup for TFmini model. As I said, I don't have the device, so this is very blind code... In order to verify, you need at least to run the command "tfmini status" under nsh with a TFmini model being connected and with SENS_EN_TFMINI being set to 1. This should display, among other lines: If anything went wrong, please let me know! |
Hi @amoizard , It looks like things are functioning properly. One detail we could attend to, it appears the driver is returning |
@mcsauder / thanks for testing, but it's not working... From your snapshot above, the "autosetup" for TFmini doesn't work. It is written "TFmini is being configured" instead of "TFmini is configured". The "state" is still the first one, which means even the first "command" (enter setup) was not accepted. I advise you to try this command first:
The result must be: (20ms can be different)
I'm sorry I can't debug this myself. I have looked for a typo or some obvious mistake, but couldn't locate the issue. |
FYI, when this goes in, we should update this page: http://docs.px4.io/master/en/sensor/tfmini.html |
I have finally purchased a TFMINI in order to test myself. As you can see in the snapshot, the "tfmini status" is showing the expected line saying:
Also, setup via the command line also works. The use-case below is showing the sequence:
|
It seems the build failure was related to a timeout which is not related to my patch... Any way to restart the checks? |
3fd7a6d
to
9789465
Compare
@amoizard , try merging upstream/rebasing and see if we get the same CI failure again. |
012e55b
to
957484f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I'd like to follow up with another PR after this one goes it to do a bit of refactoring and move some of the new method calls out of collect()
into init()
, but this is a good first step.
Nice work @amoizard !
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
Would you mind rebasing and re-testing this? My apologies that this wasn't followed up on. |
I'm sorry: I'm not any more involved on the project and I don't have my px4 any more. I do hope @mcsauder will be able to replace me on this patch? |
Sure thing. I'll take care of it! Thanks for your work! |
957484f
to
926b2ce
Compare
Don't merge this yet, I still need to complete functional testing to make sure nothing has become broken in the time since this PR was submitted... I was actually shocked that the CI tests all passed. :) |
e53240a
to
4e0497e
Compare
I've rebased this PR and performed a few quick spot checks on the bench. This PR is good to go from what I can observe. See also PR #17645. |
… command Add support various TFmini models and basic autosetup for TFMini-plus Add "tfmini command -c XXXXXX" for device configuration Improve parser to support receiving confirmation from the device after a command has been written. Add SENS_EN_TFMINI param Improve autoconfigure mode for TFMini-plus upon starting.
4e0497e
to
e112685
Compare
Describe problem solved by this pull request
Describe your solution
A new "tfmini command -c XXXXXX" is introduced to help device configuration
directly from the flight controler. TFMini and TFMini-plus are both supported.
The parser has been improved to support receiving confirmation from the device
after a command has been written.
The parameter SENS_EN_TFMINI is implemented again to let user define the TFMini
model that will be used. This helps to validate commands and validate command's answers.
SENS_EN_TFMINI is also required because TFMini models don't offer the same capabilities
for FOV and MIN-DISTANCE.
The parser has been improved to provide signal quality for TFMini-plus.
The same should be done in the future for TFMini model.
The driver has been improved to autoconfigure the mode AND enable the output for TFMini-plus upon starting.
The same should be done in the future for TFMini model.
Describe possible alternatives
The TFMini-plus has signal strength between 100 and 0xFFFF for valid values. However, from testing, values are usually between 100 and 20000 instead. The scaling may not be perfect, but I have decided to measure signal_quality (in percentage) as 100strength/20000 instead of 100strength/0xFFFF with maximum strength being 20000 instead of 0xFFFFF.
Test data / coverage
I have tested the patch on a drone with a flight controler running latest master branch, but without flying. I have no drone ready to fly. Most of the patch concerns configuration, so I don't feel this is critical. Of course, I hope someone can fly with the patch and report
I have implemented as much as I need about the TFMini-plus model, but I have decided to not write the autosetup for the TFMini model because I don't have the device. However, I could write it, if someone is willing to test it.
Here are some example of command lines that can be used to configure the TFmini-plus device using nsh: