@@ -923,7 +923,7 @@ def _should_request_new_map(self, bbox: GeoSquare) -> bool:
923
923
use_gimbal_projection = self .get_parameter ('map_update.gimbal_projection' ).get_parameter_value ().bool_value
924
924
if use_gimbal_projection :
925
925
max_pitch = self .get_parameter ('map_update.max_pitch' ).get_parameter_value ().integer_value
926
- if self ._camera_pitch_too_high (max_pitch ):
926
+ if self ._camera_roll_or_pitch_too_high (max_pitch ):
927
927
self .get_logger ().warn (f'Camera pitch not available or above maximum { max_pitch } . Will not update map.' )
928
928
return False
929
929
@@ -1091,7 +1091,8 @@ def _should_estimate(self, img: np.ndarray) -> bool:
1091
1091
"""Determines whether :meth:`._estimate` should be called
1092
1092
1093
1093
Match should be attempted if (1) a reference map has been retrieved, (2) there are no pending match results,
1094
- (3) camera pitch is not too high (e.g. facing horizon instead of nadir), and (4) drone is not flying too low.
1094
+ (3) camera roll or pitch is not too high (e.g. facing horizon instead of nadir), and (4) drone is not flying
1095
+ too low.
1095
1096
1096
1097
:param img: Image from which to estimate pose
1097
1098
:return: True if pose estimation be attempted
@@ -1106,10 +1107,11 @@ def _should_estimate(self, img: np.ndarray) -> bool:
1106
1107
self .get_logger ().debug (f'Previous pose estimation results pending. Skipping pose estimation.' )
1107
1108
return False
1108
1109
1109
- # Check condition (3) - whether camera pitch is too large
1110
+ # Check condition (3) - whether camera roll/ pitch is too large
1110
1111
max_pitch = self .get_parameter ('misc.max_pitch' ).get_parameter_value ().integer_value
1111
- if self ._camera_pitch_too_high (max_pitch ):
1112
- self .get_logger ().warn (f'Camera pitch not available or above limit { max_pitch } . Skipping pose estimation.' )
1112
+ if self ._camera_roll_or_pitch_too_high (max_pitch ):
1113
+ self .get_logger ().warn (f'Camera roll or pitch not available or above limit { max_pitch } . Skipping pose '
1114
+ f'estimation.' )
1113
1115
return False
1114
1116
1115
1117
# Check condition (4) - whether vehicle altitude is too low
@@ -1205,11 +1207,11 @@ def _is_valid_estimate(self, fixed_camera: FixedCamera, input_data: InputData) -
1205
1207
# endregion
1206
1208
1207
1209
# region Shared Logic
1208
- def _camera_pitch_too_high (self , max_pitch : Union [int , float ]) -> bool :
1209
- """Returns True if (set) camera pitch exceeds given limit OR camera pitch is unknown
1210
+ def _camera_roll_or_pitch_too_high (self , max_pitch : Union [int , float ]) -> bool :
1211
+ """Returns True if (set) camera roll or pitch exceeds given limit OR camera pitch is unknown
1210
1212
1211
- Used to determine whether camera pitch setting is too high up from nadir to make matching against a map
1212
- not worthwhile.
1213
+ Used to determine whether camera roll or pitch is too high up from nadir to make matching against a map
1214
+ not worthwhile. Checks roll for static camera, but assumes zero roll for 2-axis gimbal (static_camera: False).
1213
1215
1214
1216
.. note::
1215
1217
Uses actual vehicle attitude (instead of gimbal set attitude) if static_camera ROS param is True
@@ -1221,6 +1223,7 @@ def _camera_pitch_too_high(self, max_pitch: Union[int, float]) -> bool:
1221
1223
static_camera = self .get_parameter ('misc.static_camera' ).get_parameter_value ().bool_value
1222
1224
pitch = None
1223
1225
if self ._bridge .gimbal_set_attitude is not None and not static_camera :
1226
+ # TODO: do not assume zero roll here - camera attitude handling needs refactoring
1224
1227
# +90 degrees to re-center from FRD frame to nadir-facing camera as origin for max pitch comparison
1225
1228
pitch = np .degrees (self ._bridge .gimbal_set_attitude .pitch ) + 90
1226
1229
else :
@@ -1232,7 +1235,7 @@ def _camera_pitch_too_high(self, max_pitch: Union[int, float]) -> bool:
1232
1235
self .get_logger ().warn ('Vehicle attitude was not available, assuming static camera pitch too high.' )
1233
1236
return True
1234
1237
else :
1235
- pitch = self ._bridge .attitude .pitch
1238
+ pitch = max ( self ._bridge .attitude .pitch , self . _bridge . attitude . roll )
1236
1239
1237
1240
assert pitch is not None
1238
1241
if pitch > max_pitch :
0 commit comments