Skip to content

Commit

Permalink
camera: implement params changing on camera side
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Oct 26, 2024
1 parent d5256d7 commit d7dc3aa
Show file tree
Hide file tree
Showing 28 changed files with 1,803 additions and 750 deletions.
2 changes: 1 addition & 1 deletion proto
5 changes: 0 additions & 5 deletions src/integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ add_executable(integration_tests_runner
action_goto.cpp
action_hold.cpp
calibration.cpp
camera_capture_info.cpp
camera_mode.cpp
camera_settings.cpp
camera_status.cpp
camera_take_photo.cpp
camera_take_photo_interval.cpp
camera_reset_settings.cpp
camera_test_helpers.cpp
connection.cpp
follow_me.cpp
geofence.cpp
Expand Down
39 changes: 0 additions & 39 deletions src/integration_tests/camera_capture_info.cpp

This file was deleted.

104 changes: 0 additions & 104 deletions src/integration_tests/camera_mode.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions src/integration_tests/camera_reset_settings.cpp

This file was deleted.

103 changes: 0 additions & 103 deletions src/integration_tests/camera_take_photo.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions src/integration_tests/camera_test_helpers.cpp

This file was deleted.

12 changes: 0 additions & 12 deletions src/integration_tests/camera_test_helpers.h

This file was deleted.

4 changes: 4 additions & 0 deletions src/mavsdk/core/mavlink_parameter_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ MavlinkParameterCache::add_new_param(const std::string& param_id, ParamValue val
MavlinkParameterCache::UpdateExistingParamResult
MavlinkParameterCache::update_existing_param(const std::string& param_id, ParamValue value)
{
LogErr() << "updated existing: " << param_id;
auto it = std::find_if(_all_params.begin(), _all_params.end(), [&](const auto& param) {
return (param_id == param.id);
});

if (it == _all_params.end()) {
LogErr() << "missing!";
return UpdateExistingParamResult::MissingParam;
}

if (!it->value.is_same_type(value)) {
LogErr() << "wrong type!";
return MavlinkParameterCache::UpdateExistingParamResult::WrongType;
} else {
it->value.update_value_typesafe(value);
LogErr() << "ok!";
return MavlinkParameterCache::UpdateExistingParamResult::Ok;
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/mavsdk/core/mavlink_parameter_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,10 @@ void MavlinkParameterClient::process_param_value(const mavlink_message_t& messag
// out of scope.
auto work_queue_guard = std::make_unique<LockedQueue<WorkItem>::Guard>(_work_queue);
const auto work = work_queue_guard->get_front();

if (!work) {
// update existing param
find_and_call_subscriptions_value_changed(safe_param_id, received_value);
return;
}

Expand Down Expand Up @@ -836,8 +839,6 @@ void MavlinkParameterClient::process_param_value(const mavlink_message_t& messag
}
}},
work->work_item_variant);

// find_and_call_subscriptions_value_changed(safe_param_id, received_value);
}

void MavlinkParameterClient::process_param_ext_value(const mavlink_message_t& message)
Expand All @@ -862,9 +863,13 @@ void MavlinkParameterClient::process_param_ext_value(const mavlink_message_t& me
// See comments on process_param_value for use of unique_ptr
auto work_queue_guard = std::make_unique<LockedQueue<WorkItem>::Guard>(_work_queue);
auto work = work_queue_guard->get_front();

if (!work) {
// update existing param
find_and_call_subscriptions_value_changed(safe_param_id, received_value);
return;
}

if (!work->already_requested) {
return;
}
Expand Down Expand Up @@ -943,9 +948,6 @@ void MavlinkParameterClient::process_param_ext_value(const mavlink_message_t& me
},
},
work->work_item_variant);

// TODO I think we need to consider more edge cases here
// find_and_call_subscriptions_value_changed(safe_param_id, received_value);
}

void MavlinkParameterClient::process_param_ext_ack(const mavlink_message_t& message)
Expand Down
Loading

0 comments on commit d7dc3aa

Please sign in to comment.