Table of Contents
*Please ensure that you have yarn
installed.
- In the
/simulator
directory, install the required dependencies.
yarn
- In the same directory, start the application.
yarn start
And you are ready to start using the Algorithm Simulator! The application is running on http://localhost:3000. The page will reload when you make changes.
- In the
/algorithms-python
directory, create a python virtual environment and activate it.
python -m venv .venv
. .venv/Scripts/activate # The .venv activation command might differ depending on your operating system
- Install the required packages.
pip install -r requirements.txt
- In the same directory (
/algorithms-python
), start the application.
uvicorn main:app --reload
And you are ready to start using the Algorithm Server! The server application is running on http://127.0.0.1:8000/
Script for quick startup:
cd algorithms-python
. .venv/Scripts/activate
uvicorn main:app --reload
📁 arena/
: Defines theMap
andObstacle
class and configure anything related to the navigational area.📁 common/
: Contains commonly used variables and functions. E.g.:constants
,enums
,types
, andutils
.📁 path_finding/
: The main algorithm related code can be found here!⭐📁 robot/
: Defines the Robot'smoves
andstm_commands
required to be interpretated by the Robot.📁 simulator/
: Contains the python version of the simulator (Not used).📁 tests/
: Contains python tests to test specific functionality
👉🏻 Entry Point: main.py
This is where the app creates an instance of the algorithm and search for the shortest hamiltonian path based on the input obstacles.
- Take a quick glance at the
📁 common/
directory'sconsts.py
,enums.py
,types.py
, andutils.py
to have a generic understanding of the app (except the algo). - Read and understand
path_finding/astar.py
.- Note the output of the
search()
method.
- Note the output of the
- Read and understand
path_finding/path_validation.py
. - Read and understand
path_finding/hamiltonian_path.py
.- This class calls the Astar search method defined in the
astar.py
. - Likewise, note the output of the
search()
method of this class.
- This class calls the Astar search method defined in the
- [Optional] Read and understand
path_finding/dubins_path.py
(will not be used as the main algo due to the robot's actual curve not being a perfect circle). - Read
robot/stm_commands.py
to understand how the algorithm outputs are converted into stm commands.- You might need to modify the
convert_segments_to_commands()
method if your schema defined by the STM / Robot is different.
- You might need to modify the
- Read
main.py
'smain
method to see how everything ties together.
This Algorithm Repo uses FASTAPI and HTTPS + JSON protocol to transmit infomation to/fro the simulator/robot.
{
cat: "obstacles",
value: {
obstacles: {
id: int, // obstacle_id
x: int, // in grid format
y: int, // in grid format
d: int, // direction of obstacle; 1: North; 2: South; 3: East; 4: West
}[],
mode: 0 | 1, // 0: Task 1; 1: Task 2
},
server_mode: "simulator" | "live" | null, // Optional
algo_type: "Exhaustive Astar" | "Euclidean" | "Breadth First Search" | null // Optional
}
Example:
{
"cat": "obstacles",
"value": {
"obstacles": [
{
"id": 1,
"x": 8,
"y": 12,
"d": 2
}
],
"mode": 0
},
"server_mode": "live",
"algo_type": "Exhaustive Astar"
}
{
positions: {
x: int, // in cm
y: int, // in cm
theta: float // in radian
}[]
}
{
commands: {
cat: "control",
value: string,
end_position: {
x: int, // in cm
y: int, // in cm
d: int // Robot Face -> 1: North; 2: South; 3: East; 4: West
}
}[]
}