130 wind_ = Eigen::Vector3d::Zero();
135 delta_.
a = (act_cmds[0] - 1500.0) / 500.0;
136 delta_.
e = -(act_cmds[1] - 1500.0) / 500.0;
137 delta_.
t = (act_cmds[2] - 1000.0) / 1000.0;
138 delta_.
r = -(act_cmds[3] - 1500.0) / 500.0;
140 double p = x.
omega(0);
141 double q = x.
omega(1);
142 double r = x.
omega(2);
145 Eigen::Vector3d V_airspeed = x.
vel + x.
rot.inverse() *
wind_;
146 double ur = V_airspeed(0);
147 double vr = V_airspeed(1);
148 double wr = V_airspeed(2);
150 double Va = V_airspeed.norm();
152 Eigen::Matrix<double, 6, 1> forces;
155 if (Va > 1.0 && std::isfinite(Va))
163 double alpha =
atan2(wr, ur);
164 double beta =
asin(vr / Va);
166 double ca =
cos(alpha);
167 double sa =
sin(alpha);
169 double sign = (alpha >= 0 ? 1 : -1);
172 double CL_a = (1 - sigma_a) * (
CL_.
O +
CL_.
alpha * alpha) + sigma_a * (2 * sign * sa * sa * ca);
180 double CX_a = -CD_a * ca + CL_a * sa;
181 double CX_q_a = -
CD_.
q * ca +
CL_.
q * sa;
184 double CZ_a = -CD_a * sa - CL_a * ca;
185 double CZ_q_a = -
CD_.
q * sa -
CL_.
q * ca;
188 forces(0) = 0.5 * (
rho_)*Va * Va *
wing_.
S * (CX_a + (CX_q_a *
wing_.
c * q) / (2.0 * Va) + CX_deltaE_a *
delta_.
e)
193 forces(2) = 0.5 * (
rho_)*Va * Va *
wing_.
S * (CZ_a + (CZ_q_a *
wing_.
c * q) / (2.0 * Va) + CZ_deltaE_a *
delta_.
e);
float atan2(float y, float x)
Eigen::Matrix< double, 6, 1 > updateForcesAndTorques(Current_State x, const int act_cmds[])
void set_wind(Eigen::Vector3d wind)
Fixedwing(ros::NodeHandle *nh)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
struct rosflight_sim::Fixedwing::PropCoeff prop_
struct rosflight_sim::Fixedwing::Actuators delta_
struct rosflight_sim::Fixedwing::WingCoeff wing_