-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: allow for more than 327m range #27886
base: master
Are you sure you want to change the base?
AP_RangeFinder: allow for more than 327m range #27886
Conversation
1bf6995
to
88faf49
Compare
ea8a289
to
1239beb
Compare
|
5c0e9ae
to
09efa59
Compare
09efa59
to
0983029
Compare
ArduSub/Log.cpp
Outdated
@@ -48,7 +48,7 @@ void Sub::Log_Write_Control_Tuning() | |||
inav_alt : inertial_nav.get_position_z_up_cm() * 0.01f, | |||
baro_alt : barometer.get_altitude(), | |||
desired_rangefinder_alt : (int16_t)mode_surftrak.get_rangefinder_target_cm(), |
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.
These now being in different units will be annoying. I would vote to convert this to meters for logging.
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, adding a patch.
ArduSub/mode_surftrak.cpp
Outdated
@@ -67,9 +67,9 @@ bool ModeSurftrak::set_rangefinder_target_cm(float target_cm) | |||
sub.gcs().send_text(MAV_SEVERITY_WARNING, "wrong mode, rangefinder target not set"); | |||
} else if (sub.inertial_nav.get_position_z_up_cm() >= sub.g.surftrak_depth) { | |||
sub.gcs().send_text(MAV_SEVERITY_WARNING, "descend below %f meters to set rangefinder target", sub.g.surftrak_depth * 0.01f); | |||
} else if (target_cm < (float)sub.rangefinder_state.min_cm) { | |||
} else if (target_cm < (float)sub.rangefinder_state.min*100) { |
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.
} else if (target_cm < (float)sub.rangefinder_state.min*100) { | |
} else if (target_cm < sub.rangefinder_state.min*100) { |
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.
Fixed
ArduSub/mode_surftrak.cpp
Outdated
sub.gcs().send_text(MAV_SEVERITY_WARNING, "rangefinder target below minimum, ignored"); | ||
} else if (target_cm > (float)sub.rangefinder_state.max_cm) { | ||
} else if (target_cm > (float)sub.rangefinder_state.max*100) { |
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.
} else if (target_cm > (float)sub.rangefinder_state.max*100) { | |
} else if (target_cm > sub.rangefinder_state.max*100) { |
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.
Fixed.
ArduSub/sensors.cpp
Outdated
|
||
#if RANGEFINDER_TILT_CORRECTION | ||
// correct alt for angle of the rangefinder | ||
temp_alt = (float)temp_alt * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); | ||
temp_alt_m = (float)temp_alt_m * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); |
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.
temp_alt_m = (float)temp_alt_m * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); | |
temp_alt_m = temp_alt_m * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); |
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.
Fixed
libraries/AP_Scripting/docs/docs.lua
Outdated
@@ -3177,6 +3177,26 @@ function rangefinder:max_distance_cm_orient(orientation) end | |||
---@return integer | |||
function rangefinder:distance_cm_orient(orientation) end | |||
|
|||
-- desc |
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.
Full descriptions please.
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.
Fixed. Note that I did just copy the block above which used that "desc" thing :-)
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.
Fixed. Note that I did just copy the block above which used that "desc" thing :-)
Yeah, stuff that pre-dates the docs gets a pass, anything new does not. I need to take another pass at filling in the missing ones.
@@ -252,10 +252,18 @@ singleton RangeFinder rename rangefinder | |||
singleton RangeFinder method num_sensors uint8_t | |||
singleton RangeFinder method has_orientation boolean Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient uint16_t Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient deprecate Use distance_orient (in metres) |
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.
Nice! There is also some markup we should add to the docs. If you re-generate it might do that for you..... If not Just add
---@deprecated -- Use distance_orient (in metres)
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.
Looks like that will update the static checkers, so you will also have disable that check on any files that need it with:
---@diagnostic disable deprecated
Or move them onto the new method of course....
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.
Nice! There is also some markup we should add to the docs. If you re-generate it might do that for you..... If not Just add
---@deprecated -- Use distance_orient (in metres)
Done
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.
Looks like that will update the static checkers, so you will also have disable that check on any files that need it with:
---@diagnostic disable deprecated
Or move them onto the new method of course....
I have moved them to the new method - which I really should have done already!
0983029
to
23bf660
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.
Thanks for the review, @IamPete1 !
ArduSub/mode_surftrak.cpp
Outdated
@@ -67,9 +67,9 @@ bool ModeSurftrak::set_rangefinder_target_cm(float target_cm) | |||
sub.gcs().send_text(MAV_SEVERITY_WARNING, "wrong mode, rangefinder target not set"); | |||
} else if (sub.inertial_nav.get_position_z_up_cm() >= sub.g.surftrak_depth) { | |||
sub.gcs().send_text(MAV_SEVERITY_WARNING, "descend below %f meters to set rangefinder target", sub.g.surftrak_depth * 0.01f); | |||
} else if (target_cm < (float)sub.rangefinder_state.min_cm) { | |||
} else if (target_cm < (float)sub.rangefinder_state.min*100) { |
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.
Fixed
ArduSub/mode_surftrak.cpp
Outdated
sub.gcs().send_text(MAV_SEVERITY_WARNING, "rangefinder target below minimum, ignored"); | ||
} else if (target_cm > (float)sub.rangefinder_state.max_cm) { | ||
} else if (target_cm > (float)sub.rangefinder_state.max*100) { |
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.
Fixed.
ArduSub/sensors.cpp
Outdated
|
||
#if RANGEFINDER_TILT_CORRECTION | ||
// correct alt for angle of the rangefinder | ||
temp_alt = (float)temp_alt * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); | ||
temp_alt_m = (float)temp_alt_m * MAX(0.707f, ahrs.get_rotation_body_to_ned().c.z); |
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.
Fixed
libraries/AP_Scripting/docs/docs.lua
Outdated
@@ -3177,6 +3177,26 @@ function rangefinder:max_distance_cm_orient(orientation) end | |||
---@return integer | |||
function rangefinder:distance_cm_orient(orientation) end | |||
|
|||
-- desc |
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.
Fixed. Note that I did just copy the block above which used that "desc" thing :-)
@@ -252,10 +252,18 @@ singleton RangeFinder rename rangefinder | |||
singleton RangeFinder method num_sensors uint8_t | |||
singleton RangeFinder method has_orientation boolean Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient uint16_t Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient deprecate Use distance_orient (in metres) |
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.
Nice! There is also some markup we should add to the docs. If you re-generate it might do that for you..... If not Just add
---@deprecated -- Use distance_orient (in metres)
Done
@@ -252,10 +252,18 @@ singleton RangeFinder rename rangefinder | |||
singleton RangeFinder method num_sensors uint8_t | |||
singleton RangeFinder method has_orientation boolean Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient uint16_t Rotation'enum ROTATION_NONE ROTATION_MAX-1 | |||
singleton RangeFinder method distance_cm_orient deprecate Use distance_orient (in metres) |
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.
Looks like that will update the static checkers, so you will also have disable that check on any files that need it with:
---@diagnostic disable deprecated
Or move them onto the new method of course....
I have moved them to the new method - which I really should have done already!
8f566a9
to
3a6a09f
Compare
Parameter upgrade was tested with this:
|
… rename also fix a race condition in the quadplane-tailsitter test - which is unlikely to ever trigger
3a6a09f
to
b620ad4
Compare
No description provided.