How can I communicate with another agent (anylogic) within certain vision angle? - java

I am trying to do modeling using Anylogic pedestrian library where an agent (A) will communicate with another agent (B) only if the other agent is within certain vision angles and arc radius of A. The conventional way of communication is to define certain distance based communication where the distance defined forms a sphere around the agent. But I want to model that the agent will not be able to communicate with other agents who are not within his vision angle (like a conical projection & certain distance). For example, the agent should not be able to communicate with others who are behind him. How I can do this?
Also, I am trying to model individual agents behavior (those abovementioned pedestrian agents) through agents statechart. Unfortunately, agent states aren't changing based on communication in my model. Is it due to using pedestrian library? Can we model pedestrian agents behaviour by statechart?
It would be a great help if someone can answer those questions.

you can use just a polygonal node or area and use it like this:
if you want to evaluate if a pedestrian or agent is in the field of vision, you need to get x and y for that agent and do:
if(fieldOfVision.contains(x,y))
//communicate with that dude

Related

How to draw public transport route using google map?

I am working with the Android project. I want to draw the route between two points which is showed public transport routes like bus and train, not the shortest route. I am using google direction API and google map API.
I want to just make it like google map where they show the suggestion of bus and times like this when we choose locations.
is there any special API for public transport route?
you can use mode parameter in directions api like this
https://maps.googleapis.com/maps/api/directions/json?
origin=place_id:ChIJ685WIFYViEgRHlHvBbiD5nE
&destination=place_id:ChIJA01I-8YVhkgRGJb0fW4UX7Y
&mode=transit
&key=YOUR_API_KEY
Travel Modes When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. The following travel modes are supported:
driving (default) indicates standard driving directions using the
road network.
walking requests walking directions via pedestrian paths &
sidewalks (where available).
bicycling requests bicycling directions via bicycle paths &
preferred streets (where available).
transit requests directions via public transit routes (where
available). If you set the mode to transit, you can optionally
specify either a departure_time or an arrival_time. If neither time
is specified, the departure_time defaults to now (that is, the
departure time defaults to the current time). You can also optionally
include a transit_mode and/or a transit_routing_preference.

Extending ArcGIS

I've been tasked with a thesis project where i have to extend the features of ArcGis. I've been asked to create a model written in Python that can run out of ArcGIS 10. This model will have a simple user interface where the user can drag/drop a variety of shapefiles and enter the values for particular variables in order for the model to run effectively. Once the model has finished running, a new shapefile is created that lays out the most cost effective Collector Cable route for a wind turbine from point A to point B.
I'd like to know if such a functionality/ extension already exists in ArcGIS so i don't have to re-invent the wheel. If not then what is the best programming language to learn to extend ArcGIS for this (Python vs Visual basic vs Java). My background is Java, PHP, Jquery and Javascript. Also any pointers in the right direction i.e documentation, resources etc would be hugely appreciated
You must understand EXACTLY how it should work and where the tool should place all input and output datasets, their structures, attribute table fields and so on.
There is only one person who knows all these stuff - and it is You.
And it is not "the wheel", but it is a custom tool. You can build a model in built-in model builder (the great thing) and then export the model into a Python script.
Check this video http://www.youtube.com/watch?v=mBSXBqEP-7Y
And again. You have to know: 1) Input datasets and parameters 2) What do you want to get as the output 3) How it should work
I do stuff like this every day for my day job in customizing ArcGIS for utility companies like gas, water, and electric. We create buttons for them that does similar things like - draw a service gas line from the gas meter point on the side of the house to the nearest point on the nearest gas main line, split the main at that point, insert a "T" point feature, and connect the service line from the "T" to the meter.
We mostly use C# and a bit of VB.net. You may want to look into creating a Python Add-in for something like ArcGIS Explorer. Or an Add-in for ArcMap.
Explorer and ArcMap let you add shapefiles as layers in the map. Add-ins let you easily add a button to the toolbar that can do things to the features on the map like query their attributes and modify their attributes and geometry to move them around on the map, as well as create new features and fill out attributes and place them on the map with X,Y or Lat/Long.
So your "Calculate Best Cable Route" tool could be a button your create on the toolbar (ICommand) that would first:
1. let the users select point A and point B on the map using the built in selection tools in Explorer/ArcMap.
2. let the users click your custom ICommand button.
3. your ICommand.OnClick() method would then execute all the code to try different routes based on geometry of other features on the map like street edges, building outlines, property lines, etc. then calculate the total cost like digging in dirt, asphalt, and getting permission/Right of way for cases where it goes over property lines.
See the ArcGIS ArcObjects API here to get started:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ICommand_Interface/00430000001s000000/
Creating a Python AddIn is probably the quickest and easiest approach if you just want to do some geoprocessing and deploy the tool to lots of users.
But as soon as you need a user interface (that does more than simply select GIS data sources) you should create a .Net AddIn (using either C# or VB.net).
I've created many AddIns over the years and they are a dramatic improvement to the old ArcGIS "plugins" that involved lots of complicated COM registration. AddIns are easy to build and deploy. Easy for users to install and uninstall.
.Net has excellent, powerful features for creating rich user interfaces with the kind of drag and drop that you require. And there are great books, forums, samples to leverage.

android automatic route for pedestrians

I would like to develop an Android application that allows users (pedestrians) to follow an automatically generated route.
Users would specify how far they wish to walk, whether they must return to their stating position, avoid hills, dangerous roads, not cross any roads, how fast they walk on avergae, etc.
i have been searching for a java based library or service that generates a route but have failed.
can anyone recommend a java library that will automatically generate a route?
Interesting idea. I've never seen any library or available implementation that matches your requirements exactly. What you are attempting to do, though, is basic route optimization.
Look at some combination of the google directions API (https://developers.google.com/maps/documentation/directions/) and a set of pre-defined (that you set up) waypoints around the city. The waypoints represent nodes in your "graph" and the edges are routes between them. Waypoints have coordinates so you can map them. Then you assign weight (preference) to each edge and use google to calculate the distance between the waypoints. Extract the routes that match your distance preference and then pick the one with the best "weight" preference.

representing a topological map using java

I'm developing a indoor navigation program for android, and i'm stuck right at the beginning:
How do you represent a map in java?
I will prefer a way that will allow me to apply Dijkstra's algorithm easily.
note: i need the program to know the size of each room and where are the entrances and exits.
edit: i'm looking for a object to use in the BL not the UI
Android has a built-in GUI element called a mapView that you can add to a screen in your application. It is a Google map and will require you to obtain your applications API key. You can add overlays to it and locate points on the map based on latitude and longitude (I think it supports other methods as well) and these points could be used for Dijkstra's algorithm.
Hope this helps, good luck.
I think, what you are describing is a extended topological map (where you have an estimate on the nodes absolute location). So you basically need a component that can draw a graph with locations attached to the nodes. Also, you might want the possibility to draw addistional stuff (like heat maps for wifi connectivitiy, bluetooth devices or whatever you are using to estimate your position and gather information about the environment). You are also dealing with the SLAM problem.
I don't know of any existing component that can do the visual task for that, but maybe you find something with google. I wouldn't however recommend it. I would just create my own component (using a TextView and draw my stuff on that). It is much more flexible, not that much of an effort and you can choose the functionality and data format, which can be very helpful in such cases...
Once you have all the rest running (which is a lot!), you still can decide to look for some fancy component that may integrate even google maps, is able to zoom or so.

What are possible ways to send Game/Simulation State with javaNIO?

i heard this phrase quite often to "send the game state or simulation state " in network game/simulation realm and my question is stem from that and i really need to know how? .
I m working on real time network physics simulation, my question is only that :
*How simulation state can be transfer from server to client*? (the least simulation state are the coordinates X,Y of simulated bodies=))
Possible scenario: taking the example of simple ball simulation, the server is moving the multiple balls and should send coordinates of each ball to client for drawing and updating simulation, and each ball should move according to its received coordinates from the sever.
thanks,
jibbylala
P.S: please don't mention any string based solution i am looking for generic mechanism which can be applicable on different Physics simulation.
In fast paced action games, the state of dynamic objects is sent constantly in structures. By state I mean it is usually position and rotation. Depending on model's architecture, it can be server constantly pushing the states, or sending the change in state when it occurs. More often the first one. When the state is not received in some period of time the game lag occurs. The state can also have parameters such as velocity, acceleration, etc. really depends on game and on how you want to handle game events. Lets say we are writing simple 2D game with flying ships on surface then the state could be a simple class in java like:
class ShipState{
public float x;
public float y;
public float angle;
}
The netcode in game takes care of transporting these structures. Games usually have their own protocol built on top of TCP/IP and UDP to handle everything, since there is lot of different type of information going both ways in real games, not just physical state. If you are serious about your project, you should really look into networking libraries. I strongly doubt there is anything really good, since JAVA is not very popular on this frontier. Single google request brought up this Kryo library which seems pretty good. You could also probably look into netty, which is a very solid general purpose networking library. If I was to write a netcode for game in Java I would just go and dig up open source game networking libraries written in C/C++, such as Enet to get some ideas.
Getting to the bottom of your question, regarding the ball simulation on server, it is as simple as server sending ball coordinates and clients receiving those. If you are not sure how it is done, you probably want to look at these tutorials. And other general Java networking tutorials. Good luck!

Categories

Resources