Skip to content

Commit

Permalink
camera: don't forget to set component ID
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Nov 21, 2024
1 parent e973599 commit 2f8c5b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mavsdk/plugins/camera/camera_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,7 @@ void CameraImpl::process_heartbeat(const mavlink_message_t& message)
});

if (!found) {
auto new_potential_camera = PotentialCamera(message.compid);
_potential_cameras.emplace_back(std::move(new_potential_camera));
_potential_cameras.emplace_back(message.compid);
check_potential_cameras_with_lock();
}
}
Expand Down Expand Up @@ -1252,6 +1251,8 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message)
camera_information.cam_definition_uri[sizeof(camera_information.cam_definition_uri) - 1] = '\0';

Camera::Information new_information{};
// TODO: Check the case for 1-6.
new_information.component_id = message.compid;
new_information.vendor_name = reinterpret_cast<char*>(camera_information.vendor_name);
new_information.model_name = reinterpret_cast<char*>(camera_information.model_name);
new_information.focal_length_mm = camera_information.focal_length;
Expand All @@ -1268,13 +1269,12 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message)
});

if (potential_camera == _potential_cameras.end()) {
auto new_potential_camera = PotentialCamera(message.compid);
_potential_cameras.emplace_back(std::move(new_potential_camera));
_potential_cameras.emplace_back(message.compid);
potential_camera = std::prev(_potential_cameras.end());
}

// We need a copy of the component ID inside the information.
new_information.component_id = potential_camera->component_id;
potential_camera->component_id = new_information.component_id;
potential_camera->maybe_information = new_information;
potential_camera->camera_definition_url = camera_information.cam_definition_uri;
potential_camera->camera_definition_version = camera_information.cam_definition_version;
Expand Down

0 comments on commit 2f8c5b7

Please sign in to comment.