Brian's Logbook

IDP - Software Documentation

Pub Upd Est #python #microcontroller #raspberry pi
tip
Copyright Notice

This post is licensed under CC BY-NC-ND 4.0.

info
Note

The UML diagrams provided below may not strictly adhere to formal UML standards, as formal UML notation is introduced in fourth year and thus is not a requirement for this project's documentation.

They should, however, clearly and concisely reflect the structure of the project.

Diagrams

Class Diagram

  
classDiagram
    class PathFinder {
        +dijkstras(start: Node, end: Node) List~Instruction~
    }

    class PicoBot {
        +move(instructions: List~Instruction~)
        +turn(is_180: bool)
        +walk()
        +pick_up(node: int)
        +drop_off(depot: int)
    }

    class MissionControl {
        +start()
        +on_bootup()
        +on_finish()
    }

    class ColorSensor {
        +get_colour() str
    }

    class LineSensor {
        +value() bool
    }

    class Motor {
        +Forward(percentage: int)
        +Reverse(percentage: int)
        +off()
    }

    class Servo {
        +rotate(angle: int)
    }

    MissionControl --> PathFinder : calls
    MissionControl --> PicoBot : commands
    PicoBot --> ColorSensor : reads from
    PicoBot --> LineSensor : reads from
    PicoBot --> Motor : operates
    PicoBot --> Servo : operates

Sequence Diagram

  
sequenceDiagram
    actor User
    participant MC as MissionControl
    participant PF as PathFinder
    participant PB as PicoBot
    participant LS as LineSensor
    participant CS as ColorSensor
    participant M as Motor
    participant SM as Servo

    User ->> MC: Press button to start mission
    MC ->> PF: dijkstras(start, target)
    PF -->> MC: Returns list of instructions

    MC ->> PB: move(instructions)

    loop Execute each instruction
        PB ->> M: Execute TurnInstruction or WalkInstruction
        PB ->> LS: Check line sensors for line following
        LS -->> PB: Direction correction
    end

    MC ->> PB: pick_up()
    PB ->> SM: Rotate servo to pick up box
    PB ->> CS: Check color sensor
    CS -->> MC: Return detected color

    MC ->> PF: dijkstras(target, depot)
    PF -->> MC: Returns list of instructions

    MC ->> PB: move(instructions)

    loop Execute each instruction
        PB ->> M: Execute TurnInstruction or WalkInstruction
        PB ->> LS: Check line sensors for line following
        LS -->> PB: Direction correction
    end

    MC ->> PB: drop_off()
    PB ->> SM: Rotate servo to drop off box

    MC ->> MC: Loop back to step 2 with a new target node