|
@@ -12,19 +12,23 @@ Quaternion attitude_desired_quat_;
|
|
|
// althold_init - initialise althold controller
|
|
|
bool Sub::sport_init()
|
|
|
{
|
|
|
+ //检查是否有深度计存在
|
|
|
if(!control_check_barometer()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// initialize vertical speeds and leash lengths
|
|
|
// sets the maximum speed up and down returned by position controller
|
|
|
- pos_control.set_max_speed_z(-get_pilot_speed_dn(), g.pilot_speed_up);
|
|
|
- pos_control.set_max_accel_z(g.pilot_accel_z);
|
|
|
- pos_control.relax_alt_hold_controllers();
|
|
|
- //pos_control.set_alt_target(-20);//cm
|
|
|
- pos_control.set_target_to_stopping_point_z();
|
|
|
+ //get_pilot_speed_dn QGC PILOT 设置的值
|
|
|
+ pos_control.set_max_speed_z(-get_pilot_speed_dn(), g.pilot_speed_up);//(-500,500)设置最大最小速度 和刹车长度
|
|
|
+ pos_control.set_max_accel_z(g.pilot_accel_z);//设置最大加速度值 和刹车长度
|
|
|
+ pos_control.relax_alt_hold_controllers();//目标高度为当前高度,目标速度和上次速度 当前速度
|
|
|
+ //
|
|
|
+ //pos_control.set_target_to_stopping_point_z();//刹车长度 根据当前速度估计目标深度
|
|
|
+ pos_control.calc_leash_length_z();//刹车长度 12.19
|
|
|
+ pos_control.set_alt_target(barometer.get_altitude()*100);//当前深度12.19
|
|
|
holding_depth = true;
|
|
|
- ahrs.get_quat_body_to_ned(attitude_desired_quat_);
|
|
|
+ ahrs.get_quat_body_to_ned(attitude_desired_quat_);//12.19
|
|
|
|
|
|
|
|
|
last_roll = 0;
|
|
@@ -113,19 +117,28 @@ void Sub::handle_attitude_sport(){
|
|
|
// should be called at 100hz or more
|
|
|
void Sub::sport_run()
|
|
|
{
|
|
|
+ static int f2 = 0;
|
|
|
+ static int f3 = 0;
|
|
|
+
|
|
|
+
|
|
|
// When unarmed, disable motors and stabilization
|
|
|
if (!motors.armed()) {
|
|
|
+ f2 = 0;
|
|
|
+ f3 = 0;
|
|
|
+
|
|
|
motors.set_desired_spool_state(AP_Motors::DesiredSpoolState::GROUND_IDLE);
|
|
|
// Sub vehicles do not stabilize roll/pitch/yaw when not auto-armed (i.e. on the ground, pilot has never raised throttle)
|
|
|
attitude_control.set_throttle_out(0.5 ,true, g.throttle_filt);
|
|
|
attitude_control.relax_attitude_controllers();
|
|
|
pos_control.relax_alt_hold_controllers();
|
|
|
- //pos_control.set_alt_target(-20);//cm
|
|
|
+
|
|
|
+ //pos_control.set_alt_target(barometer.get_altitude()*100);//当前深度
|
|
|
+
|
|
|
last_roll = 0;
|
|
|
last_pitch = 0;
|
|
|
last_yaw = ahrs.yaw_sensor;
|
|
|
holding_depth = false;
|
|
|
- ahrs.get_quat_body_to_ned(attitude_desired_quat_);
|
|
|
+ ahrs.get_quat_body_to_ned(attitude_desired_quat_);//12.19
|
|
|
|
|
|
static int f = 0;
|
|
|
f++;
|
|
@@ -167,29 +180,67 @@ void Sub::sport_run()
|
|
|
// reset z targets to current values
|
|
|
holding_depth = false;
|
|
|
pos_control.relax_alt_hold_controllers();
|
|
|
- //pos_control.set_alt_target(barometer.get_altitude()*100);//cm
|
|
|
+ //pos_control.set_alt_target(barometer.get_altitude()*100);//当前深度
|
|
|
+
|
|
|
+ static int f = 0;
|
|
|
+ f2 = 0;
|
|
|
+ f3 = 0;
|
|
|
+ f++;
|
|
|
+ if(f>400)
|
|
|
+ {
|
|
|
+
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " Z1 target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
+ f=0;
|
|
|
+ }
|
|
|
} else { // hold z
|
|
|
if (ap.at_surface) { //最大油门不能向上动
|
|
|
- pos_control.set_alt_target(g.surface_depth - 10.0f); // set target to 5cm below surface level
|
|
|
+ pos_control.set_alt_target(g.surface_depth - 20.0f); // set target to 5cm below surface level
|
|
|
holding_depth = true;
|
|
|
+
|
|
|
+ f2++;
|
|
|
+ if(f2==1)
|
|
|
+ {
|
|
|
+
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " Zsurface target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
+ f2=2;
|
|
|
+ }
|
|
|
} else if (ap.at_bottom) {//最大油门不能向下动
|
|
|
- pos_control.set_alt_target(inertial_nav.get_altitude() + 20.0f); // set target to 10 cm above bottom
|
|
|
- //pos_control.set_alt_target(barometer.get_altitude()*100 +20);//cm
|
|
|
+ //pos_control.set_alt_target(inertial_nav.get_altitude() + 20.0f); // set target to 10 cm above bottom
|
|
|
+ pos_control.set_alt_target(barometer.get_altitude()*100 +20);//cm
|
|
|
holding_depth = true;
|
|
|
+
|
|
|
+ f3++;
|
|
|
+ if(f3==1)
|
|
|
+ {
|
|
|
+
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " Zbottom target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
+ f3=2;
|
|
|
+ }
|
|
|
} else if (!holding_depth) {
|
|
|
- pos_control.set_target_to_stopping_point_z();
|
|
|
+ //pos_control.set_target_to_stopping_point_z();//有对位置的付值
|
|
|
+ pos_control.calc_leash_length_z();//刹车长度 12.19
|
|
|
+ pos_control.set_alt_target(barometer.get_altitude()*100);//cm 当前深度
|
|
|
+ f2 = 0;
|
|
|
+ f3 = 0;
|
|
|
holding_depth = true;
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " Z4 target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- static int f = 0;
|
|
|
- f++;
|
|
|
- if(f>800)
|
|
|
- {
|
|
|
+ static int f5 = 0;
|
|
|
+ f5++;
|
|
|
+ if(f5>500)
|
|
|
+ {
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " Z target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " Z00 target %f %f %f",(float)pos_control.get_pos_target().z,pos_control.get_alt(),barometer.get_altitude());
|
|
|
+
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
+ f5=0;
|
|
|
+ }
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " surface %d at_bottom %d ",ap.at_surface,ap.at_bottom);
|
|
|
- f=0;
|
|
|
- }
|
|
|
|
|
|
}
|