MAVSDK
MAVSDK copied to clipboard
how to get Ardupilot Camera Trigger status?
Hello, I am developing software to control drones using MAVSDK c++, but I am having a problem, so I would like to ask a question.
What I want to do is set a flight mission to control the camera trigger at each waypoint of misson, but in mavsdk, I want to do a cout every time the trigger is controlled during the mission. But it's not working well. Please help.
` mavsdk.subscribe_on_message_async( MAVLinkMessage::Message::CAMERA_IMAGE_CAPTURED, [&](const MAVLinkMessage& message) { // 이미지가 캡처되면 실행될 코드 std::cout << "이미지 캡처 완료\n";
std::ostringstream filenameStream;
filenameStream << baseFilename << i << fileExtension;
std::string filename = filenameStream.str();
std::string command = "gphoto2 --port=usb: --folder=" + downloadPath +
" --capture-image-and-download --filename=\"" + downloadPath + filename + "\"";
int result_trigger = std::system(command.c_str());
if (result_trigger == 0) {
std::cout << "Image captured and downloaded: " << filename << std::endl;
}
else {
std::cerr << "Error capturing or downloading image." << std::endl;
return 1;
}
sleep_for(seconds(5));
std::string exifCommand = exifCommandTemplate + filePathPrefix + std::to_string(i) + filePathSuffix;
std::string move_enc = move + filePathPrefix + std::to_string(i) + filePathSuffix + enc;
std::cout << exifCommand << std::endl;
// Convert latitude and longitude to strings with full precision
std::ostringstream latitudeStr, longitudeStr;
latitudeStr << latitude;
longitudeStr << longitude;
// Convert altitude to a string and append "m"
std::ostringstream altitudeStr;
altitudeStr << altitude;
size_t pos = exifCommand.find("xxx");
exifCommand.replace(pos, 3, latitudeStr.str());
pos = exifCommand.find("xxx");
exifCommand.replace(pos, 3, longitudeStr.str());
pos = exifCommand.find("xxx");
exifCommand.replace(pos, 3, altitudeStr.str());
int result = std::system(exifCommand.c_str());
},
nullptr);
trigger_result = action.set_trigger_control(Action::TriggerControl::Disable);
if (trigger_result != Action::Result::Success) {
std::cerr << "트리거 제어 비활성화 실패: " << trigger_result << '\n';
return 1;
}`