|
|
|
@ -87,8 +87,10 @@ void Submarine::calculate_forces(const struct sitl_input &input, Vector3f &rot_a
@@ -87,8 +87,10 @@ void Submarine::calculate_forces(const struct sitl_input &input, Vector3f &rot_a
|
|
|
|
|
rot_accel += t.rotational * output * frame_property.thrust * frame_property.thruster_mount_radius / frame_property.moment_of_inertia; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float floor_depth = calculate_sea_floor_depth(position); |
|
|
|
|
range = floor_depth - position.z; |
|
|
|
|
// Limit movement at the sea floor
|
|
|
|
|
if (position.z > 100 && body_accel.z > -GRAVITY_MSS) { |
|
|
|
|
if (position.z > floor_depth && body_accel.z > -GRAVITY_MSS) { |
|
|
|
|
body_accel.z = -GRAVITY_MSS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -127,6 +129,19 @@ void Submarine::calculate_buoyancy_torque(Vector3f &torque)
@@ -127,6 +129,19 @@ void Submarine::calculate_buoyancy_torque(Vector3f &torque)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Calculate sea floor depth from submarine position |
|
|
|
|
* This creates a non planar floor for rangefinder sensor test |
|
|
|
|
* TODO: Create a better sea floor with procedural generatation |
|
|
|
|
* |
|
|
|
|
* @param position |
|
|
|
|
* @return float |
|
|
|
|
*/ |
|
|
|
|
float Submarine::calculate_sea_floor_depth(const Vector3f &/*position*/) |
|
|
|
|
{ |
|
|
|
|
return 50; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Calculate drag force against body |
|
|
|
|
* |
|
|
|
|