ardupilot/libraries/SITL/SIM_Sailboat.h

80 lines
2.9 KiB
C
Raw Permalink Normal View History

2018-09-24 04:16:23 -03:00
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
sailboat simulator class
*/
#pragma once
#include "SIM_Aircraft.h"
namespace SITL {
/*
a sailboat simulator
*/
class Sailboat : public Aircraft {
public:
2019-08-15 01:01:24 -03:00
Sailboat(const char *frame_str);
2018-09-24 04:16:23 -03:00
/* update model by one time step */
2019-02-21 19:12:05 -04:00
void update(const struct sitl_input &input) override;
2018-09-24 04:16:23 -03:00
/* static object creator */
2019-08-15 01:01:24 -03:00
static Aircraft *create(const char *frame_str) {
return new Sailboat(frame_str);
2018-09-24 04:16:23 -03:00
}
bool on_ground() const override {return true;};
protected:
bool motor_connected; // true if this frame has a motor
float sail_area; // 1.0 for normal area
2018-09-24 04:16:23 -03:00
private:
2018-09-25 03:02:51 -03:00
// calculate the lift and drag as values from 0 to 1 given an apparent wind speed in m/s and angle-of-attack in degrees
void calc_lift_and_drag(float wind_speed, float angle_of_attack_deg, float& lift, float& drag) const;
// return turning circle (diameter) in meters for steering angle proportion in the range -1 to +1
float get_turn_circle(float steering) const;
// return yaw rate in deg/sec given a steering input (in the range -1 to +1) and speed in m/s
float get_yaw_rate(float steering, float speed) const;
// return lateral acceleration in m/s/s given a steering input (in the range -1 to +1) and speed in m/s
float get_lat_accel(float steering, float speed) const;
// simulate waves and swell
void update_wave(float delta_time);
2018-09-25 03:02:51 -03:00
float steering_angle_max; // vehicle steering mechanism's max angle in degrees
float turning_circle; // vehicle minimum turning circle diameter in meters
// lift and drag curves. index is angle/10deg
2018-10-05 19:22:44 -03:00
// angle-of-attack 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170+
const float lift_curve[18] = {0.00f, 0.50f, 1.00f, 1.10f, 0.95f, 0.75f, 0.60f, 0.40f, 0.20f, 0.00f, -0.20f, -0.40f, -0.60f, -0.75f, -0.95f, -1.10f, -1.00f, -0.50f};
const float drag_curve[18] = {0.10f, 0.10f, 0.20f, 0.40f, 0.80f, 1.20f, 1.50f, 1.70f, 1.90f, 1.95f, 1.90f, 1.70f, 1.50f, 1.20f, 0.80f, 0.40f, 0.20f, 0.10f};
const float mass = 2.0f;
2019-05-27 20:52:11 -03:00
Vector3f velocity_ef_water; // m/s
Vector3f wave_gyro; // rad/s
float wave_heave; // m/s/s
float wave_phase; // rads
2018-09-24 04:16:23 -03:00
};
} // namespace SITL