2020-02-09 01:47:52 -04:00
|
|
|
#include "AP_Camera_SoloGimbal.h"
|
|
|
|
|
2023-03-06 19:04:39 -04:00
|
|
|
#if AP_CAMERA_SOLOGIMBAL_ENABLED
|
2020-07-24 14:31:42 -03:00
|
|
|
|
2023-02-10 20:27:39 -04:00
|
|
|
#include <GCS_MAVLink/GCS.h>
|
2020-02-09 01:47:52 -04:00
|
|
|
|
|
|
|
// Toggle the shutter on the GoPro
|
|
|
|
// This is so ArduPilot can toggle the shutter directly, either for mission/GCS commands, or when the
|
2023-10-11 04:41:51 -03:00
|
|
|
// Solo's gimbal is installed on a vehicle other than a Solo. The usual GoPro controls through the
|
2020-02-09 01:47:52 -04:00
|
|
|
// Solo app and Solo controller do not use this, as it is done offboard on the companion computer.
|
2023-02-10 20:27:39 -04:00
|
|
|
// entry point to actually take a picture. returns true on success
|
|
|
|
bool AP_Camera_SoloGimbal::trigger_pic()
|
2020-02-09 01:47:52 -04:00
|
|
|
{
|
|
|
|
if (gopro_status != GOPRO_HEARTBEAT_STATUS_CONNECTED) {
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "GoPro Not Available");
|
2023-02-10 20:27:39 -04:00
|
|
|
return false;
|
2020-02-09 01:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t gopro_shutter_start[4] = { 1, 0, 0, 0};
|
|
|
|
const uint8_t gopro_shutter_stop[4] = { 0, 0, 0, 0};
|
|
|
|
|
|
|
|
if (gopro_capture_mode == GOPRO_CAPTURE_MODE_PHOTO) {
|
|
|
|
// Trigger shutter start to take a photo
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro Photo Trigger");
|
2020-02-09 01:47:52 -04:00
|
|
|
mavlink_msg_gopro_set_request_send(heartbeat_channel, mavlink_system.sysid, MAV_COMP_ID_GIMBAL,GOPRO_COMMAND_SHUTTER,gopro_shutter_start);
|
|
|
|
|
|
|
|
} else if (gopro_capture_mode == GOPRO_CAPTURE_MODE_VIDEO) {
|
|
|
|
if (gopro_is_recording) {
|
|
|
|
// GoPro is recording, so stop recording
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro Recording Stop");
|
2020-02-09 01:47:52 -04:00
|
|
|
mavlink_msg_gopro_set_request_send(heartbeat_channel, mavlink_system.sysid, MAV_COMP_ID_GIMBAL,GOPRO_COMMAND_SHUTTER,gopro_shutter_stop);
|
|
|
|
} else {
|
|
|
|
// GoPro is not recording, so start recording
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro Recording Start");
|
2020-02-09 01:47:52 -04:00
|
|
|
mavlink_msg_gopro_set_request_send(heartbeat_channel, mavlink_system.sysid, MAV_COMP_ID_GIMBAL,GOPRO_COMMAND_SHUTTER,gopro_shutter_start);
|
|
|
|
}
|
|
|
|
} else {
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "GoPro Unsupported Capture Mode");
|
2023-02-10 20:27:39 -04:00
|
|
|
return false;
|
2020-02-09 01:47:52 -04:00
|
|
|
}
|
2023-02-10 20:27:39 -04:00
|
|
|
|
|
|
|
return true;
|
2020-02-09 01:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cycle the GoPro capture mode
|
|
|
|
// This is so ArduPilot can cycle through the capture modes of the GoPro directly, probably with an RC Aux function.
|
|
|
|
// This is primarily for Solo's gimbal being installed on a vehicle other than a Solo. The usual GoPro controls
|
|
|
|
// through the Solo app and Solo controller do not use this, as it is done offboard on the companion computer.
|
2023-02-10 20:27:39 -04:00
|
|
|
// momentary switch to change camera between picture and video modes
|
|
|
|
void AP_Camera_SoloGimbal::cam_mode_toggle()
|
2020-02-09 01:47:52 -04:00
|
|
|
{
|
|
|
|
uint8_t gopro_capture_mode_values[4] = { };
|
2023-02-10 20:27:39 -04:00
|
|
|
|
2020-02-09 01:47:52 -04:00
|
|
|
if (gopro_status != GOPRO_HEARTBEAT_STATUS_CONNECTED) {
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "GoPro Not Available");
|
2020-02-09 01:47:52 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(gopro_capture_mode) {
|
|
|
|
case GOPRO_CAPTURE_MODE_VIDEO:
|
|
|
|
if (gopro_is_recording) {
|
|
|
|
// GoPro is recording, cannot change modes
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro recording, can't change modes");
|
2020-02-09 01:47:52 -04:00
|
|
|
} else {
|
|
|
|
// Change to camera mode
|
|
|
|
gopro_capture_mode_values[0] = GOPRO_CAPTURE_MODE_PHOTO;
|
|
|
|
mavlink_msg_gopro_set_request_send(heartbeat_channel, mavlink_system.sysid, MAV_COMP_ID_GIMBAL,GOPRO_COMMAND_CAPTURE_MODE,gopro_capture_mode_values);
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro changing to mode photo");
|
2020-02-09 01:47:52 -04:00
|
|
|
}
|
|
|
|
break;
|
2023-02-10 20:27:39 -04:00
|
|
|
|
2020-02-09 01:47:52 -04:00
|
|
|
case GOPRO_CAPTURE_MODE_PHOTO:
|
|
|
|
default:
|
|
|
|
// Change to video mode
|
|
|
|
gopro_capture_mode_values[0] = GOPRO_CAPTURE_MODE_VIDEO;
|
|
|
|
mavlink_msg_gopro_set_request_send(heartbeat_channel, mavlink_system.sysid, MAV_COMP_ID_GIMBAL,GOPRO_COMMAND_CAPTURE_MODE,gopro_capture_mode_values);
|
2024-08-07 00:17:20 -03:00
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "GoPro changing to mode video");
|
2020-02-09 01:47:52 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-10 20:27:39 -04:00
|
|
|
// handle incoming heartbeat from the Solo gimbal GoPro
|
|
|
|
void AP_Camera_SoloGimbal::handle_message(mavlink_channel_t chan, const mavlink_message_t &msg)
|
2020-02-09 01:47:52 -04:00
|
|
|
{
|
|
|
|
mavlink_gopro_heartbeat_t report_msg;
|
|
|
|
mavlink_msg_gopro_heartbeat_decode(&msg, &report_msg);
|
|
|
|
gopro_is_recording = report_msg.flags & GOPRO_FLAG_RECORDING;
|
|
|
|
heartbeat_channel = chan;
|
|
|
|
|
|
|
|
switch((GOPRO_HEARTBEAT_STATUS)report_msg.status) {
|
|
|
|
case GOPRO_HEARTBEAT_STATUS_DISCONNECTED:
|
|
|
|
case GOPRO_HEARTBEAT_STATUS_INCOMPATIBLE:
|
|
|
|
case GOPRO_HEARTBEAT_STATUS_ERROR:
|
|
|
|
case GOPRO_HEARTBEAT_STATUS_CONNECTED:
|
|
|
|
gopro_status = (GOPRO_HEARTBEAT_STATUS)report_msg.status;
|
|
|
|
break;
|
|
|
|
case GOPRO_HEARTBEAT_STATUS_ENUM_END:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch((GOPRO_CAPTURE_MODE)report_msg.capture_mode){
|
|
|
|
case GOPRO_CAPTURE_MODE_VIDEO:
|
|
|
|
case GOPRO_CAPTURE_MODE_PHOTO:
|
|
|
|
case GOPRO_CAPTURE_MODE_BURST:
|
|
|
|
case GOPRO_CAPTURE_MODE_TIME_LAPSE:
|
|
|
|
case GOPRO_CAPTURE_MODE_MULTI_SHOT:
|
|
|
|
case GOPRO_CAPTURE_MODE_PLAYBACK:
|
|
|
|
case GOPRO_CAPTURE_MODE_SETUP:
|
|
|
|
case GOPRO_CAPTURE_MODE_UNKNOWN:
|
|
|
|
gopro_capture_mode = (GOPRO_CAPTURE_MODE)report_msg.capture_mode;
|
|
|
|
break;
|
|
|
|
case GOPRO_CAPTURE_MODE_ENUM_END:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-07-24 14:31:42 -03:00
|
|
|
|
2023-03-06 19:04:39 -04:00
|
|
|
#endif // AP_CAMERA_SOLOGIMBAL_ENABLED
|