Android Question GPS: shortest route

Beja

Expert
Licensed User
Longtime User
Hello all
Facing a complicated problem and hope someone has a solution.
I know how to calculate the shortest distance.. But how my robot follow that short path is the problem.. Checking for decrimened value is not useful because if it traveled with less than 90 degrees the value will still decrement (for some time).
Any help appreciated.

p.s.
Using GPS coordinates for each point
 
Last edited:

Beja

Expert
Licensed User
Longtime User
Hi Rick,
Thanks so much for the useful function, and it was my mistake in the title.. but if you see the post subject, I can use your equation or the GPS distanceto function.. but what I am looking for is a way to move object A towards object B.. Object B is stationary. In other words, I want to control object A's direction so it can move towards object B.
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
Rick. The broad solution is called "The Transportation Algorithm". A subset of Linear Programming/Optimization and requires extensive use of arrays. Excel provides a free (up to 10 X 10 array) you can use for a some sample data.

The array is pretty straight forward - I wrote it in Basic a long time ago (1980 or so and long lost the code) but any reference you get today makes it way too complicated to understand i.e. https://github.com/Somenath24/TransP. It can be pretty involved because you need every turn/distance to provide the information to the array. But once that information is available - the cpu does all the work and it is pretty fast. Also, Google has vast resources and access to specialized optimization routines that would not be visible or is embedded in other code. Optimization is it's own discipline and worthwhile to understand but it can be challenging - however, it will provide the answer.

The short solution, there may be another application that can provide the answer or you may need to add constraints that will provide a reliable special solution.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Dears Rick and Dogbonesix,
Thanks for your efforts and willing to help, and I honestly invite you to read posts 1 and 3 (the full text). in short, it's a straight line between 2 points less than 50 meters away from each other.. so no big circle or globe, and no street turns.. and again, the problem is not finding the distance as stated in the first post.. but to move an object from point A to point B. point A must decrement it's location Lat/Lon every (interval) but in the direction of point B until lat1 = lat2 and lon1 = lon2.
I hope I am more clear now.
 
Last edited:
Upvote 0

Beja

Expert
Licensed User
Longtime User
Is there a way you can attach an image of your problem? I think that would help.
Sure.. here you go. Note: The car may turn left or right so it must re-calculate contentiously
Please note I am using the same point twice and that was by mistake.. the marker should show different location.. but it should be obvious

LatLon88.jpg
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
You have to calculate the azimuth to the target and turn the car to that azimuth (from its own azimuth). Use mod to get rid of additional or negative 360 from calculating the difference.
It is simpler to work with UTM coordinates and calculate the azimuth using ATAN2 function.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi derez and thanks..

I did some research on your solution and I have no experience to design with it, besides
I don't want to use azimuth (I don't want to use any compass).. I want to use the geo-coordinates only.
 
Last edited:
Upvote 0
Top