navigator: stop capturing images on mission exit

When a mission starts capturing images using the
MAV_CMD_IMAGE_START_CAPTURE command, it should also stop it again, in
case it is stopped early, e.g. with RTL.
This commit is contained in:
Julian Oes
2022-09-15 18:15:25 -04:00
committed by Daniel Agar
parent 70194f52cd
commit fc89705ef8
3 changed files with 32 additions and 0 deletions
+27
View File
@@ -1499,7 +1499,20 @@ void Navigator::publish_vehicle_cmd(vehicle_command_s *vcmd)
// sent to the mavlink links to other components.
switch (vcmd->command) {
case NAV_CMD_IMAGE_START_CAPTURE:
// We are only capturing multiple if param3 is 0 or > 1.
if (static_cast<int>(vcmd->param3) != 1) {
_is_capturing_images = true;
}
vcmd->target_component = 100; // MAV_COMP_ID_CAMERA
break;
case NAV_CMD_IMAGE_STOP_CAPTURE:
_is_capturing_images = false;
vcmd->target_component = 100; // MAV_COMP_ID_CAMERA
break;
case NAV_CMD_VIDEO_START_CAPTURE:
case NAV_CMD_VIDEO_STOP_CAPTURE:
vcmd->target_component = 100; // MAV_COMP_ID_CAMERA
@@ -1552,6 +1565,20 @@ void Navigator::release_gimbal_control()
publish_vehicle_cmd(&vcmd);
}
void
Navigator::stop_capturing_images()
{
if (_is_capturing_images) {
vehicle_command_s vcmd = {};
vcmd.command = NAV_CMD_IMAGE_STOP_CAPTURE;
vcmd.param1 = 0.0f;
publish_vehicle_cmd(&vcmd);
// _is_capturing_images is reset inside publish_vehicle_cmd.
}
}
bool Navigator::geofence_allows_position(const vehicle_global_position_s &pos)
{
if ((_geofence.getGeofenceAction() != geofence_result_s::GF_ACTION_NONE) &&