-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Thoneflow 3901U Driver #12148
Conversation
FYI @bys1123 |
4b08e71
to
ed158ee
Compare
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? |
@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 |
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. |
ed158ee
to
eb3cea5
Compare
This looks safe to merge if you'd like to get it in and continue testing/iterating. |
@dagar Glad to see this merge for further testing. |
Rebase? |
@mhkabir Do you have time rebase this, thanks! |
@mhkabir is this in a state that can be merged? Did you ever flight test it? |
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. |
@mhkabir Do you have time rebase this, then we can easy to test it. Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
When this is done, can you please add connector wiring information to https://docs.px4.io/master/en/sensor/pmw3901.html#thone_thoneflow_3901U |
@hamishwillee Thank you, I'll share the information later. |
@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! |
Hey @bys1123 I don't, but feel free to pick it up and rebase it. It should be fairly painless. |
@mhkabir Thanks, I'll try it recently. |
b3f20a5
to
610c9d7
Compare
610c9d7
to
f60e98c
Compare
Thanks! I've arrange to test with my team in this week! |
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.
Thanks for your work, just read the code, I'm setting up the flight test.
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); |
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.
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
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; | ||
} | ||
} |
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.
Will support customize rotation here? Or delete R:
?
serial_config: | ||
- command: thoneflow start -d ${SERIAL_DEV} | ||
port_config_param: | ||
name: SENS_TFLOW_CFG |
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.
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?
|
||
/* Integrated flow is sent at 66fps */ | ||
_report.frame_count_since_last_readout = 1; | ||
_report.integration_timespan = 15151; // microseconds |
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.
_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), |
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.
_cycle_interval(15150), | |
_cycle_interval(10526), |
https://logs.px4.io/plot_app?log=e52de1fa-fa65-402c-bce4-a53496c9e583 |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
This going to go in? |
Has there been any progress on this? Happy to flight test. |
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. |
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. |
getopt had a copy past parameter surviving which breaks CI module documentation checks: 2824eff |
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.