-
Notifications
You must be signed in to change notification settings - Fork 0
Initial Floodfill Code #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AFE123xr
wants to merge
1
commit into
release/stm32maze
Choose a base branch
from
afe123x/floodfill
base: release/stm32maze
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| build/ | ||
| build/ | ||
| testmazes/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,80 @@ | ||
| SRCS = astar.c floodfill.c main.c | ||
| OBJS = $(patsubst %.c,build/%.o,$(SRCS)) | ||
| DEPS = $(OBJS:.o=.d) | ||
| TARGET = build/mazealgo | ||
| CC ?= gcc | ||
| CC ?= gcc | ||
|
|
||
| CFLAGS = -Wall -Wextra -Werror -std=c11 -Og -g -pedantic | ||
| # Build configuration | ||
| BUILD_TYPE ?= debug # options: debug, release | ||
| SANITIZE ?= 1 # 1 to enable sanitizers, 0 to disable | ||
| SIM ?= 1 # 1 to define SIM, 0 to omit | ||
|
|
||
| # Base compiler flags (common to all builds) | ||
| CFLAGS = -Wall -Wextra -Werror -std=c11 -pedantic | ||
| CFLAGS += -Wconversion -Wshadow -Wformat=2 -fstack-protector-strong | ||
|
|
||
| # Configuration-specific flags | ||
| ifeq ($(BUILD_TYPE),debug) | ||
| # make BUILD_TYPE=debug | ||
| CFLAGS += -Og -g | ||
| else ifeq ($(BUILD_TYPE),release) | ||
| CFLAGS += -O2 | ||
| endif | ||
|
|
||
| ifeq ($(SANITIZE), 1) | ||
| CFLAGS += -fsanitize=address,undefined | ||
| endif | ||
|
|
||
| ifeq ($(DEBUG), 1) | ||
| CFLAGS += -DDEBUG | ||
| endif | ||
|
|
||
| ifeq ($(SIM), 1) | ||
| CFLAGS += -DSIM | ||
| endif | ||
| LDFLAGS = | ||
|
|
||
| BUILD = build | ||
| TARGET_ALGO = $(BUILD)/mazealgo | ||
| TARGET_READER = $(BUILD)/socket_reader | ||
|
|
||
| ALGO_SRCS = api.c floodfill.c main.c queue.c | ||
| READER_SRCS = socket_reader.c | ||
|
|
||
| ALGO_OBJS = $(patsubst %.c, $(BUILD)/%.o, $(ALGO_SRCS)) | ||
| READER_OBJS = $(patsubst %.c, $(BUILD)/%.o, $(READER_SRCS)) | ||
| ALL_OBJS = $(ALGO_OBJS) $(READER_OBJS) | ||
| DEPS = $(ALL_OBJS:.o=.d) | ||
|
|
||
| # ── Targets ──────────────────────────────────────────────────────────────────── | ||
|
|
||
| .PHONY: all clean run help | ||
|
|
||
| all: $(TARGET_ALGO) $(TARGET_READER) | ||
|
|
||
| $(TARGET_ALGO): $(ALGO_OBJS) | $(BUILD) | ||
| $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) | ||
|
|
||
| $(TARGET_READER): $(READER_OBJS) | $(BUILD) | ||
| $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) | ||
|
|
||
| $(BUILD)/%.o: %.c | $(BUILD) | ||
| $(CC) $(CFLAGS) -MMD -MP -c $< -o $@ | ||
|
|
||
| $(BUILD): | ||
| mkdir -p $(BUILD) | ||
|
|
||
| # ── Dependency includes ──────────────────────────────────────────────────────── | ||
|
|
||
| -include $(DEPS) | ||
|
|
||
| build/mazealgo: $(OBJS) | ||
| $(CC) -o $@ $^ $(CFLAGS) | ||
| build/%.o: %.c | ||
| mkdir -p build | ||
| $(CC) -MMD -MP -c $< -o $@ $(CFLAGS) | ||
| .PHONY: clean help | ||
| # ── Utility ─────────────────────────────────────────────────────────────────── | ||
|
|
||
| run: all | ||
| $(TARGET_READER) & $(TARGET_ALGO) | ||
|
|
||
| clean: | ||
| rm -rf build | ||
| $(RM) -r $(BUILD) | ||
|
|
||
| help: | ||
| @echo "This project is built using 'make' (see Makefile)." | ||
| @echo "If the README still refers to CMake-based builds, those instructions are legacy." | ||
| @echo "To build the binary used by CI, run: make" | ||
| @echo "To clean build artifacts, run: make clean" | ||
| @echo "Targets:" | ||
| @echo " all - Build mazealgo and socket_reader (default)" | ||
| @echo " run - Build then run both binaries" | ||
| @echo " clean - Remove build artifacts" | ||
| @echo " help - Show this message" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,74 @@ | ||
| # Maze Algorithm Repository | ||
| # Micromouse Maze Algorithm Repository | ||
|
|
||
| This repository will contain the maze algorithm. Right now, it uses a left wall following algorithm. | ||
| This repository provides the template and core interface for developing Micromouse maze-solving algorithms. It includes an adapter for the Micromouse Simulator (MMS) and a skeleton for implementing search algorithms. | ||
|
|
||
| ## how to build | ||
| ## File Structure | ||
|
|
||
| This uses a build tool known as cmake. This will make compilation much easier. There's a `CMakeLists.txt` file which describes what the final executable should look like. | ||
| | File | Description | | ||
| | :--- | :--- | | ||
| | `floodfill.c` | **Primary Logic:** Implement your floodfill or search algorithm here. | | ||
| | `api.c` | The low-level interface used to communicate with the simulator. | | ||
| | `socket_reader.c` | An adapter that connects the MMS to your algorithm, enabling step-by-step debugging. | | ||
| | `queue.c` | A standard queue data structure implementation for use in BFS/Floodfill. | | ||
|
|
||
| ```sh | ||
| mkdir build # if you didn't create a folder named build yet | ||
| cd build # go into build folder | ||
| cmake .. # generate make file and other components | ||
| make # compile your code. You can add j<num-threads> to speed up compilation | ||
| ## Build Instructions | ||
|
|
||
| Use the `make` command with the following optional flags to compile the project: | ||
|
|
||
| ```bash | ||
| make SIM=1 DEBUG=1 SANITIZE=1 | ||
| ``` | ||
|
|
||
| ### Build Flags | ||
|
|
||
| * **`SIM=1`**: Compiles the code specifically for use with the Micromouse Simulator. | ||
| * **`DEBUG=1`**: Enables symbols and configurations for step-by-step debugging. | ||
| * **`SANITIZE=1`**: Enables AddressSanitizer to detect memory leaks and buffer overflows. | ||
|
|
||
| To remove compiled binaries and object files, run: | ||
|
|
||
| - This is expected to be used in conjunction with the micromouse maze simulator | ||
| ```bash | ||
| make clean | ||
| ``` | ||
|
|
||
| ----- | ||
|
|
||
| ## Execution & Simulation | ||
|
|
||
| ## Documentation | ||
| ### 1\. Configure the Simulator | ||
|
|
||
| - https://github.com/mackorone/mms-cpp: the micromouse cpp api | ||
| - https://github.com/mackorone/mms: The micromouse maze simulation program | ||
| Before running your code, open the **Micromouse Simulator (MMS)** and point the configuration to your build directory. | ||
|
|
||
| ## branching conventions | ||
|  | ||
|
|
||
| You'll create a new branch for each problem you're trying to fix. We'll be doing the following convention | ||
| ### 2\. Run the Algorithm | ||
|
|
||
| ```sh | ||
| user/<username>/problem | ||
| Once the simulator is configured and the "Run" button is pressed, execute the binary from your terminal: | ||
|
|
||
| user/afe123x/left-corner-crash #An example branch name, clearly describing what we're working on. | ||
| ```bash | ||
| ./build/mazealgo | ||
| ``` | ||
|
|
||
| When you're done with your work, and ensure it compiles, you can make a pull request. | ||
| ----- | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Branching Convention | ||
|
|
||
| To maintain a clean repository, please use the following naming convention for all new features or bug fixes: | ||
|
|
||
| `user/<username>/<brief-description>` | ||
|
|
||
| **Example:** | ||
| `user/afe123x/left-corner-crash` | ||
|
|
||
| ### Pull Requests | ||
|
|
||
| 1. Ensure your code compiles without errors or warnings. | ||
| 2. Verify that `SANITIZE=1` does not report memory issues. | ||
| 3. Push your branch and open a Pull Request for review. | ||
|
|
||
| ## Resources | ||
|
|
||
| * [MMS Simulation Program](https://github.com/mackorone/mms): The core simulator application. | ||
| * [MMS C++ API](https://github.com/mackorone/mms-cpp): Documentation for the simulator's API and protocol. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.