Example #1
0
void dcm_servo_callback_prepare_outputs(void)
{
	if (dcm_flags._.calib_finished)
	{
		flight_mode_switch_2pos_poll();
#if ( DEADRECKONING == 1 )
		process_flightplan() ;
#endif	
#if(ALTITUDE_GAINS_VARIABLE == 1)
		airspeedCntrl();
#endif // ALTITUDE_GAINS_VARIABLE == 1
		updateBehavior() ;
		wind_gain = wind_gain_adjustment () ;
		rollCntrl() ;
		yawCntrl() ;
		altitudeCntrl();
		pitchCntrl() ;
		servoMix() ;
#if ( USE_CAMERA_STABILIZATION == 1 )
		cameraCntrl() ;
#endif
		cameraServoMix() ;
		updateTriggerAction() ;
	}
	else
	{
		// otherwise, there is not anything to do
		manualPassthrough() ;	// Allow manual control while starting up
	}
	
	if ( dcm_flags._.calib_finished ) // start telemetry after calibration
	{
#if ( SERIAL_OUTPUT_FORMAT == SERIAL_MAVLINK )
		mavlink_output_40hz() ;
#else
		// This is a simple check to send telemetry at 8hz
		if (udb_heartbeat_counter % 5 == 0)
		{
			serial_output_8hz() ;
		}
#endif
	}
	
#if (USE_OSD == 1)
	osd_run_step() ;
#endif
	
	return ;
}
Example #2
0
void BehaviorManager::updateBehaviors() {
	if (!_isActive)
		return;

	debug(0, "BehaviorManager::updateBehaviors()");
	for (uint i = 0; i < _behaviors.size(); i++) {
		BehaviorInfo *beh = _behaviors[i];

		if (!beh->_ani) {
			beh->_counter++;
			if (beh->_counter >= beh->_counterMax)
				updateBehavior(beh, beh->_bheItems[0]);

			continue;
		}

		if (beh->_ani->_movement || !(beh->_ani->_flags & 4) || (beh->_ani->_flags & 2)) {
			beh->_staticsId = 0;
			continue;
		}

		if (beh->_ani->_statics->_staticsId == beh->_staticsId) {
			beh->_counter++;
			if (beh->_counter >= beh->_counterMax) {
				if (beh->_subIndex >= 0 && !(beh->_flags & 1) && beh->_ani->_messageQueueId <= 0)
					updateStaticAniBehavior(beh->_ani, beh->_counter, beh->_bheItems[beh->_subIndex]);
			}
		} else {
			beh->_staticsId = beh->_ani->_statics->_staticsId;
			beh->_counter = 0;
			beh->_subIndex = -1;

			for (int j = 0; j < beh->_itemsCount; j++)
				if (beh->_bheItems[j]->_staticsId == beh->_staticsId) {
					beh->_subIndex = j;
					break;
				}

		}
	}
}