Wireless GPS Positioning - c#

I have a database of wireless access points and multiple readings (1-n) of signal strength (RSSI) for each access point. Along with this I record the GPS coordinates of each reading.
Now, what I want to do is given visible access points compute my approx. GPS position but I'm not sure how to go about doing this. I've read that I possibly need trilateration however I'm not maths savvy and a lot of articles on this seem to be that way inclined, can someone break it down for my simple mind with code examples (psuedo or otherwise)?
Many of these pages also talk about distance and I'm unsure how best to compute that. One thought is to infer it from the RSSI. Assuming I have at least two readings for a given access point at decreasing RSSI I should be able to roughly infer distance from that just by computing the distance between the GPS coords? I'm making the assumption the lowest RSSI is the nearest to the actual device and not taking into account signal propagation or anything like that.
Any thoughts, points and links would be most appreciated.

I believe you'll need at least four readings from reasonably separated locations for an access point to get a rough idea of where it is, however this only works even vaguely accurately in a vacuum :) Buildings, trees, and other interference will naturally skew the results, often quite dramatically. More readings in that case would improve the accuracy.
The theory is that at each point in space exists within a shell of radius r from the given access point. Theoretically, the signal strength drops off with the inverse square of the distance r, so you need to take that into account as well.
So say you measure a signal strength at some location - you know that the square root of one over the signal strength is proportional to the distance from you to the access point - but that access point could exist anywhere on the surface of the sphere with that radius from you.
A second reading at a different location produces a second sphere which should intersect with the first - however think about two overlapping beach balls and you'll see that the intersection is a circle, anywhere along which the AP could be located. The third reading will intersect with the circle from the first two at two places so now you have two target points where the access point could be located. The fourth and final reading will tell you which of these two it is.
Again, this is all assuming an ideal situation - far from likely in the real world. You'd need to apply ranges, statistical methods, and a lot more than 4 readings etc to get a good guess as to the location of the AP.
Also, the method used above to conceptualize the method to find the AP may not be the best way to actually do this in practice. You'd also need to ensure the user who is trying to locate the AP walks around a bit to get some decent readings.
Other things to consider: where the readings are taken from matters. If you just walk in a straight line or on a flat surface you'll most likely not be able to determine if the AP is to the left or right of the line or below or above you. Your walk must include some movement in all three dimensions. Also, you'll probably want a smattering of trig and Pythagoras to do the actual translation calcs :)
Anyway, I'd love to have an iPhone app that finds APs and puts them on google maps for me so I can figure out where they are and who they belong to... it'd be awesome. But yeah, I haven't tried any of the above, it just seems to me to be the way it would work. I'm happy to be corrected if this turns out to be inaccurate :D

Related

Trying to find the fastest way to navigate a set of edges in a graph

I'm unsure of which algorithm I should use to accomplish this task. I have a graph of nodes. Some nodes are connected with a weighted line that are required to be traversed. However, every node is connected with a weighted, bi-directional line. Only some of the lines must be traversed while the others are just for navigation. I need to find a path to go over all these required lines (bi-directional), but only go over the lines one time. I know which node I must start with.
The real-world problem is that I have a list of edges that need cut from a CNC pattern. I'm trying to decrease the amount of time the CNC machine spends cutting out this pattern. I know I always want to start at the origin, but I don't care where the pattern ends, just as long as all the little pieces in the pattern are cut out. I know how long each edge of the pieces will take to cut out, and the machine is accurate enough that it can lift up the head and go to any point to start from that position. My graph isn't huge, maybe up to 100 nodes in a general case.
This is unlike the travelling-salesman because I don't have to start and end at the same place, and I'm allowed to (and required) to hit a node multiple times.
Djikstras algorithm doesn't work because I need to traverse all the nodes to get all the edges cut... I'm not just trying to find the fastest way from point A to B.
Bonus, I need this implemented in C#, but even if I just knew what algorithm, I can probably get it programmed.
Here is a sample picture of a pattern I need to cut out. Note, there is one diagonal and one arc I forgot to assign a weight to, which can be 50 for the diagonal, and 75 for the arc:
I believe this can be solved as a case of the route inspection problem.
https://en.wikipedia.org/wiki/Route_inspection_problem
You will need ensure that there is a eulerian circuit for the graph, which may achieved through luck or by joining the odd vertices together.
I think this would still reduce to the traveling salesman problem. TSP does not get any easier by removing the return-to-origin rule or allowing multiple visits.
As such there would be no polonomial solution, and your best bet is probably an approximate solution.

algorithm to use to find closest object on tile map

I have a game map represented as a tile map. Currently there are two types of objects that are present on the map, relevant to this problem: gatherable resources (trees, rocks, etc.) and buildings built by the player. Buildings are also connected by roads.
I have a problem figuring out an efficient algorithm that could do the following:
find the closest resource to any relevant building (ie. find the closest tree to lumberjack/tree-gatherer)
find the closest relevant building to any building (ie. find the closest storage to any sawmill)
I separated those two issues because the first one does not need roads, but the second one is supposed to only use roads.
So, the result of this should be a single path to a single object, that is the closest to the one I'm figuring it out from. The path is then used by a worker to gather the resource and bring it back, or let's say, to pick a resource from a sawmill and bring it to the closest storage.
I know how to get the closest path itself (A*, Djikstra or even Floyd-Warshall), but I'm not sure how to optimally proceed with multiples of those and getting the best/closest one, especially if it's going to be run very regularly and the map object collections (roads and buildings) is expected to be changing regularly as well.
I'm doing this in Unity3D/c# but I guess this is not really Unity3D-related issue.
How should I proceed?
Finding the geographical distance between two objects is a cheap (quick) operation - you can afford to perform that many times per game tick. Use it if the option is available.
Finding the shortest path by making use of terrain features such as roads, tracks etc. is a much more complex operation. As you already mentioned in your post the A* search algorithm is probably your best option for it, but it is quite slow.
But generally, you should not need to run it too often - just compute the path every X seconds (for some value of X), and make your worker spend the next few game ticks following this computed path, until you "refresh" it. The more precision you have, and more responsiveness to changes to the game environment (e.g. obstacles appearing in your path), the more CPU time you will use.
Try different amounts of precision, and find one that gives decent precision while not being too expensive in terms of CPU time. (The update interval depends purely on the number of calls you are expected to make. Calculating paths for 100 workers is obviously much harder than for 1.)

Travelling salesman with time limit

I'm trying to make an application to calculate a daily route to visit my clients. I can solve whole way by using Genetic Algorithms so far. But I need to limit solution by distance. When I just "cut" the solution path at some point, it becomes a bad solution. Is there a special algorithm for this instance? I'm trying to find and fit one but no luck.
Someone used to do this can give me a recommendetion? I can use vb.NET, c#, php or JAVA.
Thanks.
If you're limiting the distance traveled, then I'm assuming that you're okay with not visiting ALL of your clients every day. If you need to visit ALL of your clients AND you have a maximum distance you want to travel, then all you can do is keep running your TSP algorithm until it (hopefully) produces a solution you're happy with.
If you only want to visit clients within a certain distance of the starting point, then determine the Euclidean distance of each point from the starting point, and filter out those that are too far away. Then run your TSP algorithm on the remaining points.
I'm assuming you instead want to be able to visit as many clients as possible by traveling a maximum distance d. I recommend using a Hill-climbing approach. Start with a valid solution (e.g. just use a greedy approach of taking the next closest unvisited client and stop when the total distance is d), and then randomly modify n nodes in the solution (this could mean reordering them, or this could mean swapping a node for one that isn't currently in the solution; use a sensible heuristic here, you don't want to swap a node for a node that's on the other side of the map, one possible approach is to use a weighted algorithm that favors swaps with closer nodes over more distant nodes) and test to see if the new solution is valid + better than the previous solution. You can always force the new solution to be valid by stripping off the last few clients from the trip.
Maybe you can adjust the TSP or VRP example in OptaPlanner (open source, java) to do your bidding? There's a video that shows how to customize/tailor the constraints to your specific case.

Preventing entities from stacking on top of eachother in an overhead shooter

I'm working on an overhead shooter and what happens is, over time, as I move in circles around the arena, the enemies will begin to stack on top of each other until they're one giant stack of units. It ends up looking pretty silly.
The AI is pretty simple and basic: Find the player, move towards him, and attack him if he's in range.
What's the best way to push them away from each other so that they don't all end up on the same spot? I think flocking is a bit overkill (and probably too intensive since I'll have 100-200 enemies on the screen at a time).
Ideas?
Thanks!
Here are a few different approaches you could take to solving this problem:
You could define a potential field for each unit that associates a "height" or "badness" to each location on the map. Each unit moves in a way that tries to minimize its potential, perhaps by taking a step in the direction that moves it to the lowest potential that it can in one step. You could define the potential function so that it slopes toward the player, causing all units to try to move to the player, but also be very high around existing units, causing units to avoid bumping into one another. This is a very powerful framework that is exploited all the time in AI; one famous example is its use in the Berkeley Overmind AI for StarCraft, which ended up winning an AI StarCraft competition. If you do adopt this sort of approach, you could probably then tweak the potential function to get the AI to behave in many other interesting ways, and could easily support flocking. I personally think that this is the best approach to take, as it's the most flexible. It also would be a great starting point for more advanced pathfinding models. For a very good and practical introduction to potential fields for AI, check out this website. For a rigorous mathematical introduction to potential fields and their applications, you might want to check out this paper surveying different AI methods using potential fields.
If you define a bounding circle for each enemy, you could just explicitly disallow the units from stacking on top of each other by preventing any two units from being within two radii's distance of one another. Any time two units got too close, you could either stop one of them from moving, or could have them exert forces on one another to spread them apart. When two units bump into each other, you could just pick a random force vector to apply to each unit to try to spread them apart. This is a much hackier and less elegant solution than potential fields, but if you need to get something up and running it's definitely a viable option.
You could choose a set of points around the player that the units try to move toward, then have each unit randomly choose one of those target points to move to. This would cause the units to spread more thinly in a ring (or whatever shape you'd like) around the player, avoiding the huge masses that you've seen so far. Again, this is way less elegant than using potential fields, but it's another quick hack you could experiment with if your goal is to get something working quickly.
Hope this helps!

determining your location using ONLY wifi signals?

i will be working on a project that tries to determine your position using the wifi signal strength from a few access points. i was wondering if anyone knew of any similiar projects or any articles on that topic
if anyone cares: its a research project in at my university. the app is written is used as a playing ground to develop new wifi antenna that are better suited for this type of usage. i only work on the coding part of the project though. oh and its written using c# which is not optional
clarification:
its ONLY wifi. no GPS goodnes for us becaus its supposed to work indoors
the software is supposed to determine your location by using the known locations of the access points and their signal strenghts to tell you where you are. its currently at around 4-5 meters of accuracy
aside from that i already have a working prototype and was just wondering if anything similiar has been done before or if anyone has any tips or ideas for/about the project
Discarding the first 2 answers, where they need to use GPS and A-GPS in the first and a known WiFi network in the second, my answer is:
it sounds easy, but you need to do some homework first, a Survey.
you will need to measure up and create a oval shape (in a paper) with points and percentages of all wifi routers in the camp.
when, lets imagine that you compile 2 routers information, you are ready to go.
get the current wifi points and signal strengths from the user laptop/device and query the database using those values.
give the user their current location.
Example:
in the campus bar you measured that to be in that place you need to have around 55% strength of the signal provided from WiFi Router 1 and 25% of the WiFi Router 2.
To use all this in C#, you should start in this Code Project article to get the signal strengths. Then is just use those returned values with your data that you measured before when doing the first survey.
Hope it helps :) At least, that was what I would do in order to approach this problem.
We did this on a project already determining distance from Access Points, but without the signal triangulation (already covered on other answers here).
I do have a recommendation from the "man, I wish I didn't have to go back and do this" department - it would be to spend extra time on 2 areas:
An easy and repeatable method of calibration using Multiple Data Points. For example, the dropoff from being "very close" to "kinda close" will be a lot more than "really far away" to "really really far" away. It's not going to be a linear slope.
Data Smoothing. As you move, the signal strength will vary unproportionally to your movement (due to obstacles in the path). It will make your results much more accurate if you take a rolling average of the last 5-10 samples of the signal strength rather than just taking the last sample.
You might like to look at the Google Gears Geolocation API. I don't know how easy it is to use from C#, but it may be useful/relevant.
(Disclaimer: I work for Google, but haven't had anything to do with the Geolocation API.)
I wouldn't have thought that signal strength would work well: too many things interfere with it (like walls). But you might try measuring ping times, especially if you threw a hundred pings at the AP and took the average. Most of the time will be the AP digesting the ping and generating the pong, but there will also be a time-of-flight component for the signals. If the AP response time is consistent then you should be able to subtract it and hence compute the distance to the AP. By well-known hyperbolic maths you can then find your position from 3 or 4 APs.
Paul.
Skyhook springs to mind. It depends on people registering the llocation of their APs though.
Goto Wifi in positioning System(WPS), where we use multiple Wifi AP to track a location..
this is implemented by many systems like Google, horizon etc by providing extra security 4 privacy..
I too without knowing this tried on immplimenting this sort of technique..
All d best, we can simplify its complexity by various methods there-by achieving INNOVATIVE to existing infrastructure.
I recommend u to go to the wifi router add-in management & usage before pursing this.
you can try FIND3 project, here's a documentation https://www.internalpositioning.com/doc/, it's API can be used for that purpose and use learning algorithm to constantly learn your position with accuracy. They also have mobile apps (for android only). I'm looking to do something of the same nature.

Categories

Resources