mirror of https://github.com/ArduPilot/ardupilot
SITL: added tricopter simulator
This commit is contained in:
parent
c262d6a1b4
commit
49822effca
|
@ -84,6 +84,13 @@ static const Motor octa_quad_motors[] =
|
||||||
Motor(AP_MOTORS_MOT_8, -135, AP_MOTORS_MATRIX_YAW_FACTOR_CW, 6)
|
Motor(AP_MOTORS_MOT_8, -135, AP_MOTORS_MATRIX_YAW_FACTOR_CW, 6)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const Motor tri_motors[] =
|
||||||
|
{
|
||||||
|
Motor(AP_MOTORS_MOT_1, 45, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 1),
|
||||||
|
Motor(AP_MOTORS_MOT_2, -45, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 3),
|
||||||
|
Motor(AP_MOTORS_MOT_4, 180, AP_MOTORS_MATRIX_YAW_FACTOR_CCW, 2, AP_MOTORS_MOT_7, -45, 45, -1, 0, 0),
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
table of supported frame types
|
table of supported frame types
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +103,8 @@ static Frame supported_frames[] =
|
||||||
Frame("hexa", 6, hexa_motors),
|
Frame("hexa", 6, hexa_motors),
|
||||||
Frame("hexax", 6, hexax_motors),
|
Frame("hexax", 6, hexax_motors),
|
||||||
Frame("octa", 8, octa_motors),
|
Frame("octa", 8, octa_motors),
|
||||||
Frame("octa-quad", 8, octa_quad_motors)
|
Frame("octa-quad", 8, octa_quad_motors),
|
||||||
|
Frame("tri", 3, tri_motors)
|
||||||
};
|
};
|
||||||
|
|
||||||
void Frame::init(float _mass, float hover_throttle, float _terminal_velocity, float _terminal_rotation_rate)
|
void Frame::init(float _mass, float hover_throttle, float _terminal_velocity, float _terminal_rotation_rate)
|
||||||
|
|
|
@ -34,5 +34,21 @@ void Motor::calculate_forces(const Aircraft::sitl_input &input,
|
||||||
rot_accel.y = radians(5000.0) * cosf(radians(angle)) * motor_speed;
|
rot_accel.y = radians(5000.0) * cosf(radians(angle)) * motor_speed;
|
||||||
rot_accel.z = yaw_factor * motor_speed * radians(400.0);
|
rot_accel.z = yaw_factor * motor_speed * radians(400.0);
|
||||||
thrust(0, 0, motor_speed * thrust_scale); // newtons
|
thrust(0, 0, motor_speed * thrust_scale); // newtons
|
||||||
|
if (roll_servo >= 0) {
|
||||||
|
float roll = constrain_float(roll_min + (input.servos[roll_servo]-1000)*0.001*(roll_max-roll_min), roll_min, roll_max);
|
||||||
|
Matrix3f rotation;
|
||||||
|
rotation.identity();
|
||||||
|
rotation.rotate(Vector3f(radians(roll), 0, 0));
|
||||||
|
rot_accel = rotation * rot_accel;
|
||||||
|
thrust = rotation * thrust;
|
||||||
|
}
|
||||||
|
if (pitch_servo >= 0) {
|
||||||
|
float pitch = constrain_float(pitch_min + (input.servos[pitch_servo]-1000)*0.001*(pitch_max-pitch_min), pitch_min, pitch_max);
|
||||||
|
Matrix3f rotation;
|
||||||
|
rotation.identity();
|
||||||
|
rotation.rotate(Vector3f(0, radians(pitch), 0));
|
||||||
|
rot_accel = rotation * rot_accel;
|
||||||
|
thrust = rotation * thrust;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue