|
|
|
@ -206,13 +206,13 @@ static Frame supported_frames[] =
@@ -206,13 +206,13 @@ static Frame supported_frames[] =
|
|
|
|
|
Frame("firefly", 6, firefly_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) |
|
|
|
|
{ |
|
|
|
|
/*
|
|
|
|
|
scaling from total motor power to Newtons. Allows the copter |
|
|
|
|
to hover against gravity when each motor is at hover_throttle |
|
|
|
|
*/ |
|
|
|
|
thrust_scale = (_mass * GRAVITY_MSS) / (num_motors * hover_throttle); |
|
|
|
|
thrust_scale = (_mass * GRAVITY_MSS) / (num_motors * _hover_throttle); |
|
|
|
|
|
|
|
|
|
terminal_velocity = _terminal_velocity; |
|
|
|
|
terminal_rotation_rate = _terminal_rotation_rate; |
|
|
|
@ -228,6 +228,8 @@ Frame *Frame::find_frame(const char *name)
@@ -228,6 +228,8 @@ Frame *Frame::find_frame(const char *name)
|
|
|
|
|
if (strncasecmp(name, supported_frames[i].name, strlen(supported_frames[i].name)) == 0) { |
|
|
|
|
return &supported_frames[i]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
@ -236,7 +238,8 @@ Frame *Frame::find_frame(const char *name)
@@ -236,7 +238,8 @@ Frame *Frame::find_frame(const char *name)
|
|
|
|
|
void Frame::calculate_forces(const Aircraft &aircraft, |
|
|
|
|
const struct sitl_input &input, |
|
|
|
|
Vector3f &rot_accel, |
|
|
|
|
Vector3f &body_accel) |
|
|
|
|
Vector3f &body_accel, |
|
|
|
|
float* rpm) |
|
|
|
|
{ |
|
|
|
|
Vector3f thrust; // newtons
|
|
|
|
|
|
|
|
|
@ -245,6 +248,10 @@ void Frame::calculate_forces(const Aircraft &aircraft,
@@ -245,6 +248,10 @@ void Frame::calculate_forces(const Aircraft &aircraft,
|
|
|
|
|
motors[i].calculate_forces(input, thrust_scale, motor_offset, mraccel, mthrust); |
|
|
|
|
rot_accel += mraccel; |
|
|
|
|
thrust += mthrust; |
|
|
|
|
// simulate motor rpm
|
|
|
|
|
if (!is_zero(AP::sitl()->vibe_motor)) { |
|
|
|
|
rpm[i] = sqrtf(mthrust.length() / thrust_scale) * AP::sitl()->vibe_motor * 60.0f; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
body_accel = thrust/aircraft.gross_mass(); |
|
|
|
|