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

Thoneflow 3901U Driver #12148

Merged
merged 2 commits into from
Aug 26, 2020
Merged

Thoneflow 3901U Driver #12148

merged 2 commits into from
Aug 26, 2020

Conversation

mhkabir
Copy link
Member

@mhkabir mhkabir commented Jun 3, 2019

Driver for the Thoneflow 3901U optical flow sensor connected over UART (https://www.seeedstudio.com/ThoneFlow_3901U_UART_Serial_Version_PMW3901_Optical_Flow_Sensor-p-4040.html).

Still needs flight testing and verification of the pixel to radians scaling factor.

@mhkabir mhkabir requested review from dagar and jkflying June 3, 2019 03:49
@mhkabir
Copy link
Member Author

mhkabir commented Jun 3, 2019

FYI @bys1123

@mhkabir mhkabir force-pushed the pr-thoneflow-3901u branch from 4b08e71 to ed158ee Compare June 3, 2019 03:54
@jkflying
Copy link
Contributor

jkflying commented Jun 3, 2019

The internal state machine for the parsing should be virtually identical to the existing PMW3901, correct? So wouldn't it make sense to share the parser, and just change the IO layer?

@mhkabir
Copy link
Member Author

mhkabir commented Jun 3, 2019

@jkflying Not really - these sensors have almost nothing in common at the driver level. The Thone board has an MCU on it which interfaces to the actual PMW sensor and gives us flow values over the UART using their own protocol.

After a conversation with @dagar, a new driver was found to be the best option. These 6 lines are the only thing in common between the drivers: https://github.com/PX4/Firmware/pull/12148/files#diff-cda4dc02a15d66b6b38abb0bbce9d42aR220

@bys1123
Copy link
Contributor

bys1123 commented Jun 3, 2019

Thanks, I'll test this later this week. My company is on an exhibition these days, a little bit busy.

@jkflying ThoneFlow-3901U is not using the same data format with SPI version PWM3901. But the first UART PMW3901 is using this protocol, it's out of stock now, but there is still many good tools and toy manufactures is using this format, so we continue use that protocol.

Special thanks @mhkabir 's works.

@dagar
Copy link
Member

dagar commented Jun 16, 2019

This looks safe to merge if you'd like to get it in and continue testing/iterating.

@bys1123
Copy link
Contributor

bys1123 commented Aug 13, 2019

@dagar Glad to see this merge for further testing.

@dagar
Copy link
Member

dagar commented Sep 1, 2019

Rebase?

@bys1123
Copy link
Contributor

bys1123 commented Sep 4, 2019

@mhkabir Do you have time rebase this, thanks!

@DanielePettenuzzo
Copy link
Contributor

@mhkabir is this in a state that can be merged? Did you ever flight test it?

@mhkabir
Copy link
Member Author

mhkabir commented Sep 28, 2019

This can be merged with a rebase. I flight tested it, but had issues with the scale factor which meant that the EKF was unhappy.

I'll rebase, and let's get this in and iterate.

@bys1123
Copy link
Contributor

bys1123 commented Nov 29, 2019

@mhkabir Do you have time rebase this, then we can easy to test it. Thanks!

@stale
Copy link

stale bot commented Feb 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@hamishwillee
Copy link
Contributor

When this is done, can you please add connector wiring information to https://docs.px4.io/master/en/sensor/pmw3901.html#thone_thoneflow_3901U

@stale stale bot removed the stale label Mar 26, 2020
@bys1123
Copy link
Contributor

bys1123 commented Mar 26, 2020

@hamishwillee Thank you, I'll share the information later.

@bys1123
Copy link
Contributor

bys1123 commented Apr 19, 2020

@dagar Do you have time update this driver makes it compatible with current master, then I could test the hard code parameters in the driver. Thanks!

@mhkabir
Copy link
Member Author

mhkabir commented Apr 20, 2020

Hey @bys1123 I don't, but feel free to pick it up and rebase it. It should be fairly painless.

@bys1123
Copy link
Contributor

bys1123 commented Apr 20, 2020

@mhkabir Thanks, I'll try it recently.

@bys1123
Copy link
Contributor

bys1123 commented Apr 22, 2020

image
ThoneFlow 3901UY Scheme

@mhkabir mhkabir force-pushed the pr-thoneflow-3901u branch from b3f20a5 to 610c9d7 Compare April 23, 2020 04:00
@mhkabir mhkabir force-pushed the pr-thoneflow-3901u branch from 610c9d7 to f60e98c Compare April 23, 2020 04:03
@bys1123
Copy link
Contributor

bys1123 commented Apr 23, 2020

Thanks! I've arrange to test with my team in this week!

@bys1123
Copy link
Contributor

bys1123 commented Apr 28, 2020

ThoneFlow-3901UY - Mount and Wiring

Copy link
Contributor

@bys1123 bys1123 left a comment

Choose a reason for hiding this comment

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

Thanks for your work, just read the code, I'm setting up the flight test.

Comment on lines +136 to +137
flow->pixel_flow_x_integral = static_cast<float>(delta_x) * (3.52e-3f);
flow->pixel_flow_y_integral = static_cast<float>(delta_y) * (3.52e-3f);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use 1.76f / 500.0f instead of (3.52e-3f), could help other developers better to understand the scale transition from PMW3901. https://github.com/PX4/Firmware/blob/master/src/drivers/optical_flow/pmw3901/PMW3901.cpp#L327-L328

Comment on lines +497 to +507
while ((ch = px4_getopt(argc, argv, "R:d:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'd':
device_path = myoptarg;
break;

default:
PX4_WARN("Unknown option!");
return -1;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will support customize rotation here? Or delete R:?

serial_config:
- command: thoneflow start -d ${SERIAL_DEV}
port_config_param:
name: SENS_TFLOW_CFG
Copy link
Contributor

Choose a reason for hiding this comment

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

The parameter setting is not like other serial device have a serial list in QGC, is that need to wait parameter metadata update on QGC side?

@bys1123
Copy link
Contributor

bys1123 commented May 2, 2020

image
Disarm log looks good.


/* Integrated flow is sent at 66fps */
_report.frame_count_since_last_readout = 1;
_report.integration_timespan = 15151; // microseconds
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
_report.integration_timespan = 15151; // microseconds
_report.integration_timespan = 10526; // microseconds

Thoneflow::Thoneflow(const char *port) :
ScheduledWorkItem(MODULE_NAME, px4::serial_port_to_wq(port)),
_rotation(Rotation(0)),
_cycle_interval(15150),
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
_cycle_interval(15150),
_cycle_interval(10526),

@bys1123
Copy link
Contributor

bys1123 commented May 18, 2020

@stale
Copy link

stale bot commented Aug 16, 2020

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale label Aug 16, 2020
@hamishwillee
Copy link
Contributor

This going to go in?

@stale stale bot removed the stale label Aug 16, 2020
@Chick92
Copy link

Chick92 commented Aug 26, 2020

Has there been any progress on this? Happy to flight test.

@dagar dagar marked this pull request as ready for review August 26, 2020 17:08
@dagar
Copy link
Member

dagar commented Aug 26, 2020

I don't see any harm in merging the current state, this is an optional peripheral driver you have to opt into using. Let's continue testing and iterating from master. Thanks everyone.

@dagar dagar merged commit c319bbd into PX4:master Aug 26, 2020
@mhkabir mhkabir deleted the pr-thoneflow-3901u branch August 26, 2020 18:53
@mhkabir
Copy link
Member Author

mhkabir commented Aug 26, 2020

For anyone who's using this/interested, the cycle interval probably needs to be changed to 10526.

Apparently there are also units out in the wild with different datarates over the UART.

@MaEtUgR
Copy link
Member

MaEtUgR commented Aug 26, 2020

getopt had a copy past parameter surviving which breaks CI module documentation checks: 2824eff

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

Successfully merging this pull request may close these issues.

8 participants