当前位置: 首页>>代码示例>>C++>>正文


C++ ECL_RollController::reset_integrator方法代码示例

本文整理汇总了C++中ECL_RollController::reset_integrator方法的典型用法代码示例。如果您正苦于以下问题:C++ ECL_RollController::reset_integrator方法的具体用法?C++ ECL_RollController::reset_integrator怎么用?C++ ECL_RollController::reset_integrator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ECL_RollController的用法示例。


在下文中一共展示了ECL_RollController::reset_integrator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: warnx


//.........这里部分代码省略.........
                /* if airspeed is not updating, we assume the normal average speed */
                if (bool nonfinite = !isfinite(_airspeed.true_airspeed_m_s) ||
                                     hrt_elapsed_time(&_airspeed.timestamp) > 1e6) {
                    airspeed = _parameters.airspeed_trim;
                    if (nonfinite) {
                        perf_count(_nonfinite_input_perf);
                    }
                } else {
                    airspeed = _airspeed.true_airspeed_m_s;
                }

                /*
                 * For scaling our actuators using anything less than the min (close to stall)
                 * speed doesn't make any sense - its the strongest reasonable deflection we
                 * want to do in flight and its the baseline a human pilot would choose.
                 *
                 * Forcing the scaling to this value allows reasonable handheld tests.
                 */

                float airspeed_scaling = _parameters.airspeed_trim / ((airspeed < _parameters.airspeed_min) ? _parameters.airspeed_min : airspeed);

                float roll_sp = _parameters.rollsp_offset_rad;
                float pitch_sp = _parameters.pitchsp_offset_rad;
                float throttle_sp = 0.0f;

                if (_vcontrol_mode.flag_control_velocity_enabled || _vcontrol_mode.flag_control_position_enabled) {
                    /* read in attitude setpoint from attitude setpoint uorb topic */
                    roll_sp = _att_sp.roll_body + _parameters.rollsp_offset_rad;
                    pitch_sp = _att_sp.pitch_body + _parameters.pitchsp_offset_rad;
                    throttle_sp = _att_sp.thrust;

                    /* reset integrals where needed */
                    if (_att_sp.roll_reset_integral) {
                        _roll_ctrl.reset_integrator();
                    }
                    if (_att_sp.pitch_reset_integral) {
                        _pitch_ctrl.reset_integrator();
                    }
                    if (_att_sp.yaw_reset_integral) {
                        _yaw_ctrl.reset_integrator();
                    }
                } else {
                    /*
                     * Scale down roll and pitch as the setpoints are radians
                     * and a typical remote can only do around 45 degrees, the mapping is
                     * -1..+1 to -man_roll_max rad..+man_roll_max rad (equivalent for pitch)
                     *
                     * With this mapping the stick angle is a 1:1 representation of
                     * the commanded attitude.
                     *
                     * The trim gets subtracted here from the manual setpoint to get
                     * the intended attitude setpoint. Later, after the rate control step the
                     * trim is added again to the control signal.
                     */
                    roll_sp = (_manual.y * _parameters.man_roll_max - _parameters.trim_roll)
                              + _parameters.rollsp_offset_rad;
                    pitch_sp = -(_manual.x * _parameters.man_pitch_max - _parameters.trim_pitch)
                               + _parameters.pitchsp_offset_rad;
                    throttle_sp = _manual.z;
                    _actuators.control[4] = _manual.flaps;

                    /*
                     * in manual mode no external source should / does emit attitude setpoints.
                     * emit the manual setpoint here to allow attitude controller tuning
                     * in attitude control mode.
                     */
开发者ID:KjeldJensen,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp

示例2: q_att


//.........这里部分代码省略.........
				 */
				float airspeed_scaling = _parameters.airspeed_trim / ((airspeed < _parameters.airspeed_min) ? _parameters.airspeed_min :
							 airspeed);

				/* Use min airspeed to calculate ground speed scaling region.
				 * Don't scale below gspd_scaling_trim
				 */
				float groundspeed = sqrtf(_global_pos.vel_n * _global_pos.vel_n +
							  _global_pos.vel_e * _global_pos.vel_e);
				float gspd_scaling_trim = (_parameters.airspeed_min * 0.6f);
				float groundspeed_scaler = gspd_scaling_trim / ((groundspeed < gspd_scaling_trim) ? gspd_scaling_trim : groundspeed);

				// in STABILIZED mode we need to generate the attitude setpoint
				// from manual user inputs
				if (!_vcontrol_mode.flag_control_climb_rate_enabled && !_vcontrol_mode.flag_control_offboard_enabled) {
					_att_sp.timestamp = hrt_absolute_time();
					_att_sp.roll_body = _manual.y * _parameters.man_roll_max + _parameters.rollsp_offset_rad;
					_att_sp.roll_body = math::constrain(_att_sp.roll_body, -_parameters.man_roll_max, _parameters.man_roll_max);
					_att_sp.pitch_body = -_manual.x * _parameters.man_pitch_max + _parameters.pitchsp_offset_rad;
					_att_sp.pitch_body = math::constrain(_att_sp.pitch_body, -_parameters.man_pitch_max, _parameters.man_pitch_max);
					_att_sp.yaw_body = 0.0f;
					_att_sp.thrust = _manual.z;

					Quatf q(Eulerf(_att_sp.roll_body, _att_sp.pitch_body, _att_sp.yaw_body));
					q.copyTo(_att_sp.q_d);
					_att_sp.q_d_valid = true;

					int instance;
					orb_publish_auto(_attitude_setpoint_id, &_attitude_sp_pub, &_att_sp, &instance, ORB_PRIO_DEFAULT);
				}

				/* reset integrals where needed */
				if (_att_sp.roll_reset_integral) {
					_roll_ctrl.reset_integrator();
				}

				if (_att_sp.pitch_reset_integral) {
					_pitch_ctrl.reset_integrator();
				}

				if (_att_sp.yaw_reset_integral) {
					_yaw_ctrl.reset_integrator();
					_wheel_ctrl.reset_integrator();
				}

				/* Reset integrators if the aircraft is on ground
				 * or a multicopter (but not transitioning VTOL)
				 */
				if (_vehicle_land_detected.landed
				    || (_vehicle_status.is_rotary_wing && !_vehicle_status.in_transition_mode)) {

					_roll_ctrl.reset_integrator();
					_pitch_ctrl.reset_integrator();
					_yaw_ctrl.reset_integrator();
					_wheel_ctrl.reset_integrator();
				}

				float roll_sp = _att_sp.roll_body;
				float pitch_sp = _att_sp.pitch_body;
				float yaw_sp = _att_sp.yaw_body;
				float throttle_sp = _att_sp.thrust;

				/* Prepare data for attitude controllers */
				struct ECL_ControlData control_input = {};
				control_input.roll = _roll;
				control_input.pitch = _pitch;
开发者ID:larics,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp

示例3: poll


//.........这里部分代码省略.........
					/* prevent numerical drama by requiring 0.5 m/s minimal speed */
					airspeed = math::max(0.5f, _airspeed.true_airspeed_m_s);
				}

				/*
				 * For scaling our actuators using anything less than the min (close to stall)
				 * speed doesn't make any sense - its the strongest reasonable deflection we
				 * want to do in flight and its the baseline a human pilot would choose.
				 *
				 * Forcing the scaling to this value allows reasonable handheld tests.
				 */

				float airspeed_scaling = _parameters.airspeed_trim / ((airspeed < _parameters.airspeed_min) ? _parameters.airspeed_min : airspeed);

				float roll_sp = _parameters.rollsp_offset_rad;
				float pitch_sp = _parameters.pitchsp_offset_rad;
				float yaw_manual = 0.0f;
				float throttle_sp = 0.0f;

				/* Read attitude setpoint from uorb if
				 * - velocity control or position control is enabled (pos controller is running)
				 * - manual control is disabled (another app may send the setpoint, but it should
				 *   for sure not be set from the remote control values)
				 */
				if (_vcontrol_mode.flag_control_auto_enabled ||
						!_vcontrol_mode.flag_control_manual_enabled) {
					/* read in attitude setpoint from attitude setpoint uorb topic */
					roll_sp = _att_sp.roll_body + _parameters.rollsp_offset_rad;
					pitch_sp = _att_sp.pitch_body + _parameters.pitchsp_offset_rad;
					throttle_sp = _att_sp.thrust;

					/* reset integrals where needed */
					if (_att_sp.roll_reset_integral) {
						_roll_ctrl.reset_integrator();
					}
					if (_att_sp.pitch_reset_integral) {
						_pitch_ctrl.reset_integrator();
					}
					if (_att_sp.yaw_reset_integral) {
						_yaw_ctrl.reset_integrator();
					}
				} else if (_vcontrol_mode.flag_control_velocity_enabled) {

					/* the pilot does not want to change direction,
					 * take straight attitude setpoint from position controller
					 */
					if (fabsf(_manual.y) < 0.01f && fabsf(_att.roll) < 0.2f) {
						roll_sp = _att_sp.roll_body + _parameters.rollsp_offset_rad;
					} else {
						roll_sp = (_manual.y * _parameters.man_roll_max)
								+ _parameters.rollsp_offset_rad;
					}

					pitch_sp = _att_sp.pitch_body + _parameters.pitchsp_offset_rad;
					throttle_sp = _att_sp.thrust;

					/* reset integrals where needed */
					if (_att_sp.roll_reset_integral) {
						_roll_ctrl.reset_integrator();
					}
					if (_att_sp.pitch_reset_integral) {
						_pitch_ctrl.reset_integrator();
					}
					if (_att_sp.yaw_reset_integral) {
						_yaw_ctrl.reset_integrator();
					}
开发者ID:harvard-uas,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp


注:本文中的ECL_RollController::reset_integrator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。