Commit graph

43 commits

Author SHA1 Message Date
ef10ab5998 Adds parent ID to LedPump
Introduces a `parent_organ_id` field to the `LedPump` struct and updates its constructor. This establishes a clear hierarchical link, allowing a `LedPump` instance to identify its containing organ.

Additionally, changes the `last_beat` field type from `u128` to `u64` for optimized storage of beat tracking data.
2026-03-26 14:22:13 +00:00
d5ad70666e Refactors organ system for component modularity
Introduces a `Parenchyma` trait to represent essential functional tissues within an organ, enabling a component-based architecture.

Transforms the `Heart` into a generic `Organ` capable of hosting multiple `Parenchyma` components, centralizing command processing. Adds a new `LedPump` parenchyma as an example component.

Includes an `impl_identifiable!` macro for streamlined implementation of the `Parenchyma` trait and establishes an ID generation system for organs and their components. Renames `OrganCommand::Beat` to `OrganCommand::HeartBeat` for improved clarity.
2026-03-26 08:55:17 +00:00
2439de214b RustyLee: Validates organ responses before command processing
Ensures the brain only processes commands from organs that return an 'Ok' response.

Specifically, the 'Waken' command now requires an 'Ok' response to transition the brain to the 'Awake' state, improving the robustness of inter-organ communication.
2026-03-14 09:50:54 +00:00
33ae160566 RustyLee Cleans up code formatting
Removes unnecessary line breaks and comments, improving code readability and consistency.
Consolidates multi-line function signatures and variable declarations into single lines.
2026-03-14 09:44:17 +00:00
8195a3ccad RustyLee: Adds organ lifecycle state tracking
Introduces a `last_reported_state` field to `OrganSocket` for better management of each organ's lifecycle status.

Updates `OrganSocket` and `Heart` constructors to accept an initial `LifeState`, allowing for more flexible initialization. The `OrganFactory` is adjusted to pass this state during organ creation.

This change provides a centralized mechanism for monitoring the state of all spawned organs.
2026-03-14 09:41:06 +00:00
175e01e361 RustyLee: Adds organ ID to brain messages
Includes a unique identifier for the sending organ in `BrainMessage`.
Enables the Brain to differentiate and respond appropriately to messages from various organs.
Refactors `Brain` method for clearer communication flow.
2026-03-14 09:14:45 +00:00
6bf5809ed8 RustyLee: Implements initial system wake-up protocol
The Brain now broadcasts a 'Waken' command to all connected organs during its startup phase. Organs, like the Heart, transition to an 'Awake' state upon receiving this command and provide feedback. The Brain then updates its own 'LifeState' to 'Awake' once organs acknowledge the wake-up.

This change establishes a fundamental handshake, ensuring that core system functions only activate once the components are initialized and responsive. It introduces the `LifeState::Awake` and `OrganCommand::Waken` states for this purpose.
2026-03-14 09:04:42 +00:00
a353c48d21 RustyLee: Streamlines system lifecycle and organ commands
Removes several `LifeState` variants, focusing on a more essential set of states for the core system.

Eliminates various `OrganCommand` protocols that are no longer needed, reducing the overall complexity of inter-organ communication.

Adjusts the `Brain`'s main loop to actively process organ messages, simplifying its core operational logic.
2026-03-14 07:41:19 +00:00
6ea909347b RustyLee: Enhances Brain's Dead state behaviour and logging
The Brain now actively rests when in the `Dead` lifecycle state, ensuring consistent idle behavior and continuous logging of its status.

Adds the `Display` trait implementation for `LifeState`, providing human-readable representations of lifecycle states for improved debugging output.
2026-03-14 06:15:23 +00:00
793c8eda8d RustyLee: Adds organ heartbeat and system time module
Introduces a dedicated `system::time` module to provide consistent millisecond timestamps throughout the application.

Refactors the `Heart` organ to process `Beat` commands, incorporating a cooldown mechanism to regulate its rhythm.

Updates the `Brain` to periodically request a heartbeat from its organs when in an active lifecycle state, utilizing the new time utilities. Ensures organs are initialized before the brain begins its operational loop.
2026-03-13 18:29:36 +00:00
dbb52ccbb2 RustyLee: Starts Heart organ processing
Activates the Heart organ's main command processing loop by calling its `start` method.

Replaces the previous placeholder `run_loop` method with the functional `start` method. The `start` method now takes a mutable reference to `self`, which enables it to operate as a long-running process without consuming the `Heart` instance.
2026-03-13 15:55:19 +00:00
7633985535 Rust: Establishes core organ communication framework
Introduces `OrganFactory` to manage the creation and spawning of organs, running each in its own thread. `OrganSocket` provides the Brain's interface for sending timestamped commands to specific organs.

Configures new MPSC channels within the Brain to handle bidirectional communication with its organs, enabling command dispatch and feedback reception. The Heart is integrated as the first example organ within this architecture.
2026-03-13 15:47:48 +00:00
33e7de18cf Adds initial organ system and protocols
Establishes the core `organs` module, including a basic `Heart` implementation, to structure internal components.

Introduces a `protocols` layer to define message passing and communication between the `Brain` and various `organs`.

Adds a `coordinates` module with a `Point3D` struct for spatial definitions.

Increases the `Brain`'s resting sleep duration for minor tuning.
2026-03-13 09:06:26 +00:00
ee01746956 Removes redundant brain state definition
The `State` enum, along with its variants (Starting, Running, Stopping, Stopped), is no longer required for managing the brain's operational stages. This change simplifies the codebase by removing an unnecessary abstraction.
2026-03-03 09:39:35 +00:00
58e1197ff4 Integrates signal handling with lifecycle
Refactors the application shutdown mechanism to use lifecycle commands.
OS signals (SIGTERM/SIGINT) now sends a `Dying` command directly to the brain.
The brain processes this command, transitioning through `Dying` to `Buried` state.
The main loop now explicitly waits for the brain to report a `Dead` or `Buried` state before exiting, ensuring a graceful shutdown.
Increases the brain's rest duration and adds debug logging.
2026-03-03 09:37:41 +00:00
500b26703e Enhances lifecycle communication with detailed receipts
Replaces simple string messages sent from the Brain with a structured `LifecycleReceipt` object.

This receipt provides comprehensive feedback, including the original command, a specific response status (e.g., `Ok`, `Refused`), and the resulting `LifeState`. This change improves the clarity, type safety, and debuggability of inter-thread communication between the main God thread and the Brain.
2026-03-03 08:47:30 +00:00
b8137feea5 Refactors main function logic for clarity
Extracts core application setup, brain management, and OS signal handling into dedicated functions.
Improves readability and modularity of the main execution flow.
Removes an unused variable and updates the build number.
2026-03-02 12:50:18 +00:00
4acf07f389 Refactors brain to event-driven lifecycle
Introduces a multi-threaded architecture where the brain operates in its own thread.

Establishes explicit MPSC channels for communication, enabling the main application (God) to send `LifecycleCommand` messages to the brain and receive status updates. This replaces the previous polling-based `update` loop with an event-driven model.

Defines a comprehensive `LifeState` enum for more granular and robust state management. The `LedPump` component is removed as its functionality is superseded by the new command-driven state transitions.

This architectural shift improves separation of concerns and lays the groundwork for more complex and responsive robot control.
2026-03-01 15:19:53 +00:00
92c2ffa9cd Makes build number increment conditional
Introduces an `increment` Cargo feature to control the automatic incrementing of the build number during the build process.

This change prevents the build number from incrementing on every build, providing more control for local development and specific release scenarios. The build number will now only increment when the `increment` feature is explicitly enabled.

Adds `cargo:rerun-if-changed=src/` to ensure the build script re-runs when source files change.
2026-02-28 08:07:07 +00:00
76d1311440 Bumps build number to 102
Reflects the latest successful build iteration for the project.
2026-02-28 07:40:26 +00:00
c201f40d65 Implements automated build numbering
Introduces a build script to automatically increment a build number with each compilation.
This number is combined with the semantic version to create a full version string.
The full version is then exposed to the application and logged at startup, providing a unique identifier for each build to aid in tracking and debugging.
2026-02-28 07:39:45 +00:00
5714b3a396 Introduces periodic beat mechanism
Adds a `LedPump` component to the `Brain` to execute logic periodically while in the `Running` state.

This establishes a basic timing mechanism that currently logs debug messages at a fixed interval, providing a foundation for future timed operations or state transitions. The default logging level is adjusted to `debug` to ensure these periodic events are visible.
2026-02-28 06:55:12 +00:00
3e13aa2261 Flattens brain module structure
Renames the `mod.rs` file for the `brain` module to `brain.rs`.
This simplifies the module path and aligns with standard Rust practices for modules defined entirely within a single file.
2026-02-27 14:46:12 +00:00
c05b771e76 Integrates structured logging with tracing
Replaces existing `println!` statements with `tracing::info!` macros for improved observability and debuggability.

Configures `tracing-subscriber` to enable structured logging, allowing for flexible filtering via `RUST_LOG` and compact, human-readable output by default.
2026-02-26 13:07:19 +00:00
2f0cb6e359 Renames RobotNode to Dixon and adds Rustylee core
Refactors the existing `RobotNode` module by renaming its directory and associated files to `Dixon`. This consolidates the core C++ robot node under a new name.

Introduces the initial `rustylee` module, establishing a foundational structure for the robot's brain. This new Rust component includes:
- A state machine (Starting, Running, Stopping, Stopped) to manage the brain's operational lifecycle.
- Graceful shutdown capabilities using a `ctrlc` signal handler.
- A main watchdog loop that orchestrates state transitions and responds to shutdown requests.
2026-02-26 11:00:48 +00:00
d452578afc Sets up initial Rust project with ARM64 deployment
Introduces the `rustylee` Rust project with a basic "Hello, world!" application.
Configures cross-compilation for `aarch64-unknown-linux-gnu` targets using `cargo.toml`.
Adds a deployment script to automate pushing the compiled ARM64 binary to a remote host.
This enables development and deployment of Rust applications for the target environment.
2026-02-25 07:20:14 +00:00
2125e936dc Centralizes GPIO pin definitions
Moves GPIO pin and chip definitions to a central
constants file for easier management and consistency.

Refactors the heart component to utilize these centralized
constants, enhancing code maintainability and readability.
2026-02-24 16:41:01 +00:00
9159967b83 Moves heart module to cardio directory
Refactors the location of the heart module for better organization and clarity.

Updates the include paths and CMakeLists.txt to reflect the new location.

Increments the version number.
2026-02-22 14:20:10 +00:00
f7818c63ec Refactors source file naming convention
Updates source file names to adhere to a consistent lowercase convention, improving code maintainability and readability.

This change ensures consistency across the codebase and aligns with common coding standards.
2026-02-21 08:23:21 +00:00
b9bfe8df68 Uses DIXON_VERSION macro for version string
Updates the version logging to use the DIXON_VERSION macro.

This allows the version to be dynamically injected at compile time, instead of a hardcoded string.
2026-02-20 17:12:06 +00:00
adda211b76 Improves shutdown handling and adds logging
Adds logging to heart component and signal handler for improved debugging.
Changes signal handler to set a "StopPending" state to allow the main loop to handle shutdown.
Fixes a potential thread join issue during shutdown.
2026-02-20 17:07:10 +00:00
3a4e00a409 Adds basic logging and refactors main loop
Adds a basic logging system using std::clog with color codes for different log levels.
Refactors the main loop to use the logging system and improve readability.
Changes DixonNodeState to use atomic exchange for setting node status and logs status changes.
Removes the old main.cpp and adds a new one that uses a separate thread for signal handling.
Updates the CMakeLists.txt to link against gpiod and spdlog.
Moves version information into a version.txt file and creates a custom target to bump the version using a python script.
2026-02-20 15:27:42 +00:00
e8c3e0f8c2 Updates RobotNode build and deployment process.
Simplifies the RobotNode build process by linking directly to system gpiod libraries instead of including a local copy. This reduces redundancy and ensures compatibility with the system's gpiod installation.

Adds a deployment script for easier deployment to the robot, streamlining the update process.

Also introduces a script to automatically fix symlinks during cross-compilation, ensuring that links resolve correctly on the target system.
2026-02-17 17:13:16 +00:00
Programmer59
07eb6bea15 chore: workstation setup (line-endings and ignore .idea) 2026-02-14 17:10:56 +00:00
Russell Gilbert
c19687d91a Improves Dixon's shutdown and control flow.
Adds signal handling for graceful shutdown via SIGINT and SIGTERM.

Updates the control loop to be interruptible, allowing for a clean exit when a shutdown signal is received.

Changes the node state management to use an enum for clarity and better control the run states (starting, running, stopping, stopped).

The heartbeat is stopped when the node is stopping or stopped.

Also updates the line request to force an inactive state when claiming the pin.

Also updates the version number.
2026-02-12 09:53:29 +00:00
Russell Gilbert
2ccbd2f307 Uses atomic booleans for thread safety
Replaces mutex with atomic booleans in DixonNodeState for improved thread safety. This eliminates the need for explicit locking in the connected_ and brainRunning_ accessors, reducing overhead and potential for deadlocks.

Updates version file.
2026-02-11 07:56:57 +00:00
Russell Gilbert
1da934ba3c Updates executable name and dependency links
Renames the executable to lowercase and updates the corresponding dependency links in CMakeLists.txt.

Introduces a version file to manage the project's version.
2026-02-11 07:43:40 +00:00
Russell Gilbert
b2761dd2db Adds versioning to the robot node
Implements an automatic versioning system for the robot node,
utilizing a `version.txt` file and a Python script to increment
the patch version.

Integrates the version into the CMake build process to ensure
the version is displayed in the robot node's output.
2026-02-08 14:03:47 +00:00
Russell Gilbert
957f789faa Adds heartbeat functionality using GPIO
Introduces a heartbeat mechanism to the robot node using GPIO.
This allows for external monitoring of the node's active state.

The heartbeat is implemented using a GPIO pin that toggles
at a regular interval, indicating that the system is running.

Updates CMakeLists to link the project with gpiod libraries
staged locally.
Adds .gitignore entries for local dependencies and PC build directories.
2026-02-08 12:55:44 +00:00
Russell Gilbert
6a8f4f364b Refactors heart beat mechanism with gpiod
Updates the heart beat mechanism to use a prepared request to control the GPIO line, improving efficiency and code clarity.
Removes the direct line request in the beat function.
Switches to using pkg-config to manage dependencies and linker flags.
2026-02-07 06:44:18 +00:00
Russell Gilbert
5fcedb0fca Initializes project structure for Dixon Robot, config build & link
Sets up the initial project structure for the Dixon robot,
including core components and build configurations.

This commit lays the foundation for future development by:
- Adding necessary `.idea` files for IDE configuration,
  including `.gitignore`, `aws.xml`, `modules.xml`, `vcs.xml`,
  `editor.xml`, and `encodings.xml`
- Creating `Heart` component for managing heart beat with GPIO.
- Setting up CMakeLists.txt to define project dependencies and configurations,
  including specifying C++20 standard and linking necessary libraries.
2026-02-07 04:36:27 +00:00
Russell Gilbert
14336c70d5 Adds basic robot control node structure
Introduces a basic structure for the robot control node. This includes:

- A central brain component that manages the robot's logic.
- A state management system using a singleton to ensure thread-safe access to shared data.
- A simple main loop that can be started and stopped.
- Initial CMakeLists.txt and gitignore configurations.

This provides a foundation for implementing robot control logic.
2025-12-28 10:04:23 +00:00
fd274fef0b
Initial commit 2025-12-28 09:37:09 +00:00