#include "SoloGimbal_Parameters.h" #if HAL_SOLO_GIMBAL_ENABLED #include #include #include #include extern const AP_HAL::HAL& hal; const uint32_t SoloGimbal_Parameters::_retry_period = 3000; const uint8_t SoloGimbal_Parameters::_max_fetch_attempts = 5; SoloGimbal_Parameters::SoloGimbal_Parameters() { reset(); } void SoloGimbal_Parameters::reset() { memset(_params,0,sizeof(_params)); _last_request_ms = 0; _last_set_ms = 0; _flashing_step = GMB_PARAM_NOT_FLASHING; } const char* SoloGimbal_Parameters::get_param_name(gmb_param_t param) { switch(param) { case GMB_PARAM_GMB_OFF_ACC_X: return "GMB_OFF_ACC_X"; case GMB_PARAM_GMB_OFF_ACC_Y: return "GMB_OFF_ACC_Y"; case GMB_PARAM_GMB_OFF_ACC_Z: return "GMB_OFF_ACC_Z"; case GMB_PARAM_GMB_GN_ACC_X: return "GMB_GN_ACC_X"; case GMB_PARAM_GMB_GN_ACC_Y: return "GMB_GN_ACC_Y"; case GMB_PARAM_GMB_GN_ACC_Z: return "GMB_GN_ACC_Z"; case GMB_PARAM_GMB_OFF_GYRO_X: return "GMB_OFF_GYRO_X"; case GMB_PARAM_GMB_OFF_GYRO_Y: return "GMB_OFF_GYRO_Y"; case GMB_PARAM_GMB_OFF_GYRO_Z: return "GMB_OFF_GYRO_Z"; case GMB_PARAM_GMB_OFF_JNT_X: return "GMB_OFF_JNT_X"; case GMB_PARAM_GMB_OFF_JNT_Y: return "GMB_OFF_JNT_Y"; case GMB_PARAM_GMB_OFF_JNT_Z: return "GMB_OFF_JNT_Z"; case GMB_PARAM_GMB_K_RATE: return "GMB_K_RATE"; case GMB_PARAM_GMB_POS_HOLD: return "GMB_POS_HOLD"; case GMB_PARAM_GMB_MAX_TORQUE: return "GMB_MAX_TORQUE"; case GMB_PARAM_GMB_SND_TORQUE: return "GMB_SND_TORQUE"; case GMB_PARAM_GMB_SYSID: return "GMB_SYSID"; case GMB_PARAM_GMB_FLASH: return "GMB_FLASH"; default: return ""; }; } void SoloGimbal_Parameters::fetch_params() { for(uint8_t i=0; i _retry_period) && (HAVE_PAYLOAD_SPACE(_chan, PARAM_REQUEST_LIST))) { _last_request_ms = tnow_ms; mavlink_msg_param_request_list_send(_chan, 0, MAV_COMP_ID_GIMBAL); for(uint8_t i=0; i _retry_period)) { mavlink_msg_param_set_send(_chan, 0, MAV_COMP_ID_GIMBAL, get_param_name((gmb_param_t)i), _params[i].value, MAV_PARAM_TYPE_REAL32); _last_set_ms = AP_HAL::millis(); if (!_params[i].seen) { _params[i].fetch_attempts++; } } } // check for nonexistent parameters for(uint8_t i=0; i _max_fetch_attempts) { _params[i].state = GMB_PARAMSTATE_NONEXISTANT; DEV_PRINTF("Gimbal parameter %s timed out\n", get_param_name((gmb_param_t)i)); } } if(_flashing_step == GMB_PARAM_FLASHING_WAITING_FOR_SET) { bool done = true; for(uint8_t i=0; iWrite_Parameter(packet.param_id, packet.param_value); } #endif for(uint8_t i=0; i