Creating an Agent

Creating an Agent#

This section provides an overview of how to use the adf-core-python library.

Creating a New Agent#

To create a new agent, run the following command:

adf-core-python

When you run it, an interactive prompt like the following will appear:

Your agent team name: my-agent
Creating a new agent team with name: my-agent

Note

The agent team name is used as the agent directory name. From here on, the agent team name will be referred to as <your_team_name>.

After you enter the values, a template for the agent will be created in the current directory.

.
└── my-agent
    ├── config
       ├── development.json
       ├── launcher.yaml
       └── module.yaml
    ├── main.py
    └── src
        └── my-agent
            ├── __init__.py
            └── module
                ├── __init__.py
                └── complex
                    ├── __init__.py
                    ├── sample_human_detector.py
                    ├── sample_road_detector.py
                    └── sample_search.py

Running the Simulation#

Open two terminals.

Open one terminal and start the simulation server with the following command:

# Terminal A
cd WORKING_DIR/rcrs-server/scripts
./start-comprun.sh -m ../maps/tutorial_fire_brigade_only/map -c ../maps/tutorial_fire_brigade_only/config

Then open another terminal and start the agent:

# Terminal B
cd WORKING_DIR/<your_team_name>
python main.py

If the agent starts successfully, it will connect to the simulation server, join the simulation, and begin moving. If you want to stop it midway, press Ctrl + C in each command line (Command + C on macOS).

Warning

After stopping the simulation server, some processes may remain, so run ./kill.sh.