コード例 #1
0
void AP_MotorsHeli::rsc_control() {

    if (armed() && (rsc_ramp >= rsc_ramp_up_rate)){                     // rsc_ramp will never increase if rsc_mode = 0
        if (motor_runup_timer < MOTOR_RUNUP_TIME){                      // therefore motor_runup_complete can never be true
            motor_runup_timer++;
        } else {
            motor_runup_complete = true;
        }
    } else {
        motor_runup_complete = false;                                   // motor_runup_complete will go to false if we
        motor_runup_timer = 0;                                          // disarm or wind down the motor
    }


    switch ( rsc_mode ) {

    case AP_MOTORSHELI_RSC_MODE_CH8_PASSTHROUGH:
        if( armed() && (_rc_8->radio_in > (_rc_8->radio_min + 10))) {
            if (rsc_ramp < rsc_ramp_up_rate) {
                rsc_ramp++;
                rsc_output = map(rsc_ramp, 0, rsc_ramp_up_rate, _rc_8->radio_min, _rc_8->radio_in);
            } else {
                rsc_output = _rc_8->radio_in;
            }
        } else {
			rsc_ramp--;                                                 //Return RSC Ramp to 0 slowly, allowing for "warm restart"
			if (rsc_ramp < 0) {
                rsc_ramp = 0;
			}
			rsc_output = _rc_8->radio_min;
        }
        hal.rcout->write(AP_MOTORS_HELI_EXT_RSC, rsc_output);
        break;

    case AP_MOTORSHELI_RSC_MODE_EXT_GOV:

        if( armed() && _rc_8->control_in > 100) {
            if (rsc_ramp < rsc_ramp_up_rate) {
                rsc_ramp++;
                rsc_output = map(rsc_ramp, 0, rsc_ramp_up_rate, 1000, ext_gov_setpoint);
            } else {
                rsc_output = ext_gov_setpoint;
            }
        } else {
            rsc_ramp--;                                                 //Return RSC Ramp to 0 slowly, allowing for "warm restart"
            if (rsc_ramp < 0) {
                rsc_ramp = 0;
            }
            rsc_output = 1000;                                  //Just to be sure RSC output is 0
        }
        hal.rcout->write(AP_MOTORS_HELI_EXT_RSC, rsc_output);
        break;

    default:
        break;
    }
};
コード例 #2
0
CLSBasicScalerChannelDetector::CLSBasicScalerChannelDetector(const QString &name, const QString &description, CLSSIS3820Scaler *scaler, int channelIndex, QObject *parent) :
	AMDetector(name, description, parent)
{
	scaler_ = scaler;
	channelIndex_ = channelIndex;

	connect(scaler_, SIGNAL(connectedChanged(bool)), this, SLOT(onScalerConnected(bool)));
	connect(scaler_, SIGNAL(scanningChanged(bool)), this, SLOT(onScalerScanningChanged(bool)));
	connect(scaler_, SIGNAL(sensitivityChanged()), this, SLOT(onScalerSensitivityChanged()));
	connect(scaler_, SIGNAL(dwellTimeChanged(double)), this, SLOT(onScalerDwellTimeChanged()));
	connect(scaler_, SIGNAL(continuousChanged(bool)), this, SLOT(onContinuousChanged(bool)));

	connect(scaler_, SIGNAL(armed()), this, SIGNAL(armed()));
}
コード例 #3
0
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsSingle::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // output to motors and servos
    switch (motor_seq) {
        case 1:
            // flap servo 1
            rc_write(AP_MOTORS_MOT_1, pwm);
            break;
        case 2:
            // flap servo 2
            rc_write(AP_MOTORS_MOT_2, pwm);
            break;
        case 3:
            // flap servo 3
            rc_write(AP_MOTORS_MOT_3, pwm);
            break;
        case 4:
            // flap servo 4
            rc_write(AP_MOTORS_MOT_4, pwm);
            break;
        case 5:
            // spin main motor
            rc_write(AP_MOTORS_MOT_7, pwm);
            break;
        default:
            // do nothing
            break;
    }
}
コード例 #4
0
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsTri::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // output to motors and servos
    switch (motor_seq) {
        case 1:
            // front right motor
            hal.rcout->write(AP_MOTORS_MOT_1, pwm);
            break;
        case 2:
            // back motor
            hal.rcout->write(AP_MOTORS_MOT_4, pwm);
            break;
        case 3:
            // back servo
            hal.rcout->write(AP_MOTORS_CH_TRI_YAW, pwm);
            break;
        case 4:
            // front left motor
            hal.rcout->write(AP_MOTORS_MOT_2, pwm);
            break;
        default:
            // do nothing
            break;
    }
}
コード例 #5
0
ファイル: MSToggleButtonBase.C プロジェクト: PlanetAPL/a-plus
void MSToggleButtonBase::key(KeySym keysym_,unsigned int,const char *)
{
  if (keysym_==XK_Return) { (armed()==MSFalse)?arm():disarm(); }
  else if (keysym_==XK_Up) up();
  else if (keysym_==XK_Down) down();
  else if (keysym_==XK_Left) left();
  else if (keysym_==XK_Right) right();
}
コード例 #6
0
ファイル: AP_Motors.cpp プロジェクト: Jean-Emile/ardupilot
// throttle_pass_through - passes throttle through to motors - dangerous but used for initialising ESCs
void AP_Motors::throttle_pass_through()
{
    if( armed() ) {
        for( int16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++ ) {
            _rc->OutputCh(_motor_to_channel_map[i], _rc_throttle->radio_in);
        }
    }
}
コード例 #7
0
// throttle_pass_through - passes throttle through to motors - dangerous but used for initialising ESCs
void AP_Motors::throttle_pass_through()
{
    if( armed() ) {
        // XXX
        for( int16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++ ) {
            hal.rcout->write(_motor_to_channel_map[i], _rc_throttle->radio_in);
        }
    }
}
コード例 #8
0
// return true if the tail rotor is up to speed
bool AP_MotorsHeli::tail_rotor_runup_complete()
{
    // always return true if not using direct drive variable pitch tails
    if (_tail_type != AP_MOTORS_HELI_TAILTYPE_DIRECTDRIVE_VARPITCH) {
        return true;
    }

    // check speed
    return (armed() && _tail_direct_drive_out >= _direct_drive_tailspeed);
}
コード例 #9
0
ファイル: AP_MotorsMulticopter.cpp プロジェクト: czq13/THUF35
// throttle_pass_through - passes provided pwm directly to all motors - dangerous but used for initialising ESCs
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsMulticopter::throttle_pass_through(int16_t pwm)
{
    if (armed()) {
        // send the pilot's input directly to each enabled motor
        for (uint16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
            if (motor_enabled[i]) {
                hal.rcout->write(i, pwm);
            }
        }
    }
}
コード例 #10
0
// throttle_pass_through - passes pilot's throttle input directly to all motors - dangerous but used for initialising ESCs
void AP_Motors::throttle_pass_through()
{
    if (armed()) {
        // send the pilot's input directly to each enabled motor
        for (int16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
            if (motor_enabled[i]) {
                hal.rcout->write(_motor_to_channel_map[i], _rc_throttle->radio_in);
            }
        }
    }
}
コード例 #11
0
// throttle_pass_through - passes provided pwm directly to all motors - dangerous but used for initialising ESCs
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_Motors::throttle_pass_through(int16_t pwm)
{
    if (armed()) {
        // send the pilot's input directly to each enabled motor
        for (int16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
            if (motor_enabled[i]) {
                hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[i]), pwm);
            }
        }
    }
}
コード例 #12
0
// update the throttle input filter
void AP_Motors::update_throttle_filter()
{
    if (armed()) {
        _throttle_filter.apply(constrain_float(_throttle_in,-100,1100), 1.0f/_loop_rate);
    } else {
        _throttle_filter.reset(0.0f);
    }

    // prevent _rc_throttle.servo_out from wrapping at int16 max or min
    _rc_throttle.servo_out = constrain_float(_throttle_filter.get(),-32000,32000);
}
コード例 #13
0
// update the throttle input filter
void AP_MotorsMulticopter::update_throttle_filter()
{
    if (armed()) {
        _throttle_filter.apply(_throttle_in, 1.0f/_loop_rate);
    } else {
        _throttle_filter.reset(0.0f);
    }

    // constrain throttle signal to 0-1000
    _throttle_control_input = constrain_float(_throttle_filter.get(),0.0f,1000.0f);
}
コード例 #14
0
// passes throttle directly to all motors for ESC calibration.
//   throttle_input is in the range of 0 ~ 1 where 0 will send get_pwm_output_min() and 1 will send get_pwm_output_max()
void AP_MotorsMulticopter::set_throttle_passthrough_for_esc_calibration(float throttle_input)
{
    if (armed()) {
        uint16_t pwm_out = get_pwm_output_min() + constrain_float(throttle_input, 0.0f, 1.0f) * (get_pwm_output_max() - get_pwm_output_min());
        // send the pilot's input directly to each enabled motor
        for (uint16_t i=0; i < AP_MOTORS_MAX_NUM_MOTORS; i++) {
            if (motor_enabled[i]) {
                rc_write(i, pwm_out);
            }
        }
    }
}
コード例 #15
0
ファイル: Track.C プロジェクト: shanipribadi/non
/** build the context menu */
Fl_Menu_Button &
Track::menu ( void ) const
{

    int c = output.size();
    int s = size();

    _menu.clear();

    _menu.add( "Takes/Show all takes", 0, 0, 0, FL_MENU_TOGGLE | ( show_all_takes() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Takes/New", 0, 0, 0 );

    if ( takes->children() )
    {
        _menu.add( "Takes/Remove", 0, 0, 0 );
        _menu.add( "Takes/Remove others", 0, 0, 0, FL_MENU_DIVIDER );
        
        for ( int i = 0; i < takes->children(); ++i )
        {
            Sequence *s = (Sequence *)takes->child( i );
            
            char n[256];
            snprintf( n, sizeof(n), "Takes/%s", s->name() );

            _menu.add( n, 0, 0, s);
        }
    }

    _menu.add( "Type/Mono",  0, 0, 0, FL_MENU_RADIO | ( c == 1 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Type/Stereo", 0, 0, 0, FL_MENU_RADIO | ( c == 2 ? FL_MENU_VALUE : 0 ));
    _menu.add( "Type/Quad",            0, 0, 0, FL_MENU_RADIO | ( c == 4 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Type/...",             0, 0, 0, FL_MENU_RADIO | ( c == 3 || c > 4 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Overlay controls",   0, 0, 0, FL_MENU_TOGGLE | ( overlay_controls() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Add Control",     0, 0, 0 );
    _menu.add( "Add Annotation",  0, 0, 0 );
    _menu.add( "Color",           0, 0, 0 );
    _menu.add( "Rename",          FL_CTRL + 'n', 0, 0 );
    _menu.add( "Size/Small",           FL_ALT + '1', 0, 0, FL_MENU_RADIO | ( s == 0 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Medium",          FL_ALT + '2', 0, 0, FL_MENU_RADIO | ( s == 1 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Large",           FL_ALT + '3', 0, 0, FL_MENU_RADIO | ( s == 2 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Size/Huge",           FL_ALT + '4', 0, 0, FL_MENU_RADIO | ( s == 3 ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Record",         FL_CTRL + 'r', 0, 0, FL_MENU_TOGGLE | ( armed() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Mute",            FL_CTRL + 'm', 0, 0, FL_MENU_TOGGLE | ( mute() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Flags/Solo",           FL_CTRL + 's', 0, 0, FL_MENU_TOGGLE | ( solo() ? FL_MENU_VALUE : 0 ) );
    _menu.add( "Move Up",        FL_SHIFT + '1', 0, 0 );
    _menu.add( "Move Down",        FL_SHIFT + '2', 0, 0 );
    _menu.add( "Remove",          0, 0, 0 ); // transport->rolling ? FL_MENU_INACTIVE : 0 );
  
    _menu.callback( &Track::menu_cb, (void*)this );

    return _menu;
}
コード例 #16
0
ファイル: Track.C プロジェクト: shanipribadi/non
void
Track::get_unjournaled ( Log_Entry &e ) const
{
    e.add( ":height",          size()           );
    e.add( ":inputs",          input.size()     );
    e.add( ":outputs",         output.size()    );
    e.add( ":show-all-takes",  show_all_takes()  );
    e.add( ":overlay-controls", overlay_controls()  );    
    e.add( ":armed",           armed()          );
    e.add( ":mute",            mute()           );
    e.add( ":solo",            solo()           );
    e.add( ":row",             timeline->find_track( this ) );
}
コード例 #17
0
ファイル: AP_MotorsMatrix.cpp プロジェクト: Flandoe/ardupilot
void AP_MotorsMatrix::output_to_motors()
{
    int8_t i;
    int16_t motor_out[AP_MOTORS_MAX_NUM_MOTORS];    // final pwm values sent to the motor

    switch (_spool_mode) {
        case SHUT_DOWN: {
            // sends minimum values out to the motors
            // set motor output based on thrust requests
            for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
                if (motor_enabled[i]) {
                    if (_disarm_disable_pwm && _disarm_safety_timer == 0 && !armed()) {
                        motor_out[i] = 0;
                    } else {
                        motor_out[i] = get_pwm_output_min();
                    }
                }
            }
            break;
        }
        case SPIN_WHEN_ARMED:
            // sends output to motors when armed but not flying
            for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
                if (motor_enabled[i]) {
                    motor_out[i] = calc_spin_up_to_pwm();
                }
            }
            break;
        case SPOOL_UP:
        case THROTTLE_UNLIMITED:
        case SPOOL_DOWN:
            // set motor output based on thrust requests
            for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
                if (motor_enabled[i]) {
                    motor_out[i] = calc_thrust_to_pwm(_thrust_rpyt_out[i]);
                }
            }
            break;
    }

    // send output to each motor
    hal.rcout->cork();
    for (i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
        if (motor_enabled[i]) {
            rc_write(i, motor_out[i]);
        }
    }
    hal.rcout->push();
}
コード例 #18
0
// update the throttle input filter
void AP_MotorsMulticopter::update_throttle_filter()
{
    if (armed()) {
        _throttle_filter.apply(_throttle_in, 1.0f/_loop_rate);
        // constrain filtered throttle
        if (_throttle_filter.get() < 0.0f) {
            _throttle_filter.reset(0.0f);
        }
        if (_throttle_filter.get() > 1.0f) {
            _throttle_filter.reset(1.0f);
        }
    } else {
        _throttle_filter.reset(0.0f);
    }
}
コード例 #19
0
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsMatrix::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // loop through all the possible orders spinning any motors that match that description
    for (uint8_t i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
        if (motor_enabled[i] && _test_order[i] == motor_seq) {
            // turn on this motor
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[i]), pwm);
        }
    }
}
コード例 #20
0
// set frame class (i.e. quad, hexa, heli) and type (i.e. x, plus)
void AP_MotorsMatrix::set_frame_class_and_type(motor_frame_class frame_class, motor_frame_type frame_type)
{
    // exit immediately if armed or no change
    if (armed() || (frame_class == _last_frame_class && _last_frame_type == frame_type)) {
        return;
    }
    _last_frame_class = frame_class;
    _last_frame_type = frame_type;

    // setup the motors
    setup_motors(frame_class, frame_type);

    // enable fast channels or instant pwm
    set_update_rate(_speed_hz);
}
コード例 #21
0
ファイル: AP_MotorsMatrix.cpp プロジェクト: GUYING7/ardupilot
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsMatrix::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // loop through all the possible orders spinning any motors that match that description
    hal.rcout->cork();
    for (uint8_t i=0; i<AP_MOTORS_MAX_NUM_MOTORS; i++) {
        if (motor_enabled[i] && _test_order[i] == motor_seq) {
            // turn on this motor
            rc_write(i, pwm);
        }
    }
    hal.rcout->push();
}
コード例 #22
0
// rsc_control - update value to send to tail and main rotor's ESC
// desired_rotor_speed is a desired speed from 0 to 1000
void AP_MotorsHeli::rsc_control()
{
    // if disarmed output minimums
    if (!armed()) {
        // shut down tail rotor
        if (_tail_type == AP_MOTORS_HELI_TAILTYPE_DIRECTDRIVE_VARPITCH || _tail_type == AP_MOTORS_HELI_TAILTYPE_DIRECTDRIVE_FIXEDPITCH) {
            _tail_direct_drive_out = 0;
            write_aux(_tail_direct_drive_out);
        }
        // shut down main rotor
        if (_rsc_mode != AP_MOTORS_HELI_RSC_MODE_NONE) {
            _rotor_out = 0;
            _rotor_speed_estimate = 0;
            write_rsc(_rotor_out);
        }
        return;
    }

    // ramp up or down main rotor and tail
    if (_rotor_desired > 0) {
        // ramp up tail rotor (this does nothing if not using direct drive variable pitch tail)
        tail_ramp(_direct_drive_tailspeed);
        // note: this always returns true if not using direct drive variable pitch tail
        if (tail_rotor_runup_complete()) {
            rotor_ramp(_rotor_desired);
        }
    }else{
        // shutting down main rotor
        rotor_ramp(0);
        // if completed shutting down main motor then shut-down tail rotor.  Note: this does nothing if not using direct drive vairable pitch tail
        if (_rotor_speed_estimate <= 0) {
            tail_ramp(0);
        }
    }

    // direct drive fixed pitch tail servo gets copy of yaw servo out (ch4) while main rotor is running
    if (_tail_type == AP_MOTORS_HELI_TAILTYPE_DIRECTDRIVE_FIXEDPITCH) {
        // output fixed-pitch speed control if Ch8 is high
        if (_rotor_desired > 0 || _rotor_speed_estimate > 0) {
            // copy yaw output to tail esc
            write_aux(_servo_4->servo_out);
        }else{
            write_aux(0);
        }
    }
}
コード例 #23
0
// output_test_num - spin a motor connected to the specified output channel
//  (should only be performed during testing)
//  If a motor output channel is remapped, the mapped channel is used.
//  Returns true if motor output is set, false otherwise
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
bool AP_MotorsMatrix::output_test_num(uint8_t output_channel, int16_t pwm)
{
    if (!armed()) {
        return false;
    }

    // Is channel in supported range?
    if (output_channel > AP_MOTORS_MAX_NUM_MOTORS -1) {
        return false;
    }

    // Is motor enabled?
    if (!motor_enabled[output_channel]) {
        return false;
    }

    rc_write(output_channel, pwm); // output
    return true;
}
コード例 #24
0
// output_test_seq - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsHeli_Dual::output_test_seq(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // output to motors and servos
    switch (motor_seq) {
    case 1:
        // swash servo 1
        rc_write(AP_MOTORS_MOT_1, pwm);
        break;
    case 2:
        // swash servo 2
        rc_write(AP_MOTORS_MOT_2, pwm);
        break;
    case 3:
        // swash servo 3
        rc_write(AP_MOTORS_MOT_3, pwm);
        break;
    case 4:
        // swash servo 4
        rc_write(AP_MOTORS_MOT_4, pwm);
        break;
    case 5:
        // swash servo 5
        rc_write(AP_MOTORS_MOT_5, pwm);
        break;
    case 6:
        // swash servo 6
        rc_write(AP_MOTORS_MOT_6, pwm);
        break;
    case 7:
        // main rotor
        rc_write(AP_MOTORS_HELI_DUAL_RSC, pwm);
        break;
    default:
        // do nothing
        break;
    }
}
コード例 #25
0
ファイル: motor.c プロジェクト: The-Red/RedCopter
/****************************************
 * Internal Functions
 ****************************************/
static uint16_t motorEscLimit(uint16_t rawData) {
  uint16_t duty;
  if (armed()) {
    if (rawData >= ESC_ARM_DUTY) {
      if (rawData <= ESC_MAX_DUTY)
        // ARM, ARM_DUTY <= duty <= ESC_MAX_DUTY
        duty = rawData;
      else
        // ARM, ARM_DUTY < ESC_MAX_DUTY < duty
        duty = ESC_MAX_DUTY;
    }
    else
      // ARM, duty < ARM_DUTY
      duty = ESC_ARM_DUTY;
  }
  else
    // Darmed
    duty = ESC_DISARM_DUTY;
  return duty;
}
コード例 #26
0
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsHeli_Single::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // output to motors and servos
    switch (motor_seq) {
        case 1:
            // swash servo 1
            rc_write(AP_MOTORS_MOT_1, pwm);
            break;
        case 2:
            // swash servo 2
            rc_write(AP_MOTORS_MOT_2, pwm);
            break;
        case 3:
            // swash servo 3
            rc_write(AP_MOTORS_MOT_3, pwm);
            break;
        case 4:
            // external gyro & tail servo
            if (_tail_type == AP_MOTORS_HELI_SINGLE_TAILTYPE_SERVO_EXTGYRO) {
                if (_acro_tail && _ext_gyro_gain_acro > 0) {
                    write_aux(_ext_gyro_gain_acro/1000.0f);
                } else {
                    write_aux(_ext_gyro_gain_std/1000.0f);
                }
            }
            rc_write(AP_MOTORS_MOT_4, pwm);
            break;
        case 5:
            // main rotor
            rc_write(AP_MOTORS_HELI_SINGLE_RSC, pwm);
            break;
        default:
            // do nothing
            break;
    }
}
コード例 #27
0
// output_test - spin a motor at the pwm value specified
//  motor_seq is the motor's sequence number from 1 to the number of motors on the frame
//  pwm value is an actual pwm value that will be output, normally in the range of 1000 ~ 2000
void AP_MotorsHeli::output_test(uint8_t motor_seq, int16_t pwm)
{
    // exit immediately if not armed
    if (!armed()) {
        return;
    }

    // output to motors and servos
    switch (motor_seq) {
        case 1:
            // swash servo 1
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[AP_MOTORS_MOT_1]), pwm);
            break;
        case 2:
            // swash servo 2
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[AP_MOTORS_MOT_2]), pwm);
            break;
        case 3:
            // swash servo 3
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[AP_MOTORS_MOT_3]), pwm);
            break;
        case 4:
            // external gyro & tail servo
            if (_tail_type == AP_MOTORS_HELI_TAILTYPE_SERVO_EXTGYRO) {
                write_aux(_ext_gyro_gain);
            }
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[AP_MOTORS_MOT_4]), pwm);
            break;
        case 5:
            // main rotor
            hal.rcout->write(pgm_read_byte(&_motor_to_channel_map[AP_MOTORS_HELI_RSC]), pwm);
            break;
        default:
            // do nothing
            break;
    }
}
コード例 #28
0
ファイル: AP_MotorsHeli.cpp プロジェクト: AhLeeYong/x-drone
void AP_MotorsHeli::rsc_control() {
    switch ( rsc_mode ) {

    case AP_MOTORSHELI_RSC_MODE_CH8_PASSTHROUGH:
        if( armed() && (_rc_8->radio_in > (_rc_8->radio_min + 10))) {
            if (rsc_ramp < rsc_ramp_up_rate) {
                rsc_ramp++;
                rsc_output = map(rsc_ramp, 0, rsc_ramp_up_rate, _rc_8->radio_min, _rc_8->radio_in);
            } else {
                rsc_output = _rc_8->radio_in;
            }
        } else {
			rsc_ramp--;                                                 //Return RSC Ramp to 0 slowly, allowing for "warm restart"
			if (rsc_ramp < 0) {
                rsc_ramp = 0;
			}
			rsc_output = _rc_8->radio_min;
        }
        hal.rcout->write(AP_MOTORS_HELI_EXT_RSC, rsc_output);
        break;

    case AP_MOTORSHELI_RSC_MODE_EXT_GOV:

        if( armed() && _rc_8->control_in > 100) {
            if (rsc_ramp < rsc_ramp_up_rate) {
                rsc_ramp++;
                rsc_output = map(rsc_ramp, 0, rsc_ramp_up_rate, 1000, ext_gov_setpoint);
            } else {
                rsc_output = ext_gov_setpoint;
            }
        } else {
            rsc_ramp--;                                                 //Return RSC Ramp to 0 slowly, allowing for "warm restart"
            if (rsc_ramp < 0) {
                rsc_ramp = 0;
            }
            rsc_output = 1000;                                  //Just to be sure RSC output is 0
        }
        hal.rcout->write(AP_MOTORS_HELI_EXT_RSC, rsc_output);
        break;

    //	case 3:																		// Open Loop ESC Control
    //
    //	coll_scaled = _motors->coll_out_scaled + 1000;
    //	if(coll_scaled <= _motors->collective_mid){
    //		esc_ol_output = map(coll_scaled, _motors->collective_min, _motors->collective_mid, esc_out_low, esc_out_mid);		// Bottom half of V-curve
    //	} else if (coll_scaled > _motors->collective_mid){
    //		esc_ol_output = map(coll_scaled, _motors->collective_mid, _motors->collective_max, esc_out_mid, esc_out_high);		// Top half of V-curve
    //	} else { esc_ol_output = 1000; }																									// Just in case.
    //
    //	if(_motors->armed() && _rc_throttle->control_in > 10){
    //			if (ext_esc_ramp < ext_esc_ramp_up){
    //				ext_esc_ramp++;
    //				ext_esc_output = map(ext_esc_ramp, 0, ext_esc_ramp_up, 1000, esc_ol_output);
    //			} else {
    //				ext_esc_output = esc_ol_output;
    //			}
    //		} else {
    //			ext_esc_ramp = 0;	//Return ESC Ramp to 0
    //			ext_esc_output = 1000; //Just to be sure ESC output is 0
    //}
    //		hal.rcout->write(AP_MOTORS_HELI_EXT_ESC, ext_esc_output);
    //	break;


    default:
        break;
    }
};
コード例 #29
0
ファイル: Track.C プロジェクト: shanipribadi/non
void
Track::set ( Log_Entry &e )
{
    for ( int i = 0; i < e.size(); ++i )
    {
        const char *s, *v;

        e.get( i, &s, &v );

        if ( ! strcmp( s, ":height" ) )
        {
            size( atoi( v ) );
            adjust_size();
        }
        else if ( ! strcmp( s, ":selected" ) )
            _selected = atoi( v );
//                else if ( ! strcmp( s, ":armed"
        else if ( ! strcmp( s, ":name" ) )
            name( v );
        else if ( ! strcmp( s, ":inputs" ) )
            configure_inputs( atoi( v ) );
        else if ( ! strcmp( s, ":outputs" ) )
            configure_outputs( atoi( v ) );
        else if ( ! strcmp( s, ":color" ) )
        {
            color( (Fl_Color)atoll( v ) );
            redraw();
        }
        else if ( ! strcmp( s, ":show-all-takes" ) )
            show_all_takes( atoi( v ) );
        else if ( ! strcmp( s, ":overlay-controls" ) )
            overlay_controls( atoi( v ) );
        else if ( ! strcmp( s, ":solo" ) )
            solo( atoi( v ) );
        else if ( ! strcmp( s, ":mute" ) )
            mute( atoi( v ) );
        else if ( ! strcmp( s, ":arm" ) )
            armed( atoi( v ) );
        else if ( ! strcmp( s, ":sequence" ) )
        {
            int i;
            sscanf( v, "%X", &i );

            if ( i )
            {
                Audio_Sequence *t = (Audio_Sequence*)Loggable::find( i );

                /* FIXME: our track might not have been
                 * defined yet... what should we do about this
                 * chicken/egg problem? */
                if ( t )
                {
//                        assert( t );

                    sequence( t );
                }

            }

        }
        else if ( ! strcmp( s, ":row" ) )
            row( atoi( v ) );
    }
}
コード例 #30
0
ファイル: Track.C プロジェクト: shanipribadi/non
void
Track::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "Picked: %s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Type/Mono" ) )
    {
        command_configure_channels( 1 );
    }
    else if ( ! strcmp( picked, "Type/Stereo" ) )
    {
        command_configure_channels( 2 );
    }
    else if ( ! strcmp( picked, "Type/Quad" ) )
    {
        command_configure_channels( 4 );
    }
    else if ( ! strcmp( picked, "Type/..." ) )
    {
        const char *s = fl_input( "How many channels?", "3" );
        if ( s )
        {

            int c = atoi( s );

            if ( c <= 0 || c > 10 )
                fl_alert( "Invalid number of channels." );
            else
            {
                command_configure_channels(c);
            }
        }
    }
    else if ( ! strcmp( picked, "/Add Control" ) )
    {
        /* add audio track */
        char *name = get_unique_control_name( "Control" );

        timeline->wrlock();
        new Control_Sequence( this, name );
        timeline->unlock();
    }
    else if ( ! strcmp( picked, "/Overlay controls" ) )
    {
        overlay_controls( ! m->mvalue()->value() );
    }
    else if ( ! strcmp( picked, "/Add Annotation" ) )
    {
        add( new Annotation_Sequence( this ) );
    }
    else if ( ! strcmp( picked, "/Color" ) )
    {
        unsigned char r, g, b;

        Fl::get_color( color(), r, g, b );

        if ( fl_color_chooser( "Track Color", r, g, b ) )
        {
            color( fl_rgb_color( r, g, b ) );
        }

        redraw();
    }
    else if ( ! strcmp( picked, "Flags/Record" ) )
    {
        armed( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Mute" ) )
    {
        mute( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Flags/Solo" ) )
    {
        solo( m->mvalue()->flags & FL_MENU_VALUE );
    }
    else if ( ! strcmp( picked, "Size/Small" ) )
    {
        size( 0 );
    }
    else if ( ! strcmp( picked, "Size/Medium" ) )
    {
        size( 1 );
    }
    else if ( ! strcmp( picked, "Size/Large" ) )
    {
        size( 2 );
    }
    else if ( ! strcmp( picked, "Size/Huge" ) )
    {
        size( 3 );
    }
    else if ( ! strcmp( picked, "/Remove" ) )
    {
        int r = fl_choice( "Are you certain you want to remove track \"%s\"?", "Cancel", NULL, "Remove", name() );

        if ( r == 2 )
        {
            timeline->command_remove_track( this );
             Fl::delete_widget( this );
        }
    }
    else if ( ! strcmp( picked, "/Rename" ) )
    {
        ((Fl_Sometimes_Input*)name_field)->take_focus();
    }
    else if ( ! strcmp( picked, "/Move Up" ) )
    {
        timeline->command_move_track_up( this );
    }
    else if ( ! strcmp( picked, "/Move Down" ) )
    {
        timeline->command_move_track_down( this );
    }
    else if ( !strcmp( picked, "Takes/Show all takes" ) )
    {
        show_all_takes( ! m->mvalue()->value() );
    }
    else if ( !strcmp( picked, "Takes/New" ) )
    {
        timeline->wrlock();
        sequence( (Audio_Sequence*)sequence()->clone_empty() );
        timeline->unlock();
    }
    else if ( !strcmp( picked, "Takes/Remove" ) )
    {
            if ( takes->children() )
            {
                Loggable::block_start();

                timeline->wrlock();

                Audio_Sequence *s = sequence();

                sequence( (Audio_Sequence*)takes->child( 0 ) );

                delete s;

                timeline->unlock();

                Loggable::block_end();
            }
    }
    else if ( !strcmp( picked, "Takes/Remove others" ))
    {
        if ( takes->children() )
            {
                Loggable::block_start();

                takes->clear();

                Loggable::block_end();
            }
    }
    else if ( !strncmp( picked, "Takes/", sizeof( "Takes/" ) - 1 ) )
    {
        Audio_Sequence* s = (Audio_Sequence*)m->mvalue()->user_data();

        timeline->wrlock();
        sequence( s );
        timeline->unlock();
    }
}