detect and initialise backends
| 187 | |
| 188 | // detect and initialise backends |
| 189 | void AP_Camera::init() |
| 190 | { |
| 191 | // check init has not been called before |
| 192 | if (primary != nullptr) { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | // perform any required parameter conversion |
| 197 | convert_params(); |
| 198 | |
| 199 | // create each instance |
| 200 | for (uint8_t instance = 0; instance < AP_CAMERA_MAX_INSTANCES; instance++) { |
| 201 | switch ((CameraType)_params[instance].type.get()) { |
| 202 | #if AP_CAMERA_SERVO_ENABLED |
| 203 | case CameraType::SERVO: |
| 204 | _backends[instance] = NEW_NOTHROW AP_Camera_Servo(*this, _params[instance], instance); |
| 205 | break; |
| 206 | #endif |
| 207 | #if AP_CAMERA_RELAY_ENABLED |
| 208 | case CameraType::RELAY: |
| 209 | _backends[instance] = NEW_NOTHROW AP_Camera_Relay(*this, _params[instance], instance); |
| 210 | break; |
| 211 | #endif |
| 212 | #if AP_CAMERA_SOLOGIMBAL_ENABLED |
| 213 | // check for GoPro in Solo camera |
| 214 | case CameraType::SOLOGIMBAL: |
| 215 | _backends[instance] = NEW_NOTHROW AP_Camera_SoloGimbal(*this, _params[instance], instance); |
| 216 | break; |
| 217 | #endif |
| 218 | #if AP_CAMERA_MOUNT_ENABLED |
| 219 | // check for Mount camera |
| 220 | case CameraType::MOUNT: |
| 221 | _backends[instance] = NEW_NOTHROW AP_Camera_Mount(*this, _params[instance], instance); |
| 222 | break; |
| 223 | #endif |
| 224 | #if AP_CAMERA_MAVLINK_ENABLED |
| 225 | // check for MAVLink enabled camera driver |
| 226 | case CameraType::MAVLINK: |
| 227 | _backends[instance] = NEW_NOTHROW AP_Camera_MAVLink(*this, _params[instance], instance); |
| 228 | break; |
| 229 | #endif |
| 230 | #if AP_CAMERA_MAVLINKCAMV2_ENABLED |
| 231 | // check for MAVLink Camv2 driver |
| 232 | case CameraType::MAVLINK_CAMV2: |
| 233 | _backends[instance] = NEW_NOTHROW AP_Camera_MAVLinkCamV2(*this, _params[instance], instance); |
| 234 | break; |
| 235 | #endif |
| 236 | #if AP_CAMERA_SCRIPTING_ENABLED |
| 237 | // check for Scripting driver |
| 238 | case CameraType::SCRIPTING: |
| 239 | _backends[instance] = NEW_NOTHROW AP_Camera_Scripting(*this, _params[instance], instance); |
| 240 | break; |
| 241 | #endif |
| 242 | case CameraType::NONE: |
| 243 | break; |
| 244 | } |
| 245 | |
| 246 | // set primary to first non-null instance |
no test coverage detected