Darkmik70/arp_drone

Create SHM Server

Darkmik70 opened this issue · 1 comments

The Blackboard server works as the central information hub: It should maintain the current state of the simulation, including the drone's position, velocity, information about targets, obstacles, and any other relevant env data.

The server is the intermediary for communication between different processes, such as receiving input from Keyboard Manager and passing the commands to Drone Dynamics, and also updating UI with latest simulation state.

Logging: Optionally, the Server could maintain a log of events and state changes for debugging and monitoring purposes - This can also be done by the monitoring process.

Few thoughts on specific components

  1. Server has access to different data structures to stor the simulation state efficeintly. This includes structures to represent the drone, obstacles, and targets in memory.

  2. We need to implement mechanisms like mutexes and semaphores to ensure data consistency when accessed by multiple processes.

  3. The performance of server is critical. We need to ensure the scalability of it for future assignments.

  4. Error Handling: Robust error handling to manage and recover from unexpected situations, ensuring the simulation continues to run smoothly.

Modularity: Keeping the Server's functionality modular will help in maintaining and updating the system.

Interaction with Other Components

  1. With Keyboard Manager: Receives user inputs, interprets them, and updates the drone's command forces accordingly.

  2. With Drone Dynamics: Sends the command forces to the Drone Dynamics for calculating the drone's movement. It also receives updates on the drone's position and velocity.

  3. With User Interface: Regularly updates the UI component with the latest state of the simulation for rendering to the user.

  4. With Watchdog: Communicates its status to the Watchdog process, ensuring that it's functioning correctly and hasn't encountered any critical errors.

Assignments V2.1 (2)..pdf

Based on the previous comment I asked gpt to prepare a pseudocode of this file. @jetinoco98 maybe this will help a little.

Make sure to divide it into .c and .h files

// Import necessary libraries for IPC, Shared Memory, Synchronization, etc.

// Define Data Structures
struct DroneState {
    float positionX, positionY;
    float velocityX, velocityY;
    // Additional drone parameters...
}

struct SimulationState {
    DroneState drone;
    List<Obstacle> obstacles;
    List<Target> targets;
    // Additional environmental parameters...
}

// Initialize Shared Memory and Synchronization Mechanisms
function initializeServer() {
    sharedMemory = createSharedMemory(SimulationState);
    mutex = createMutex();
    // Initialize other synchronization and IPC mechanisms
}

// Update Drone State based on Input from Keyboard Manager
function updateDroneState(Command command) {
    lock(mutex);
    SimulationState state = readSharedMemory(sharedMemory);
    // Logic to update drone's state based on the command
    writeSharedMemory(sharedMemory, state);
    unlock(mutex);
}

// Main Server Loop
function mainServerLoop() {
    while (true) {
        checkForIncomingCommands();
        processCommands();
        updateSimulationState();
        communicateWithOtherComponents();
        // Optional: Logging, Error Handling, etc.
    }
}

// Entry Point of the Program
function main() {
    initializeServer();
    mainServerLoop();
}