Skip to content

Commit

Permalink
SITL: added tricopter simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Apr 21, 2016
1 parent c262d6a commit 49822ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libraries/SITL/SIM_Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ static const Motor octa_quad_motors[] =
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
*/
Expand All @@ -96,7 +103,8 @@ static Frame supported_frames[] =
Frame("hexa", 6, hexa_motors),
Frame("hexax", 6, hexax_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)
Expand Down
16 changes: 16 additions & 0 deletions libraries/SITL/SIM_Motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.z = yaw_factor * motor_speed * radians(400.0);
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;
}
}

0 comments on commit 49822ef

Please sign in to comment.