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

AP_RangeFinder:add support for RDS02UF radar driver on serial #21646

Closed
wants to merge 4 commits into from

Conversation

zebulon-86
Copy link
Contributor

  • Adding new features
    AP_RangeFinder:add support for RDS02UF radar driver on serial
    parameter RNGFND1_TYPE is 36
    RDS02UF features:
    • Sensor range scope 1.5m~20.0m
    • Azimuth Coverage ±17°,Elevation Coverage ±3°
    • Frame Rate 20Hz

Comment on lines 46 to 53
AP_RangeFinder_RDS02UF::AP_RangeFinder_RDS02UF(
RangeFinder::RangeFinder_State &_state,
AP_RangeFinder_Params &_params):
AP_RangeFinder_Backend_Serial(_state, _params)
{

}

Copy link
Contributor

Choose a reason for hiding this comment

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

should be able to do a

use AP_RangeFinder_Backend_Serial::AP_RangeFinder_Backend_Serial;

in the header instead of this empty constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the directions. I will make some changes before submitting them.

libraries/AP_RangeFinder/AP_RangeFinder_RDS02UF.cpp Outdated Show resolved Hide resolved
uint16_t count = 0;
int16_t nbytes = uart->available();
while (nbytes-- > 0) {
uint8_t c = uart->read();
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the return type of read. Need to check for read failure here.

libraries/AP_RangeFinder/AP_RangeFinder_RDS02UF.cpp Outdated Show resolved Hide resolved
Comment on lines 51 to 52
uint8_t parserbuf_index;
uint8_t rev_buffer[RDS02_BUFFER_SIZE];
Copy link
Contributor

Choose a reason for hiding this comment

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

These should have similar names.

libraries/AP_RangeFinder/AP_RangeFinder_RDS02UF.cpp Outdated Show resolved Hide resolved
libraries/AP_RangeFinder/AP_RangeFinder_RDS02UF.cpp Outdated Show resolved Hide resolved
*/

/**
* RDS02UF Note:
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a reference to the datasheet up in here somewhere.

if((data_fc & 0xf0f) == RDS02_TARGET_INFO){ // data_fc = 0x70C + ID * 0x10, ID: 0~0xF
float distance = (rev_buffer[RDS02_DATA_Y_INDEX_H] * 256 + rev_buffer[RDS02_DATA_Y_INDEX_L]) / 100.0f;
_distance_m = distance;
_distance_m = MIN(MAX(RDS02UF_DIST_MIN_CM, uint16_t(_distance_m*100)), RDS02UF_DIST_MAX_CM) * 0.01f;
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be constrained - this should be used to set the rangefinder as out-of-range-low or out-of-range-high

@peterbarker
Copy link
Contributor

I created a simulator for this device over here: #21647

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Sep 6, 2022

bool decode(uint8_t c);

const uint8_t crc8_table[256] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Bitwise operations eliminate the need for tables.
This saves 256 bytes of flash memory.

using namespace SITL;


const uint8_t crc8_table[256] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Bitwise operations eliminate the need for tables.
This saves 256 bytes of flash memory.

@peterbarker
Copy link
Contributor

We merged a different PR here, also by @zebulon-86 : #23056

@zebulon-86 next time, perhaps, force-push branches rather than opening new PRs :-)

Thanks!

@peterbarker peterbarker closed this Sep 5, 2024
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.

4 participants