Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Calculate Distance Until Stop with Drag + Acceleration

Discussion in 'Physics' started by imchrissharp, Jan 15, 2020.

  1. imchrissharp

    imchrissharp

    Joined:
    May 2, 2018
    Posts:
    15
    Hi!

    This is a part of a larger flight control system that I need to be able to approach a target position and stop exactly on it.

    https://github.com/ChristopherSharp/KinematicFlightController

    I have created a git repository to view source code or actually even run the Unity project (if you have it) if you are more of the hands on type.

    Essentially here is the problem I am trying to solve:

    A ship is currently moving at 10 m/s towards its target. It is also currently accelerating at 15m /s^2. The ship has a drag factor of 0.5. The ship's velocity in the next physics update (t = 0.02) can always be represented as:

    Vf = Vi + (a - Drag * Vi) * t
    Vf = 10 + (15 - 0.5 * 10) * 0.02 = 10.2 m/s

    The ship needs to be able to estimate the distance it will take to stop. When decelerating, the ship can exert a negative thrust of -25 m/s^2. In addition to this negative thrust, the ship will also still be decelerating due to the drag since it's velocity is still greater than 0. How much distance will the ship need to come to a complete stop Vf = 0?

    End Problem

    I have been successful getting this to work when Drag = 0, since it becomes a constant acceleration problem (s = required distance to stop). As long as s is less than the distance from the target, the ship accelerates. Once it is equal or greater than the distance, the ship hits the -25 m/s^2 acceleration and comes to a stop on target.

    s = (Vf^2 - Vi^2) / 2a
    s = (0 - 10^2) / (2 * -25) = 2 meters

    and then for the following update,

    s = (0 - 10.2^2) / (2 * -25) = 2.081 meters and so on...

    If Drag is greater than 0 I am at a loss. I've spent plenty of time on Wolfram Alpha trying to have some magic happen but no luck.

    I am totally open to suggestions or even changes to how I am representing drag. If there is a solution but I have to manually implement drag that's totally okay with me, in fact I would probably prefer that, but I'm no expert there. Since drag changes based upon Vi and goes to 0 as Vi goes to 0, I know this isn't linear.

    At this point I'm just spitballing now, but here is where I (sadly) am and I know I'm not even close.

    I estimate my total distance to stop just like I did in my above kinematic equation, but I don't know where to put drag (or how) into this. I do know that when de-accelerating, drag will help to deaccelerate *faster* than if it weren't there at all.

    (incorrect) s = (Vf^2 - Vi^2) / (2 * a - Vi * drag)
    s = (0 - 10^2) / (2 * -25 - 10.2 * 0.5) = 1.8181_ meters.

    This is sorta close with these numbers,and it does reinforce the fact that drag should help decelerate faster. But as they change or get larger it gets further from the truth. I know I'm missing an integral or another equation to bounce off of to solve this... any help is super appreciated.

    CS
     
    Last edited: Jan 16, 2020