|
@@ -37,14 +37,14 @@ bool Sub::sport_init()
|
|
|
last_roll = 0;
|
|
|
last_pitch = 0;
|
|
|
|
|
|
+ updowmgain =0.5;
|
|
|
|
|
|
last_yaw = ahrs.yaw_sensor;
|
|
|
last_input_ms = AP_HAL::millis();
|
|
|
last_input_ms_stable = AP_HAL::millis();
|
|
|
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " init Z target %f %f",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
-
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -75,9 +75,11 @@ void Sub::handle_attitude_sport(){
|
|
|
|
|
|
|
|
|
|
|
|
- get_pilot_desired_lean_angles(0, (int16_t)((0.5-channel_throttle->norm_input())*5700*2), target_roll, target_pitch, attitude_control.get_althold_lean_angle_max());
|
|
|
+
|
|
|
+ get_pilot_desired_lean_angles(0, (int16_t)((0.5-channel_throttle->norm_input())*5700), target_roll, target_pitch, attitude_control.get_althold_lean_angle_max());
|
|
|
|
|
|
- target_yaw = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
|
|
|
+ target_yaw = get_pilot_desired_yaw_rate(channel_yaw->get_control_in()*0.3);
|
|
|
+
|
|
|
if (abs(target_roll) > 300 || abs(target_pitch) > 300) {
|
|
|
|
|
|
|
|
@@ -111,15 +113,12 @@ void Sub::handle_attitude_sport(){
|
|
|
|
|
|
void Sub::sport_run()
|
|
|
{
|
|
|
- static int f2 = 201;
|
|
|
- static int f3 = 201;
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
if (!motors.armed()) {
|
|
|
- f2 = 201;
|
|
|
- f3 = 201;
|
|
|
-
|
|
|
+
|
|
|
motors.set_desired_spool_state(AP_Motors::DesiredSpoolState::GROUND_IDLE);
|
|
|
|
|
|
attitude_control.set_throttle_out(0.5 ,true, g.throttle_filt);
|
|
@@ -127,21 +126,14 @@ void Sub::sport_run()
|
|
|
pos_control.relax_alt_hold_controllers();
|
|
|
|
|
|
|
|
|
-
|
|
|
+ updowmgain =0.5;
|
|
|
last_roll = 0;
|
|
|
last_pitch = 0;
|
|
|
last_yaw = ahrs.yaw_sensor;
|
|
|
holding_depth = false;
|
|
|
ahrs.get_quat_body_to_ned(attitude_desired_quat_);
|
|
|
|
|
|
- static int f = 0;
|
|
|
- f++;
|
|
|
- if(f>800)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " disarm Z target %f %f",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
- f=0;
|
|
|
- }
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -161,14 +153,17 @@ void Sub::sport_run()
|
|
|
|
|
|
|
|
|
|
|
|
- motors.set_throttle(throttle_vehicle_frame.z + 1.0-(float)PressLevel_f*0.1);
|
|
|
+
|
|
|
+
|
|
|
+ motors.set_throttle(throttle_vehicle_frame.z + gaindelay(1.0-(float)PressLevel_f*0.1,updowmgain));
|
|
|
rov_message.pressure_level = int(PressLevel);
|
|
|
- motors.set_forward(-throttle_vehicle_frame.x + channel_forward->norm_input());
|
|
|
- motors.set_lateral(-throttle_vehicle_frame.y + channel_lateral->norm_input());
|
|
|
+ motors.set_forward(constrain_float(-throttle_vehicle_frame.x + getgainf(channel_forward->norm_input()),-0.8,0.8));
|
|
|
+ motors.set_lateral(constrain_float(-throttle_vehicle_frame.y + getgainf(channel_lateral->norm_input()),-0.8,0.8));
|
|
|
|
|
|
|
|
|
|
|
|
- Vector3f earth_frame_rc_inputs = ahrs.get_rotation_body_to_ned() * Vector3f(channel_forward->norm_input(), channel_lateral->norm_input(), (2.0*(0.5-PressLevel_f*0.1)));
|
|
|
+
|
|
|
+ Vector3f earth_frame_rc_inputs = ahrs.get_rotation_body_to_ned() * Vector3f(channel_forward->norm_input(), 0.0, (2.0*(0.5-PressLevel_f*0.1)));
|
|
|
|
|
|
if (fabsf(earth_frame_rc_inputs.z) > 0.05f) {
|
|
|
|
|
@@ -176,65 +171,59 @@ void Sub::sport_run()
|
|
|
pos_control.relax_alt_hold_controllers();
|
|
|
|
|
|
|
|
|
- static int f = 0;
|
|
|
- f2 = 201;
|
|
|
- f3 = 201;
|
|
|
- f++;
|
|
|
- if(f>400)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Z1 target %f %f ",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
- f=0;
|
|
|
- }
|
|
|
+
|
|
|
} else {
|
|
|
if (ap.at_surface) {
|
|
|
pos_control.set_alt_target(g.surface_depth - 10.0f);
|
|
|
holding_depth = true;
|
|
|
|
|
|
- f2++;
|
|
|
- if(f2>200)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Zsurface target %f %f ",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
- f2=0;
|
|
|
- }
|
|
|
+
|
|
|
} else if (ap.at_bottom) {
|
|
|
|
|
|
pos_control.set_alt_target(barometer.get_altitude()*100 +20);
|
|
|
holding_depth = true;
|
|
|
|
|
|
- f3++;
|
|
|
- if(f3>200)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Zbottom target %f %f ",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
- f3=0;
|
|
|
- }
|
|
|
+
|
|
|
} else if (!holding_depth) {
|
|
|
|
|
|
pos_control.calc_leash_length_z();
|
|
|
pos_control.set_alt_target(barometer.get_altitude()*100);
|
|
|
- f2 = 201;
|
|
|
- f3 = 201;
|
|
|
+
|
|
|
holding_depth = true;
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Z4 target %f %f ",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- static int f5 = 0;
|
|
|
- f5++;
|
|
|
- if(f5>500)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Z00 target %f %f ",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
- f5=0;
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+float rmpforward(float _gain){
|
|
|
+ static uint16_t rmpcounter = 0;
|
|
|
+ float get_forward_gain = motors.get_forward();
|
|
|
+ float temp=0;
|
|
|
+ rmpcounter++;
|
|
|
+ if (rmpcounter>20)
|
|
|
+ {
|
|
|
+ rmpcounter =0;
|
|
|
+ if(get_forward_gain - _gain>0.01){
|
|
|
+ temp = get_forward_gain-0.01;
|
|
|
+
|
|
|
+ }else if(get_forward_gain- _gain<-0.01){
|
|
|
+ temp = get_forward_gain+0.01;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ temp = _gain;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_gain>0.3)
|
|
|
+ {
|
|
|
+ temp =constrain_float(temp,0.4,1.0);
|
|
|
+ }else if(temp<-0.3){
|
|
|
+ temp = constrain_float(temp,-1.0,-0.4);
|
|
|
+ }else{
|
|
|
+ temp=0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}*/
|