Sign in to follow this  
helpMe321

Help with ship docking?

Recommended Posts

helpMe321    122
Hi! As a test I wanted to see if I could make a little ship (in 2D) dock with a target ala a ship/planet in the Escape velocity series. I'm having trouble figuring out how to have the ship reverse direction & thrust if it's current vector will pass the landing target. Any advice? Thanks for your time!

Share this post


Link to post
Share on other sites
hard problem

In Escape Velocity, rotation 'cheats' - instead of actual angular momentum the ship starts and stops rotating instatly as you press the rotation keys.
Are you going to continue using that? or will you also be having simulated rotation thrustors?

Anyhow, either way rotating the ship 180 to reverse thrust takes up time, during this time you may well have overshot your landing site.
Calculating the 180rotation time for your given ship is probably going to be a Must Have, so you can plan ahead for this problem.
(are you sure you dont want to cheat a little and have nose retrothrusters?)

I havent programmed Exactly this algorithm, tho I once did a similar problem with a 1D thruster (no rotation issue)
Heres how I'd fly it:
I'll leave derivation of Decceleration Time as function of Velocity and Engine Power to you. Should be simple equations. DeccelTime(Vel,MaxThrust)

Get your ship moving in a straight line thru the target.
You know your current speed, so given your known engine power, you know how long it will take to deccelerate to 0.
If that time/distance to deccelerate +180rotation time is less than the current time/distance from target, coast in till it matches just right, then spin and start your decceleration sequence.
If that time/distance to deccelerate +180rotation time is larger than the dist to target (you will overshoot) spin and start deccelerating Now so when you overshoot you will be moving as slow as possible on the other side of the target. Then start the process over again from wherever you ended up.

A pitfall:
If you are so close to target that the 180rotation time is longer than the decceleration time, you will keep overshooting.
To get out of this trap drift or accelerate farther away from target so that you have enough time to do your 180rotations.



I'm a little busy at work now
but I *might* have a better algorithm for you Later after I have more time to think it thru in better detail.

Share this post


Link to post
Share on other sites
helpMe321    122
Thanks for the input & glad I've got another head wrapped around this one. I have considered calculating the rotation time and factoring that into the approach.

Maybe retrothrusters are a better solution anyway. I'll for sure have to revist the EV Nova game and see if I can see any tricks with what they are doing on their ships. I dont believe they have reverse thrust.

Thanks & please let me know if someone else has a solution.

Share this post


Link to post
Share on other sites
ya know, I'm almost inclined to say... lets try this blindly and see if it works:

Hook a PID controller onto the distance to target (from the reference of the direction the ship is pointed), then have the ship rotate to face towards or away from the target based on if the PID output goes positive or negative. (and disconnect the main thrust while in the process of rotating)
Then pray that the time lag for rotating to thrust different directions(+,-) doesn't matter much....

Who knows? It might just be good enough.
May as well try that dumb/simple approach before you go with the hard one I suggested earlier.




P.S.
I forgot to think about it... but
Does your ship have a simple On/Off engine? or Can you throttle the thrust up and down gradually?
Precision thrust control naturally makes stopping right where you want a lot easier, since you can do tiny thrusts to slowly edge into dock...
The first post I made can probably work either way, tho you might want to have some minimum speed check to keep from taking forever. The second idea with the PID requires a engine throttle....

Share this post


Link to post
Share on other sites
BladeStone    100
Well space is an unknown, so you may want to look into other things if you are willing to break out of the mold of the game you are re-making/mimicing. Here are some other ideas for docking:

You could have an auto pilot so when you hit the 'dock' button, you are disengaged, but the computer figures it out for you, but you can't be at full speed or under attack,... just a thought.

Another method would be to come to a complete stop and be 'taxied' in by a 'tug' of some kind.

Or finally, for a game feel, you just have to fly at the station, and when you connect (at what every speed) you have docked,...

I would want the auto pilot for most realisum,... no full speed docking.

I hope open up some options. Good luck with the coding.

Share this post


Link to post
Share on other sites
-justin-    248
all though i can't say anything about EV nova (never played it) i can say a few things about the original EV

not that this will help you but if i remember correctly i'm assuming that there is a certain MIN_SPEED that you have to acquire in order to dock with a station; then as someone said before all you need to do is be on top of (or very close to) the station goin at most that minimum speed

also, as i think someone said you thrust the way you are rotated; so if you're rotated 90 degrees but you are goin 270 degrees at a speed of 10 and you thrust at 90 degrees at a speed of 2 for 4time units then you will have "slowed" down to a speed of 2

*shrug*

dunno if that helps at all (i tend to state the obvious), but i figure it couldn't hurt to comment ;)

good luck!

Share this post


Link to post
Share on other sites
deltadream    151
I think you should take your ship's moving equation and compute the distance (or time) to full stop at maximum brake. Thats for movement. Do something similar for orientation (angular movement).

Now let's say you have d - distance untill full moving rest and t1 for full angular rest.

Now when you reach d from target stop input and begin braking. When you are t1 seconds from full stop begin angular orinetation.

Whell there are a few cheats you may use:
- use a dummy docking target placed in front of your real target. So you dock with the dummy target and then move stright at constant speed to the real dummy target
- use a linear breaking formula to compute the distance to stop

Share this post


Link to post
Share on other sites
The original question, (and I am curious myself)
Is how to build an AutoPilot system that is capable of reaching that min speed and position by itself. Managing all those Newtonian physics is hard enough for a human player, so how would you have a program do it?

Traditionally, when this question is asked, people point to this one specific 'Steering Algorithms' paper, However this is inadequate for this particular problem because now Physics are involved. (whearas that paper was only concered with 'appearing' to navigate naturally)
So if a physics intensive person here has a general answer to the question - from arbitrary position and velocity how to land on target with min velocity....

This question might get better answers if moved to the Math and Physics forum.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this