Comments (2)
See fa15b1e
from matrx.
Using the weighted pathplanner
- Add objects to your MATRX world with the
traversability_penalty
property, with a value > 0 and < 1, in addition to theis_traversable
option (True or False). The agent will try to avoid objects with a hightraversability_penalty
(but will still walk over them if the path is much shorter). - In the
initialize
function of your agent, initialize the navigator to use the newNavigator.WEIGHTED_A_STAR_ALGORITHM
and with its settings like so:
# Initialize this agent's state tracker
self.state_tracker = StateTracker(agent_id=self.agent_id)
self.navigator = Navigator(agent_id=self.agent_id, action_set=self.action_set, algorithm=Navigator.WEIGHTED_A_STAR_ALGORITHM, algorithm_settings={"traversability_penalty_multiplier": 10})
For an example of an entire agent using the new pathplanner see this file: https://github.com/matrx-software/matrx/blob/319_custom_pathplanner(s)/matrx/agents/agent_types/patrolling_agent.py
Tweaking the weighted pathplanner
By increasing traversability_penalty_multiplier
in the algorithm_settings
above, the algorithm will try to avoid objects more aggresively with a traversability_penalty
.
You can calculate this as follows:
For an agent that uses the pathplanner, normally 1 step sideways or upwards has a 'cost' of 1. However, if there is a object on route with a traversability_penalty=0.5
and the {traversability_penalty_multiplier": 10}
, then walking over that object has a cost of 0.5*10=5
, thus equal to walking over 5 normal tiles.
In this way, the agent will avoid to walk over this object. However, if the alternative is more than 5 normal tiles longer, it will opt t o walk over the slow tile instead.
Creating a custom pathplanner
It is also possible to create a new pathplanner, e.g. with a different pathplanner algorithm, or one that completely ignores the is_traversable
such as maybe a drone would do. To do so:
- Change the navigator settings in your agent's initialize function as so:
self.navigator = Navigator(agent_id=self.agent_id, action_set=self.action_set, algorithm="name_of_your_pathplanner",, custom_algorithm_class=YourCustomPathPlannerClass, traversability_map_func=your_custom_traversability_map_function, algorithm_settings={"settings_specific_to_your_pathplanner": True})
- Create the
traversability_map_function
that takes the current agent state, and converts it into a map of what is traversable and what not for your algorithm. See here for an example. - Create a class for your pathplanner that takes the agent's action set (in what directions can it move) and settings for your algorithm. It should return a list of locations to traverse from the current location to the goal location. See here for an example.
from matrx.
Related Issues (20)
- Team name assignment is ignored for agents
- Add state.state_update documentation and refactor
- `state.get_room_objects` doesn't work HOT 4
- Grabbing and dropping an object changes the obj ID HOT 2
- Make state available in object `update()` function
- Bug in function state.get_room_doors HOT 1
- Create MATRX tutorial(s) and fix existing tutorials HOT 4
- remove waypoint function HOT 3
- Navigator `get_all_waypoints` does not return updated waypoints HOT 1
- State get_closest_with_property function doesn't give closest object HOT 2
- Door object has hardcoded customizable properties HOT 1
- Customizable properties not being passed for custom objects HOT 4
- Carrying objects with two agents? HOT 5
- Is it possible to use async in agent actions? HOT 2
- change_property of object cannot change img_name HOT 2
- Allow sending human message while busy HOT 5
- V2 simulation goals throw an error
- Change agent image size during simulation HOT 7
- Changing an agent's visualization properties on run time fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matrx.