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


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

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


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

示例1: warnx


//.........这里部分代码省略.........
                    att_sp.thrust = throttle_sp;

                    /* lazily publish the setpoint only once available */
                    if (_attitude_sp_pub > 0) {
                        /* publish the attitude setpoint */
                        orb_publish(ORB_ID(vehicle_attitude_setpoint), _attitude_sp_pub, &att_sp);

                    } else {
                        /* advertise and publish */
                        _attitude_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &att_sp);
                    }
                }

                /* Prepare speed_body_u and speed_body_w */
                float speed_body_u = 0.0f;
                float speed_body_v = 0.0f;
                float speed_body_w = 0.0f;
                if(_att.R_valid) 	{
                    speed_body_u = _att.R[0][0] * _global_pos.vel_n + _att.R[1][0] * _global_pos.vel_e + _att.R[2][0] * _global_pos.vel_d;
                    speed_body_v = _att.R[0][1] * _global_pos.vel_n + _att.R[1][1] * _global_pos.vel_e + _att.R[2][1] * _global_pos.vel_d;
                    speed_body_w = _att.R[0][2] * _global_pos.vel_n + _att.R[1][2] * _global_pos.vel_e + _att.R[2][2] * _global_pos.vel_d;
                } else	{
                    if (loop_counter % 10 == 0) {
                        warnx("Did not get a valid R\n");
                    }
                }

                /* Run attitude controllers */
                if (isfinite(roll_sp) && isfinite(pitch_sp)) {
                    _roll_ctrl.control_attitude(roll_sp, _att.roll);
                    _pitch_ctrl.control_attitude(pitch_sp, _att.roll, _att.pitch, airspeed);
                    _yaw_ctrl.control_attitude(_att.roll, _att.pitch,
                                               speed_body_u, speed_body_v, speed_body_w,
                                               _roll_ctrl.get_desired_rate(), _pitch_ctrl.get_desired_rate()); //runs last, because is depending on output of roll and pitch attitude

                    /* Run attitude RATE controllers which need the desired attitudes from above, add trim */
                    float roll_u = _roll_ctrl.control_bodyrate(_att.pitch,
                                   _att.rollspeed, _att.yawspeed,
                                   _yaw_ctrl.get_desired_rate(),
                                   _parameters.airspeed_min, _parameters.airspeed_max, airspeed, airspeed_scaling, lock_integrator);
                    _actuators.control[0] = (isfinite(roll_u)) ? roll_u + _parameters.trim_roll : _parameters.trim_roll;
                    if (!isfinite(roll_u)) {
                        _roll_ctrl.reset_integrator();
                        perf_count(_nonfinite_output_perf);

                        if (loop_counter % 10 == 0) {
                            warnx("roll_u %.4f", (double)roll_u);
                        }
                    }

                    float pitch_u = _pitch_ctrl.control_bodyrate(_att.roll, _att.pitch,
                                    _att.pitchspeed, _att.yawspeed,
                                    _yaw_ctrl.get_desired_rate(),
                                    _parameters.airspeed_min, _parameters.airspeed_max, airspeed, airspeed_scaling, lock_integrator);
                    _actuators.control[1] = (isfinite(pitch_u)) ? pitch_u + _parameters.trim_pitch : _parameters.trim_pitch;
                    if (!isfinite(pitch_u)) {
                        _pitch_ctrl.reset_integrator();
                        perf_count(_nonfinite_output_perf);
                        if (loop_counter % 10 == 0) {
                            warnx("pitch_u %.4f, _yaw_ctrl.get_desired_rate() %.4f,"
                                  " airspeed %.4f, airspeed_scaling %.4f,"
                                  " roll_sp %.4f, pitch_sp %.4f,"
                                  " _roll_ctrl.get_desired_rate() %.4f,"
                                  " _pitch_ctrl.get_desired_rate() %.4f"
                                  " att_sp.roll_body %.4f",
                                  (double)pitch_u, (double)_yaw_ctrl.get_desired_rate(),
开发者ID:KjeldJensen,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp

示例2: q_att


//.........这里部分代码省略.........
				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;
				control_input.yaw = _yaw;
				control_input.body_x_rate = _att.rollspeed;
				control_input.body_y_rate = _att.pitchspeed;
				control_input.body_z_rate = _att.yawspeed;
				control_input.roll_setpoint = roll_sp;
				control_input.pitch_setpoint = pitch_sp;
				control_input.yaw_setpoint = yaw_sp;
				control_input.airspeed_min = _parameters.airspeed_min;
				control_input.airspeed_max = _parameters.airspeed_max;
				control_input.airspeed = airspeed;
				control_input.scaler = airspeed_scaling;
				control_input.lock_integrator = lock_integrator;
				control_input.groundspeed = groundspeed;
				control_input.groundspeed_scaler = groundspeed_scaler;

				/* Run attitude controllers */
				if (_vcontrol_mode.flag_control_attitude_enabled) {
					if (PX4_ISFINITE(roll_sp) && PX4_ISFINITE(pitch_sp)) {
						_roll_ctrl.control_attitude(control_input);
						_pitch_ctrl.control_attitude(control_input);
						_yaw_ctrl.control_attitude(control_input); //runs last, because is depending on output of roll and pitch attitude
						_wheel_ctrl.control_attitude(control_input);

						/* Update input data for rate controllers */
						control_input.roll_rate_setpoint = _roll_ctrl.get_desired_rate();
						control_input.pitch_rate_setpoint = _pitch_ctrl.get_desired_rate();
						control_input.yaw_rate_setpoint = _yaw_ctrl.get_desired_rate();

						/* Run attitude RATE controllers which need the desired attitudes from above, add trim */
						float roll_u = _roll_ctrl.control_euler_rate(control_input);
						_actuators.control[actuator_controls_s::INDEX_ROLL] = (PX4_ISFINITE(roll_u)) ? roll_u + _parameters.trim_roll :
								_parameters.trim_roll;

						if (!PX4_ISFINITE(roll_u)) {
							_roll_ctrl.reset_integrator();
							perf_count(_nonfinite_output_perf);

							if (_debug && loop_counter % 10 == 0) {
								warnx("roll_u %.4f", (double)roll_u);
							}
						}

						float pitch_u = _pitch_ctrl.control_euler_rate(control_input);
						_actuators.control[actuator_controls_s::INDEX_PITCH] = (PX4_ISFINITE(pitch_u)) ? pitch_u + _parameters.trim_pitch :
								_parameters.trim_pitch;

						if (!PX4_ISFINITE(pitch_u)) {
							_pitch_ctrl.reset_integrator();
							perf_count(_nonfinite_output_perf);

							if (_debug && loop_counter % 10 == 0) {
								warnx("pitch_u %.4f, _yaw_ctrl.get_desired_rate() %.4f,"
								      " airspeed %.4f, airspeed_scaling %.4f,"
								      " roll_sp %.4f, pitch_sp %.4f,"
								      " _roll_ctrl.get_desired_rate() %.4f,"
								      " _pitch_ctrl.get_desired_rate() %.4f"
								      " att_sp.roll_body %.4f",
开发者ID:larics,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp

示例3: poll


//.........这里部分代码省略.........
						warnx("Did not get a valid R\n");
					}
				}

				/* Prepare data for attitude controllers */
				struct ECL_ControlData control_input = {};
				control_input.roll = _att.roll;
				control_input.pitch = _att.pitch;
				control_input.yaw = _att.yaw;
				control_input.roll_rate = _att.rollspeed;
				control_input.pitch_rate = _att.pitchspeed;
				control_input.yaw_rate = _att.yawspeed;
				control_input.speed_body_u = speed_body_u;
				control_input.speed_body_v = speed_body_v;
				control_input.speed_body_w = speed_body_w;
				control_input.acc_body_x = _accel.x;
				control_input.acc_body_y = _accel.y;
				control_input.acc_body_z = _accel.z;
				control_input.roll_setpoint = roll_sp;
				control_input.pitch_setpoint = pitch_sp;
				control_input.airspeed_min = _parameters.airspeed_min;
				control_input.airspeed_max = _parameters.airspeed_max;
				control_input.airspeed = airspeed;
				control_input.scaler = airspeed_scaling;
				control_input.lock_integrator = lock_integrator;

				/* Run attitude controllers */
				if (isfinite(roll_sp) && isfinite(pitch_sp)) {
					_roll_ctrl.control_attitude(control_input);
					_pitch_ctrl.control_attitude(control_input);
					_yaw_ctrl.control_attitude(control_input); //runs last, because is depending on output of roll and pitch attitude

					/* Update input data for rate controllers */
					control_input.roll_rate_setpoint = _roll_ctrl.get_desired_rate();
					control_input.pitch_rate_setpoint = _pitch_ctrl.get_desired_rate();
					control_input.yaw_rate_setpoint = _yaw_ctrl.get_desired_rate();

					/* Run attitude RATE controllers which need the desired attitudes from above, add trim */
					float roll_u = _roll_ctrl.control_bodyrate(control_input);
					_actuators.control[0] = (isfinite(roll_u)) ? roll_u + _parameters.trim_roll : _parameters.trim_roll;
					if (!isfinite(roll_u)) {
						_roll_ctrl.reset_integrator();
						perf_count(_nonfinite_output_perf);

						if (_debug && loop_counter % 10 == 0) {
							warnx("roll_u %.4f", (double)roll_u);
						}
					}

					float pitch_u = _pitch_ctrl.control_bodyrate(control_input);
					_actuators.control[1] = (isfinite(pitch_u)) ? pitch_u + _parameters.trim_pitch : _parameters.trim_pitch;
					if (!isfinite(pitch_u)) {
						_pitch_ctrl.reset_integrator();
						perf_count(_nonfinite_output_perf);
						if (_debug && loop_counter % 10 == 0) {
							warnx("pitch_u %.4f, _yaw_ctrl.get_desired_rate() %.4f,"
								" airspeed %.4f, airspeed_scaling %.4f,"
								" roll_sp %.4f, pitch_sp %.4f,"
								" _roll_ctrl.get_desired_rate() %.4f,"
								" _pitch_ctrl.get_desired_rate() %.4f"
								" att_sp.roll_body %.4f",
								(double)pitch_u, (double)_yaw_ctrl.get_desired_rate(),
								(double)airspeed, (double)airspeed_scaling,
								(double)roll_sp, (double)pitch_sp,
								(double)_roll_ctrl.get_desired_rate(),
								(double)_pitch_ctrl.get_desired_rate(),
开发者ID:harvard-uas,项目名称:Firmware,代码行数:67,代码来源:fw_att_control_main.cpp


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