示例#1
0
// setup
void setup()
{
    hal.console->println("AP_Motors library test ver 1.0");

    // motor initialisation
    motors.set_update_rate(490);
    motors.set_frame_orientation(AP_MOTORS_X_FRAME);
    motors.Init();
    motors.set_throttle_range(130,1000,2000);
    motors.set_hover_throttle(500);
    motors.enable();
    motors.output_min();

    // setup radio
    if (rc3.radio_min == 0) {
	    // cope with AP_Param not being loaded
	    rc3.radio_min = 1000;
    }
    if (rc3.radio_max == 0) {
	    // cope with AP_Param not being loaded
	    rc3.radio_max = 2000;
    }
    // set rc channel ranges
    rc1.set_angle(4500);
    rc2.set_angle(4500);
    rc3.set_range(130, 1000);
    rc4.set_angle(4500);

    hal.scheduler->delay(1000);
}
void apmotors_output_init(void) {

    angular_channel_setup(&s_roll);
    angular_channel_setup(&s_pitch);
    angular_channel_setup(&s_yaw);
    throttle_channel_setup(&s_throttle);

    motors.set_update_rate(50); /* Is this appropriate with IOAR?
                                     Otherwise? */
    motors.set_frame_orientation(AP_MOTORS_X_FRAME);
    motors.Init();
    motors.set_min_throttle(THROTTLE_MINIMUM);
    motors.set_max_throttle(THROTTLE_MAXIMUM);

    motors.enable();
    motors.output_min();
    motors.auto_armed(true);
}