-
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
[WIP] Create a distance sensor driver base class #11977
Conversation
@davids5 do you know where we can purchase this sensor? |
b2c5075
to
7ebfbf8
Compare
@dagar , and @davids5 , the closest product number I can find to the CM8JL65 on Lanbao's site are the PTK series: http://www.lanbaosensor.com/index.php?m=content&c=index&a=prolists&catid=96. I have not been able to locate a source or a product page for the CM8JL65. |
It is a custom build that will be made available in the next couple of weeks. It is much smaller compared to their previous offerings. |
@mcsauder at the moment all the vehicles we have that mount this distance sensor are used for testing other functionalities. Will try to allocate some time this week. |
This looks very similar with TFminiPlus |
1953792
to
85630df
Compare
@mcsauder the distance sensor is now available on seeed I'll give a shot to your branch later today |
Thanks @cmic0 , I have a sensor pre-ordered now, so in about a month I will be able to test this work. If you have spare cycles I am grateful for any feedback you have, but feel free to wait and I will update this PR with test data when my sensor arrives. Thanks for the link! |
85630df
to
e7efda6
Compare
e7efda6
to
0fc69f2
Compare
406dfbe
to
bd673fc
Compare
bd673fc
to
670c0d7
Compare
670c0d7
to
3dbdb89
Compare
e4cd5f4
to
ee94a46
Compare
ee94a46
to
f5ae946
Compare
6daedf4
to
af050a6
Compare
|
||
distance_sensor_s report; | ||
report.current_distance = get_distance(); | ||
report.id = get_sensor_id(); |
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.
Most of these fields don't change every iteration.
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.
Agreed. I'll rework this. Thanks for looking this over!
} | ||
|
||
int | ||
DistanceSensor::open_serial_port(const speed_t speed) |
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.
I think handling a serial port is an orthogonal piece.
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.
Agreed. I'll break this out into a separate implementation.
/* Configuration Constants */ | ||
#define DEFAULT_BAUD_RATE B115200 // Baudrate 115200. | ||
#define DEFAULT_MEASURE_INTERVAL 100_ms // 100ms default sensor measurement interval. | ||
#define DEFAULT_SERIAL_PORT "/dev/ttyS3" // Default UART port. |
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 entire concept of default port probably needs to go away from the driver perspective and be set per board.
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.
OK. For now I'll pull this out into a separate SerialPort
class along with the open_serial_port()
implementation.
9a78c6d
to
0e5895c
Compare
…rt the CM8JL65, HC_SR04, LeddarOne, and uLanding driver classes to inherit from the base class.
0e5895c
to
9fd6fa1
Compare
I think I'll close this PR and work on adding functionality and porting distance sensor drivers over to inherit from the PX4RangeFinder class. |
Describe problem solved by the proposed pull request
This PR creates a DistanceSensor base class, and refactors the following drivers to inherit from the base class
Test data / coverage
Test data will be presented...
Describe problem solved by the proposed pull request
The distance sensor drivers are largely copy/paste from previous implementations. This PR establishes a distance sensor driver base class to allow an inheritance, better distance design pattern and architecture, better boilerplate code for future implementations, and less overall code duplication.
Describe possible alternatives
The drivers certainly can be left as-is.
Additional context
See #11853. #11891, #9279, #11853, #11857, #1858, #11859. etc.