SITL: support fireflyY6 quadplane model

This commit is contained in:
Andrew Tridgell 2016-04-22 10:26:37 +10:00
parent 8880635fe1
commit aa80851138
3 changed files with 13 additions and 6 deletions

View File

@ -36,10 +36,11 @@ void Motor::calculate_forces(const Aircraft::sitl_input &input,
thrust(0, 0, motor_speed * thrust_scale); // newtons
if (roll_servo >= 0) {
float roll;
uint16_t servoval = input.servos[roll_servo+motor_offset];
if (roll_min < roll_max) {
roll = constrain_float(roll_min + (input.servos[roll_servo]-1000)*0.001*(roll_max-roll_min), roll_min, roll_max);
roll = constrain_float(roll_min + (servoval-1000)*0.001*(roll_max-roll_min), roll_min, roll_max);
} else {
roll = constrain_float(roll_max + (2000-input.servos[roll_servo])*0.001*(roll_min-roll_max), roll_max, roll_min);
roll = constrain_float(roll_max + (2000-servoval)*0.001*(roll_min-roll_max), roll_max, roll_min);
}
Matrix3f rotation;
rotation.from_euler(radians(roll), 0, 0);
@ -48,10 +49,11 @@ void Motor::calculate_forces(const Aircraft::sitl_input &input,
}
if (pitch_servo >= 0) {
float pitch;
uint16_t servoval = input.servos[pitch_servo+motor_offset];
if (pitch_min < pitch_max) {
pitch = constrain_float(pitch_min + (input.servos[pitch_servo]-1000)*0.001*(pitch_max-pitch_min), pitch_min, pitch_max);
pitch = constrain_float(pitch_min + (servoval-1000)*0.001*(pitch_max-pitch_min), pitch_min, pitch_max);
} else {
pitch = constrain_float(pitch_max + (2000-input.servos[pitch_servo])*0.001*(pitch_min-pitch_max), pitch_max, pitch_min);
pitch = constrain_float(pitch_max + (2000-servoval)*0.001*(pitch_min-pitch_max), pitch_max, pitch_min);
}
Matrix3f rotation;
rotation.identity();

View File

@ -238,7 +238,9 @@ void Plane::calculate_forces(const struct sitl_input &input, Vector3f &rot_accel
accel_body += force;
// add some noise
add_noise(fabsf(thrust) / thrust_scale);
if (thrust_scale > 0) {
add_noise(fabsf(thrust) / thrust_scale);
}
}
/*

View File

@ -45,9 +45,12 @@ QuadPlane::QuadPlane(const char *home_str, const char *frame_str) :
frame_type = "+";
} else if (strstr(frame_str, "-y6")) {
frame_type = "y6";
} else if (strstr(frame_str, "-firefly")) {
} else if (strstr(frame_str, "firefly")) {
frame_type = "firefly";
// elevon style surfaces
elevons = true;
// fwd motor gives zero thrust
thrust_scale = 0;
}
frame = Frame::find_frame(frame_type);
if (frame == nullptr) {