|
@@ -12,6 +12,9 @@ Quaternion attitude_desired_quat_;
|
|
|
// althold_init - initialise althold controller
|
|
|
bool Sub::sport_init()
|
|
|
{
|
|
|
+
|
|
|
+ attitude_control.set_throttle_out(0.5 ,true, g.throttle_filt);
|
|
|
+ //holding_depth = false;
|
|
|
//检查是否有深度计存在
|
|
|
if(!control_check_barometer()) {
|
|
|
return false;
|
|
@@ -39,8 +42,8 @@ bool Sub::sport_init()
|
|
|
last_input_ms = AP_HAL::millis();
|
|
|
last_input_ms_stable = AP_HAL::millis();
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " last_attitudeinit %d %d,%d ",(int)last_roll_s,(int)pitch_input_inc,(int)last_yaw_s);
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " init Z target %f %f",(float)pos_control.get_pos_target().z,barometer.get_altitude());
|
|
|
+
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, " init Z target %f %f",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -97,16 +100,7 @@ void Sub::handle_attitude_sport(){
|
|
|
//attitude_control.input_euler_angle_roll_pitch_yaw(last_roll, last_pitch, last_yaw, true);
|
|
|
attitude_control.input_quaternion(attitude_desired_quat_);
|
|
|
}
|
|
|
- static int f = 0;
|
|
|
- f++;
|
|
|
- if(f>800)
|
|
|
- {
|
|
|
-
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " sportrpy %f %f,%f ",(float)target_roll,(float)target_pitch,(float)target_yaw);
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " sportatd %f %f,%f ",(float)last_roll,(float)last_pitch,(float)last_yaw);
|
|
|
- f=0;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -117,14 +111,14 @@ void Sub::handle_attitude_sport(){
|
|
|
// should be called at 100hz or more
|
|
|
void Sub::sport_run()
|
|
|
{
|
|
|
- static int f2 = 0;
|
|
|
- static int f3 = 0;
|
|
|
+ static int f2 = 201;
|
|
|
+ static int f3 = 201;
|
|
|
|
|
|
|
|
|
// When unarmed, disable motors and stabilization
|
|
|
if (!motors.armed()) {
|
|
|
- f2 = 0;
|
|
|
- f3 = 0;
|
|
|
+ f2 = 201;
|
|
|
+ f3 = 201;
|
|
|
|
|
|
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)
|
|
@@ -145,7 +139,7 @@ void Sub::sport_run()
|
|
|
if(f>800)
|
|
|
{
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, " disarm 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, " disarm Z target %f %f",(float)pos_control.get_pos_target().z,barometer.get_altitude()*100);
|
|
|
f=0;
|
|
|
}
|
|
|
return;
|
|
@@ -183,28 +177,28 @@ void Sub::sport_run()
|
|
|
//pos_control.set_alt_target(barometer.get_altitude()*100);//当前深度
|
|
|
|
|
|
static int f = 0;
|
|
|
- f2 = 0;
|
|
|
- f3 = 0;
|
|
|
+ f2 = 201;
|
|
|
+ f3 = 201;
|
|
|
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, " 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 { // hold z
|
|
|
if (ap.at_surface) { //最大油门不能向上动
|
|
|
- pos_control.set_alt_target(g.surface_depth - 20.0f); // set target to 5cm below surface level
|
|
|
+ pos_control.set_alt_target(g.surface_depth - 10.0f); // set target to 5cm below surface level
|
|
|
holding_depth = true;
|
|
|
|
|
|
f2++;
|
|
|
- if(f2==1)
|
|
|
+ if(f2>200)
|
|
|
{
|
|
|
|
|
|
- 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, " 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=2;
|
|
|
+ f2=0;
|
|
|
}
|
|
|
} else if (ap.at_bottom) {//最大油门不能向下动
|
|
|
//pos_control.set_alt_target(inertial_nav.get_altitude() + 20.0f); // set target to 10 cm above bottom
|
|
@@ -212,21 +206,21 @@ void Sub::sport_run()
|
|
|
holding_depth = true;
|
|
|
|
|
|
f3++;
|
|
|
- if(f3==1)
|
|
|
+ if(f3>200)
|
|
|
{
|
|
|
|
|
|
- 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, " 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=2;
|
|
|
+ f3=0;
|
|
|
}
|
|
|
} else if (!holding_depth) {
|
|
|
//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;
|
|
|
+ f2 = 201;
|
|
|
+ f3 = 201;
|
|
|
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, " 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);
|
|
|
|
|
|
}
|
|
@@ -236,7 +230,7 @@ void Sub::sport_run()
|
|
|
if(f5>500)
|
|
|
{
|
|
|
|
|
|
- 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, " 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;
|