1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "Sub.h"
- bool Sub::surface_init()
- {
- if(!control_check_barometer()) {
- return false;
- }
-
- pos_control.set_max_speed_z(wp_nav.get_default_speed_down(), wp_nav.get_default_speed_up());
- pos_control.set_max_accel_z(wp_nav.get_accel_z());
-
- pos_control.set_alt_target(inertial_nav.get_altitude());
- pos_control.set_desired_velocity_z(inertial_nav.get_velocity_z());
- gcs().send_text(MAV_SEVERITY_INFO, " surfacemode target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
- return true;
- }
- void Sub::surface_run()
- {
- float target_roll, target_pitch;
- float target_yaw_rate;
-
- if (!motors.armed()) {
- motors.output_min();
- motors.set_desired_spool_state(AP_Motors::DesiredSpoolState::GROUND_IDLE);
- attitude_control.set_throttle_out(0,true,g.throttle_filt);
- attitude_control.relax_attitude_controllers();
- return;
- }
-
- if (ap.at_surface) {
- set_mode(ALT_HOLD, MODE_REASON_SURFACE_COMPLETE);
- }
-
-
- get_pilot_desired_lean_angles(channel_roll->get_control_in(), channel_pitch->get_control_in(), target_roll, target_pitch, aparm.angle_max);
-
- target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
-
- attitude_control.input_euler_angle_roll_pitch_euler_rate_yaw(target_roll, target_pitch, target_yaw_rate);
-
- float cmb_rate = constrain_float(abs(wp_nav.get_default_speed_up()), 1, pos_control.get_max_speed_up());
-
- desired_climb_rate = cmb_rate;
-
- pos_control.set_alt_target_from_climb_rate_ff(cmb_rate, G_Dt, true);
- pos_control.update_z_controller();
-
- motors.set_forward(channel_forward->norm_input());
- motors.set_lateral(channel_lateral->norm_input());
- }
|