diff --git a/doc/architecture/interfaces/interfaces.md b/doc/architecture/interfaces/interfaces.md deleted file mode 100644 index c6192aa..0000000 --- a/doc/architecture/interfaces/interfaces.md +++ /dev/null @@ -1,169 +0,0 @@ -# ROS2 Interface Definitions - g2_2025_interfaces - -## Package Overview - -This document describes the custom ROS2 interface definitions in the `g2_2025_interfaces` package. These interfaces provide standardized communication protocols for the TI Minor Grade Generator system. - -**Package Name**: `g2_2025_interfaces` -**Interface Types**: Messages, Services, Actions -**Location**: `src/g2_2025_interfaces/` - -## Message Types (.msg) - -### Exam.msg - -Represents examination result data exchanged between system components. - -``` -string student_name -string course_name -int32 result -builtin_interfaces/Time timestamp -``` - -**Field Descriptions**: -- `student_name`: Name identifier for the student -- `course_name`: Course identifier for the examination -- `result`: Numerical exam result/grade (integer value) -- `timestamp`: Timestamp of the message - -**Usage**: Primary message type for exam result communication between ExamResultGenerator and grade processing nodes. - -### Student.msg - -Represents student information and course enrollment data. - -``` -string student_name -string course_name -builtin_interfaces/Time timestamp -``` - -**Field Descriptions**: -- `student_name`: Name identifier for the student -- `course_name`: Course identifier for enrollment/management -- `timestamp`: Timestamp of the message - -**Usage**: Used for student-course management operations and enrollment tracking. - -## Service Definitions (.srv) - -### Exams.srv - -Service interface for grade calculation operations using multiple exam results. - -#### Request -``` -string student_name -string course_name -int32[] exam_grades -``` - -#### Response -``` -int32 result # Final calculated result -``` - -**Request Fields**: -- `student_name`: Student identifier for grade calculation -- `course_name`: Course identifier for context -- `exam_grades`: Array of exam grades to be processed - -**Response Fields**: -- `result`: Final calculated grade result (integer value) - -**Usage**: Main service interface used by GradeCalculator node for processing multiple exam grades into final results. - -## Action Definitions (.action) - -### Retake.action - -Action interface for managing retake exam scheduling and processing workflows. - -#### Goal -``` -string student_name -string course_name -``` - -#### Result -``` -float32 result -``` - -#### Feedback -``` -string status -``` - -**Goal Fields**: -- `student_name`: Student for which a retake is requested -- `course_name`: Course for which a retake is requested - -**Result Field** -- `result`: Progress indicator or intermediate result (float value) (*Not Implemented*) - -**Feedback Field**: -- `status`: Status indicator (*Not Implemented*) - -**Usage**: Used by RetakeScheduler node to handle long-running retake management operations with progress feedback. - -## Node Interface Usage - -### ExamResultGenerator Node - -**Publishers**: -- **Topic**: `exam_results` -- **Message Type**: `g2_2025_interfaces::msg::Exam` -- **Purpose**: Publishes generated exam results to downstream processing nodes -- **Rate**: Configurable interval (default: 2 seconds) - -**Subscribers**: -- **Topic**: `student_course_management` -- **Message Type**: `g2_2025_interfaces::msg::Student` -- **Purpose**: Receives student-course enrollment updates for exam generation queue - -### FinalGradeDeterminator Node - -**Subscribers**: -- **Topic**: `exam_results` -- **Message Type**: `g2_2025_interfaces::msg::Exam` -- **Purpose**: Collects exam results for grade calculation processing - -**Service Clients**: -- **Service**: `calculate_grade` -- **Service Type**: `g2_2025_interfaces::srv::Exams` -- **Purpose**: Requests grade calculation from GradeCalculator when threshold is met - -**Publishers**: -- **Topic**: `student_course_management` -- **Message Type**: `g2_2025_interfaces::msg::Student` -- **Purpose**: Communicate end of enrollment when grade has been calculated - -### GradeCalculator Node - -**Service Servers**: -- **Service**: `calculate_grade` -- **Service Type**: `g2_2025_interfaces::srv::Exams` -- **Purpose**: Provides grade calculation services for multiple exam grades -- **Processing**: Applies business logic (averaging, bonus points, validation) - -### RetakeScheduler Node - -**Action Servers**: -- **Action**: `retake_request` -- **Action Type**: `g2_2025_interfaces::action::Retake` -- **Purpose**: Handles long-running retake scheduling operations -- **Feedback**: Provides progress updates during scheduling process - -### RetakeGradeDeterminator Node - -**Service Clients**: -- **Service**: `calculate_grade` -- **Service Type**: `g2_2025_interfaces::srv::Exams` -- **Purpose**: Requests specialized retake grade calculations - -**Subscribers**: -- **Topic**: `retake_results` -- **Message Type**: `g2_2025_interfaces::msg::Exam` -- **Purpose**: Processes completed retake exam results diff --git a/doc/architecture/nodes/ExamResultGenerator.md b/doc/architecture/nodes/ExamResultGenerator.md deleted file mode 100644 index ff760e8..0000000 --- a/doc/architecture/nodes/ExamResultGenerator.md +++ /dev/null @@ -1,42 +0,0 @@ -# ExamResultGenerator (`assignments::one::exam_result_generator`) - -## Overview -The `ExamResultGenerator` is the core node responsible for simulating exam result generation. -It maintains a queue of student-course combinations that need exam results, generates random -grades, and publishes them to the system. - -#### Implementation Details - -**Parameters** - -- **`delay_between_grades_ms`** (int, default: 2000): Delay (in milliseconds) between generated grades. - -**Constructor** -```cpp -ExamResultGenerator() -``` -- Initializes ROS2 node with name `exam_result_generator` -- Sets up random number generation infrastructure -- Creates DatabaseManager instance with node logger -- Establishes ROS2 publishers, subscribers, and timers -- Loads initial pending combinations from database - -**Core Functions** - -**`void queue_pending_combinations()`** -- Gets all student-course combinations needing exam results -- Populates operations queue from database -- Called at initialization and when database state changes - -**`void generate_random_result()`** -- Main exam result generation executed by timer -- Selects random student-course combination from queue -- Stores result in database and publishes to ROS2 topic - -**`void student_management_callback(const g2_2025_interfaces::msg::Student::SharedPtr msg)`** -- Toggles combinations in/out of processing queue -- Updates database with new enrollments - -**`void add_student_course_combination(const StudentCourse& sc)`** -- Enrolls student into course via database -- Adds combination to processing queue diff --git a/doc/architecture/nodes/FinalGradeDeterminator.md b/doc/architecture/nodes/FinalGradeDeterminator.md deleted file mode 100644 index 13395a2..0000000 --- a/doc/architecture/nodes/FinalGradeDeterminator.md +++ /dev/null @@ -1,39 +0,0 @@ -# FinalGradeDeterminator (`assignments::one::final_grade_determinator`) - -## Overview -The `FinalGradeDeterminator` node collects exam results for student-course combinations, triggers grade calculation when enough results are gathered, and stores final grades in the database. It interacts with ROS2 publishers, subscribers, and service clients to manage the grading workflow. - -#### Implementation Details - -**Parameters** - -- **`grade_collection_amount`** (int, default: 5): Number of exam results required before triggering grade calculation for a student-course combination. - -**Constructor** -```cpp -FinalGradeDeterminator() -``` -- Initializes ROS2 node with name `final_grade_determinator` -- Declares and retrieves `grade_collection_amount` parameter -- Sets up `DatabaseManager` -- Creates publisher for student course management -- Subscribes to exam results topic -- Initializes service client for grade calculation - -**Core Functions** - -**`void exam_results_callback(const g2_2025_interfaces::msg::Exam::SharedPtr msg)`** -- Updates internal map with received exam result for student-course combo -- Checks if enough results have been collected -- Triggers grade calculation request when threshold is met - -**`void grade_calculator_request(StudentCourse combo)`** -- Waits for grade calculator service to be available -- Sends async request with collected exam grades for the student-course combination -- Uses callback to handle service response - -**`void grade_calculator_response(rclcpp::Client::SharedFuture future, StudentCourse studentCourseCombo)`** -- Verifies database connection -- Publishes final student message to ROS2 topic -- Logs final grade information -- Stores final course result in database diff --git a/doc/architecture/nodes/GradeCalculator.md b/doc/architecture/nodes/GradeCalculator.md deleted file mode 100644 index 0e90fd5..0000000 --- a/doc/architecture/nodes/GradeCalculator.md +++ /dev/null @@ -1,25 +0,0 @@ -# GradeCalculator (`assignments::one::grade_calculator::GradeCalculator`) - -## Overview -The `GradeCalculator` node provides a ROS2 service for calculating student exam grades. It processes exam scores, applies custom logic for specific student names, and ensures grade results are within valid bounds. - -#### Implementation Details - -**Constructor** -```cpp -GradeCalculator() -``` -- Initializes ROS2 node with name `grade_calculator` -- Creates a ROS2 service server for `grade_calculator_service` -- Binds the service callback to handle grade calculation requests -- Logs service startup - -**Core Functions** - -**`void grade_calculator_callback(const Exams::Request::SharedPtr request, const Exams::Response::SharedPtr response)`** -- Checks if exam grades are provided -- Calculates the total and average of exam grades -- Converts student name to lowercase for comparison -- Adds a bonus of 10 points if the student name is "wessel" -- Ensures the final grade is clamped between 10 and 100 -- Sends the calculated grade back through the service response diff --git a/doc/architecture/nodes/IMUDatabaseWriter.md b/doc/architecture/nodes/IMUDatabaseWriter.md new file mode 100644 index 0000000..d48b422 --- /dev/null +++ b/doc/architecture/nodes/IMUDatabaseWriter.md @@ -0,0 +1,29 @@ +# IMUDatabaseWriter (`assignments::two::imu_database_writer`) + +The `IMUDatabaseWriter` node subscribes to IMU sensor data (`sensor_msgs/msg/Imu`) and saves published data into the PostgreSQL database via the `DatabaseManager`. It is a lightweight sink node intended record IMU measurements (linear acceleration and angular velocity) together with timestamps. + +## Implementation Details + +**Parameters** + +- No node-specific parameters are required by default. Database connection and table configuration are handled by `DatabaseManager` and the project's `ConfigManager`. + +**Constructor** +```cpp +IMUDatabaseWriter() +``` +- Initializes ROS2 node with name `imu_database_writer` +- Creates `DatabaseManager` instance +- Creates a subscription to the `imu_data` topic using `sensor_msgs::msg::Imu` + +## Core Functionality + +**`void imu_data_callback(const sensor_msgs::msg::Imu::SharedPtr msg)`** +- Primary callback invoked whenever an IMU message is received +- Forwards: linear acceleration (x, y, z) and angular velocity (x, y, z) to `DatabaseManager::store_imu_data` + +## ROS2 Interface + +**Subscriptions** +- `imu_data` (sensor_msgs/msg/Imu) + - Receives raw IMU samples. diff --git a/doc/architecture/nodes/RetakeGradeDeterminator.md b/doc/architecture/nodes/RetakeGradeDeterminator.md deleted file mode 100644 index dec9d18..0000000 --- a/doc/architecture/nodes/RetakeGradeDeterminator.md +++ /dev/null @@ -1,60 +0,0 @@ -# RetakeGradeDeterminator (`assignments::one::retake_grade_determinator`) - -## Overview -The `RetakeGradeDeterminator` node handles the processing of retake exams for students who have -failed courses. It provides a ROS2 action server that accepts retake requests, manages exam result -collection for retake scenarios, and coordinates with the grade calculator service to determine -final retake grades. - -#### Implementation Details - -**Parameters** - -- **`grade_collection_amount`** (int, default: 5): Number of exam results required before triggering grade calculation for a retake student-course combination. - -**Constructor** -```cpp -RetakeGradeDeterminator(std::unique_ptr db_manager = nullptr) -``` -- Initializes ROS2 node with name `retake_grade_determinator` -- Sets up `DatabaseManager` (optional injection for testing) -- Creates publisher for student course management -- Subscribes to exam results topic with retake-specific callback -- Initializes service client for grade calculation -- Creates ROS2 action server for retake requests with reentrant callback group - -**Core Functions** - -**`void exam_results_callback(const g2_2025_interfaces::msg::Exam::SharedPtr msg)`** -- Only processes exam results when `retake_allowed_` flag is true -- Triggers grade calculation request when threshold is met - -**`void grade_calculator_request(StudentCourse combo)`** -- Waits for grade calculator service to be available -- Sends async request with collected retake exam grades - -**`void grade_calculator_response(rclcpp::Client::SharedFuture future, StudentCourse studentCourseCombo)`** -- Clears collected exam data from internal map -- Updates retake status in database for the student-course combination -- Publishes final student message to ROS2 topic with timestamp -- Stores final course result in database with retake flag set to true - -**Action Server Callbacks** - -**`rclcpp_action::GoalResponse goal_callback(const rclcpp_action::GoalUUID& uuid, std::shared_ptr goal)`** -- Accepts retake goal requests for specific student-course combinations -- Logs received retake requests with student and course information -- Returns `ACCEPT_AND_EXECUTE` for all valid requests - -**`rclcpp_action::CancelResponse cancel_callback(const std::shared_ptr> goal_handle)`** -- Handles retake action cancellation requests -- Returns `ACCEPT` for all cancellation requests - -**`void spawn_callback_thread(const std::shared_ptr> goal_handle)`** -- Creates detached thread for asynchronous retake action execution -- Ensures non-blocking retake processing - -**`void async_execute_callback_thread(const std::shared_ptr> goal_handle)`** -- Enables retake exam processing by setting `retake_allowed_` flag -- Publishes student enrollment message to trigger exam generation -- Creates and returns successful action result diff --git a/doc/architecture/nodes/RetakeScheduler.md b/doc/architecture/nodes/RetakeScheduler.md deleted file mode 100644 index c4f6c79..0000000 --- a/doc/architecture/nodes/RetakeScheduler.md +++ /dev/null @@ -1,47 +0,0 @@ -# RetakeScheduler (`assignments::one::retake_scheduler`) - -## Overview -The `RetakeScheduler` node automatically identifies students who have failed courses and schedules retake exams for them. It periodically queries the database for failing students and sends retake action requests to the `RetakeGradeDeterminator` node to initiate the retake process. - -#### Implementation Details - -**Parameters** - -- **`retake_check_interval_sec`** (int, default: 120): Time interval in seconds between checks for failing students requiring retakes. - -**Constructor** -```cpp -RetakeScheduler(std::unique_ptr db_manager = nullptr) -``` -- Initializes ROS2 node with name `retake_scheduler` -- Sets up `DatabaseManager` (optional injection for testing) -- Creates ROS2 action client for retake action communication -- Initializes wall timer for periodic failing student checks - -**Core Functions** - -**`void check_failing_students()`** -- Timer callback function executed periodically based on `retake_check_interval_sec` -- Queries database for all failed course results -- Iterates through failing students and initiates retake requests - -**`void send_retake_request(StudentCourse student_course_combo)`** -- Creates retake action goal with student and course information -- Sends asynchronous retake goal to `RetakeGradeDeterminator` - -**`void cancel_retake_request()`** -- Cancels all active retake goals -- Provides emergency stop functionality for retake processing - -**Action Client Callbacks** - -**`void request_response_callback(const rclcpp_action::ClientGoalHandle::SharedPtr &goal_handle)`** -- Handles retake action server responses -- Logs goal acceptance or rejection status -- Provides feedback on retake request processing state - -**`void request_result_callback(const rclcpp_action::ClientGoalHandle::WrappedResult &result)`** -- Processes final retake action results -- Logs appropriate messages based on retake completion status - -**`void request_feedback_callback(rclcpp_action::ClientGoalHandle::SharedPtr goal_handle, const std::shared_ptr feedback)`** diff --git a/doc/installation/installation.md b/doc/installation/installation.md index 7d63cf8..16a4208 100644 --- a/doc/installation/installation.md +++ b/doc/installation/installation.md @@ -22,7 +22,7 @@ cd ros2-assignments ```bash colcon build ``` -Any parameters can be changed before building by editing the `grade_calculator.launch.xml` in the launch folder +Any parameters can be changed before building by editing the `imu_reader.launch.xml` in the launch folder ### Source the Workspace @@ -38,6 +38,6 @@ You can configure specific database settings in the `docker-compose.yaml` in the ### Start the Grade calculator program ```bash -ros2 launch g2_2025_grade_calculator_pkg grade_calculator.launch.xml +ros2 launch g2_2025_imu_reader_pkg imu_reader.launch.xml ``` -To change parameters when using the launch file it will need to be edited in the `src/g2_2025_grade_calculator_pkg/launch` folder. All parameters are already added to this document and thus only the values will need to be changed +To change parameters when using the launch file it will need to be edited in the `src/g2_2025_imu_reader_pkg/launch` folder. All parameters are already added to this document and thus only the values will need to be changed diff --git a/doc/tests/ExamResultGenerator.md b/doc/tests/ExamResultGenerator.md deleted file mode 100644 index b0adbda..0000000 --- a/doc/tests/ExamResultGenerator.md +++ /dev/null @@ -1,62 +0,0 @@ -# Exam Result Generator Node Unit Tests - -Unit tests for `ExamResultGenerator` are implemented in `src/g2_2025_grade_calculator_pkg/test/ExamResultGenerator.test.cpp` using Google Test and ROS2 test utilities. The tests use a test subscriber node to capture published messages and validate node behavior. - -## Test Cases - -### 1. ConstructorTest - -**Description:** Verifies that ExamResultGenerator can be created without crashing and proper initialization occurs. - -- **Test Action:** Create ExamResultGenerator node instance -- **Expected Result:** - - Node created successfully without exceptions - - Node name set to `"exam_result_generator"` - -### 2. PublisherCreationTest - -**Description:** Verifies that the `exam_results` topic publisher is properly configured. - -- **Test Action:** Check topic names and types after node creation -- **Expected Result:** - - `/exam_results` topic is published - - Topic uses `g2_2025_interfaces/msg/Exam` message type - -### 3. SubscriberCreationTest - -**Description:** Tests that the node subscribes to the `student_course_management` topic with correct message type. - -- **Test Action:** Check subscription topics and types -- **Expected Result:** - - `/student_course_management` topic is subscribed - - Subscription uses `g2_2025_interfaces/msg/Student` message type - -### 4. StudentManagementMessageHandlingTest - -**Description:** Tests the node's ability to handle incoming student management messages without crashing. - -- **Test Action:** - - Publish student management message: - - Student: `"Test Student"` - - Course: `"Test Course"` -- **Expected Result:** Message processed without crashes - -### 5. MultipleStudentMessagesTest - -**Description:** Validates handling of multiple rapid student management messages for robustness testing. - -- **Test Action:** - - Send multiple messages with different student-course combinations - - Students: `["Alice", "Bob", "Charlie"]` - - Courses: `["Math", "Physics", "Chemistry"]` -- **Expected Result:** All messages processed without crashes or memory issues - -### 6. ExamMessageValidationTest - -**Description:** Captures and validates published exam result messages for correct content and format. - -- **Test Action:** Listen for published exam result messages over 6 seconds -- **Expected Result:** - - Published grades are within range `[10, 100]` - - Course names are not empty - - Message format is correct diff --git a/doc/tests/FinalGradeDeterminator.md b/doc/tests/FinalGradeDeterminator.md deleted file mode 100644 index fb94255..0000000 --- a/doc/tests/FinalGradeDeterminator.md +++ /dev/null @@ -1,52 +0,0 @@ -# Final Grade Determintator Node Unit Tests - -Unit tests for `FinalGradeDeterminator` are implemented in `src/g2_2025_grade_calculator_pkg/test/FinalGradeDeterminator.test.cpp` using Google Test and ROS2 test utilities. The tests use a mock database manager and a mock grade calculator service to simulate the node's interactions. - -## Test Cases - -### 1. ConstructorTest - -**Description:** Verifies that the node can be constructed without errors. - -- **Input:** Construct a `FinalGradeDeterminator` node. -- **Expected Output:** No exceptions are thrown. The node is created successfully. - -### 2. ExamCollectionTest - -**Description:** Sends the required number of exam results and checks that a grade calculation request is triggered, a student message is published, and the results are stored. - -- **Input:** - - Student: `"Test Student"` - - Course: `"Test Course"` - - Grades published: `[80, 85, 90, 75, 95]` (5 exam results, which is the default required amount) -- **Expected Output:** - - A grade calculation service request is made with the correct student, course, and grades. - - A student message is published with the correct student and course. - - The final grade is calculated as the average: (80 + 85 + 90 + 75 + 95) / 5 = 85. - -### 3. PartialExamCollectionTest - -**Description:** Sends fewer than the required number of exam results and checks that no grade calculation or student message occurs. - -- **Input:** - - Student: `"Test Student"` - - Course: `"Test Course"` - - Grades published: `[80, 85, 90]` (only 3 exam results, less than required) -- **Expected Output:** - - No grade calculation service request is made. - - No student message is published. - -### 4. MultipleStudentsTest - -**Description:** Simulates multiple students submitting exam results and verifies that each student triggers independent grade calculation and messaging. - -- **Input:** - - Students: `"Alice"`, `"Bob"` - - Course: `"Test Course"` - - Each student receives grades: `[80, 85, 90, 75, 95]` (5 exam results per student) -- **Expected Output:** - - Two grade calculation service requests are made, one for each student, with the correct grades. - - Two student messages are published, one for each student. - - The final grade for each student is calculated as the average: (80 + 85 + 90 + 75 + 95) / 5 = 85. - -These tests ensure that the node correctly collects exam results, triggers grade calculation at the right time, publishes the appropriate messages, and interacts with the database as expected. diff --git a/doc/tests/GradeCalculator.md b/doc/tests/GradeCalculator.md deleted file mode 100644 index 479623f..0000000 --- a/doc/tests/GradeCalculator.md +++ /dev/null @@ -1,56 +0,0 @@ -# Grade Calculator Node Unit Tests - -Unit tests for `GradeCalculator` are implemented in `src/g2_2025_grade_calculator_pkg/test/GradeCalculator.test.cpp` using Google Test and ROS2 test utilities. The tests use a client to call the grade calculation service and verify the results. - -## Test Cases - -### 1. NormalAverage - -**Description:** Verifies that the service returns the average of the provided grades for a normal student name. - -- **Input:** - - Student: `"Alice"` - - Grades: `[80, 90, 70]` -- **Expected Output:** - - Result: `80` (average of 80, 90, 70) - -### 2. WesselBonus - -**Description:** Checks that the student name "Wessel" (case-insensitive) receives a 10-point bonus, and the result is clamped to 100 if necessary. - -- **Input:** - - Student: `"Wessel"` - - Grades: `[80, 90, 70]` -- **Expected Output:** - - Result: `90` (average 80 + 10 bonus) - -#### 3. wesselBonus - -**Description:** Checks that the bonus logic is case-insensitive for the student name "wessel". - -- **Input:** - - Student: `"wessel"` - - Grades: `[80, 90, 70]` -- **Expected Output:** - - Result: `90` (average 80 + 10 bonus) - -#### 4. GradeTooHigh - -**Description:** Ensures that the grade is clamped to a maximum of 100, even after applying the bonus. - -- **Input:** - - Student: `"Wessel"` - - Grades: `[100, 100, 100]` -- **Expected Output:** - - Result: `100` (average 100 + 10 bonus, clamped to 100) - -#### 5. GradeTooLow - -**Description:** Ensures that the grade is clamped to a minimum of 10. - -- **Input:** - - Student: `"Alice"` - - Grades: `[0, 0, 0]` -- **Expected Output:** - - Result: `10` (average 0, clamped to 10) - diff --git a/doc/tests/IntegrationTest.md b/doc/tests/IntegrationTest.md deleted file mode 100644 index 09a9bb3..0000000 --- a/doc/tests/IntegrationTest.md +++ /dev/null @@ -1,151 +0,0 @@ -# Integration Test - -Tests the whole integrated system `nodes` connected with each other, with supervisory control and visualization of the database. It tests all major components working together: exam result generation, calculation, database usage, and retake handling. - -For validation and verification of database data the databse viewer Dbeaver can be used. - -## Test Input Data - -**Student Enrollments:** - -- `"Wessel", "ROS2"` -- `"Vincent", "ROS2"` -- `"Mohammed", "Differentieren"` -- `"Tilmann", "Differentieren"` - -## Test workflow - -### 1. Complete Grade Processing Pipeline - -**Description**: Tests the full workflow from student enrollment through exam generation to final grade calculation. - -**Steps:** - -1. **Setup Phase** - - Clear the database via `docker container prune` or by deleting the tables in dbeaver. - - Start the databse in a standalone terminal via the command `sudo docker compose up`. - - Verify database connection. - - Initialize all system nodes (ExamResultGenerator, FinalGradeDeterminator, GradeCalculator) after building tha package and starting it via the `grade_calculator.launch.xml`. - -2. **Exam Generation Phase** - - ExamResultGenerator publishes Exam messages per student-course pair to table `exam_results` topic. - - Verify exam results have valid grades (10-100 range). - - Confirm proper timestamp and student/course name matching. - -3. **Grade Collection Phase** - - FinalGradeDeterminator collects exam results for each student-course combination. - - Monitor collection count reaches threshold (5 exams per student-course by default) for each student. - -4. **Grade Calculation Phase** - - FinalGradeDeterminator calls GradeCalculator service when threshold reached. - - Service calculates average grade. - -5. **Persistence and Notification Phase** - - Final grades stored in database with proper timestamps. - - verify that final_grade_determinator has sent a de-enroll request via student_course_managment to exam_result_generator. - - exam_result_generator should now prints `removed from queue`. - - Verify final grade is within valid bounds (10-100) in table `final_course_results`. - -**Expected Results:** - -```text -Student: Wessel, Course: ROS2 -- 5 exam results generated (random grades 10-100) -- Avrage final grade calculated -- Grade stored in database - - -Student: Vincent, Course: ROS2 -- 5 exam results generated (random grades 10-100) -- Avrage final grade calculated -- Grade stored in database - - -Student: Mohammed, Course: Differentieren -- 5 exam results generated (random grades 10-100) -- Avrage final grade calculated -- Grade stored in database - - -Student: Tilmann, Course: Differentieren -- 5 exam results generated (random grades 10-100) -- Avrage final grade calculated -- Grade stored in database -``` - -### 2. Retake Process Integration - -**Description**: Tests the retake workflow for students who need to retake exams. - -**Setup:** - -no setup required, this starts immediately after `final_grade_diterminator` is done after getting the first grades for the students. - -**Steps:** - -1. **Varify Retake Schedualer is started** - - Verify in the terminal the schedualer starts the retake process. - -2. **Retake Request Phase** - - RetakeScheduler checks the database for failing students - - Schedules retake exams with `retake_grade_determinator` - -3. **Retake Execution Phase** - - Generate retake exam results - - `retake_grade_determinator` processes retake grades and sends them to the calcculator. - - `retake_grade_determinator` finaly stores the calculated result in the database. - -4. **Final Grade Update** - - Verify grade history preservation - - Confirm final grade reflects retake performance - -**Failing student Expected Retake Results:** - -```text -Student: student, Course: course -- 5 exam results generated (random grades 10-100) -- Avrage final grade calculated -- Grade stored in database -- Retake_done checkmark -- Is_retake checkmark -``` - -## Success Criteria - -### Functional Requirements - - All student enrollments processed correctly - Exam results generated within valid range (10-100) - Grade collection reaches configured thresholds - Final grades calculated using proper business logic - Database persistence works reliably - Retake process functions correctly when needed - All ROS2 communication protocols working - -## Test Execution Commands - -```bash -# 1. enter the ros2 assignment folder -cd /YOUR/PATH/HERE/ros2-assignment - -# 2. Build the packages and source the enviroment -colcon build && source install/setup.bash - -# 3. clear and Start database (if not running) in stand alone terminal -sudo docker container prune && sudo docker compose up - -# 4. Launch all system nodes -ros2 launch g2_2025_grade_calculator_pkg grade_calculator.launch.xml - -# 6. Monitor database state -By opening dbeaver and connecting to the database "grades". -Password: postgres -``` - -## Verification - -### Database Validation - -- **Student Records**: Verify all students are enrolled correctly -- **Exam Results**: Confirm all exam data is good -- **Final Grades**: Validate calculated grades and timestamps diff --git a/doc/tests/RetakeGradeDeterminator.md b/doc/tests/RetakeGradeDeterminator.md deleted file mode 100644 index 47de946..0000000 --- a/doc/tests/RetakeGradeDeterminator.md +++ /dev/null @@ -1,70 +0,0 @@ -# RetakeGradeDeterminator Node Unit Tests - -This document describes the unit tests for the `RetakeGradeDeterminator` ROS 2 node, as implemented in [`RetakeGradeDeterminator.test.cpp`](../../src/g2_2025_grade_calculator_pkg/test/RetakeGradeDeterminator.test.cpp). - -## Test Cases - -### 1. ConstructorTest - -- **Purpose:** - Verifies that the `RetakeGradeDeterminator` can be constructed without throwing exceptions. -- **Checks:** - - The node is created successfully and is not `nullptr`. - -### 2. PublisherCreationTest - -- **Purpose:** - Ensures that the node creates a publisher for the `student_course_management` topic. -- **Checks:** - - The `/student_course_management` topic is present and uses the `Student` message type. - -### 3. SubscriberCreationTest - -- **Purpose:** - Ensures that the node subscribes to the `exam_results` topic. -- **Checks:** - - The `/exam_results` topic is present and uses the `Exam` message type. - -### 4. ActionServerCreationTest - -- **Purpose:** - Verifies that the node creates an action server for the `retake_action`. -- **Checks:** - - The action server is available and can be connected to by an action client. - -### 5. ServiceClientCreationTest - -- **Purpose:** - Ensures that the node creates a client for the `grade_calculator_service`. -- **Checks:** - - The `/grade_calculator_service` is present in the node's service graph. - -### 6. ParameterTest - -- **Purpose:** - Confirms that the node's parameters are set to their expected default values. -- **Checks:** - - The `grade_collection_amount` parameter defaults to `5`. - -### 7. ExamResultsIgnoredWhenRetakeNotAllowed - -- **Purpose:** - Ensures that exam results are ignored if a retake is not currently allowed. -- **Checks:** - - No service requests are made when a retake is not in progress. - -### 8. RetakeActionGoalAcceptance - -- **Purpose:** - Verifies that the node accepts retake action goals and publishes the appropriate student enrollment message. -- **Checks:** - - The retake goal is accepted. - - A `Student` message is published with the correct student and course names. - -### 9. PartialExamResultsCollection - -- **Purpose:** - Ensures that the node does not process or store results if not enough exam results have been collected during a retake. -- **Checks:** - - No service requests are made. - - No results are stored in the database if the required number of exam results has not been reached. diff --git a/doc/tests/RetakeScheduler.md b/doc/tests/RetakeScheduler.md deleted file mode 100644 index 95dd12b..0000000 --- a/doc/tests/RetakeScheduler.md +++ /dev/null @@ -1,50 +0,0 @@ -# RetakeScheduler Node Unit Tests - -Unit tests for `RetakeScheduler` are implemented in `src/g2_2025_grade_calculator_pkg/test/RetakeScheduler.test.cpp` -The unit tests are written using Google Test and ROS 2 test utilities. They utilize clients to interact -with the RetakeScheduler node's services and actions, verifying correct behavior and expected outcomes. - -## Test Cases - -### 1. ConstructorTest - -- **Purpose:** - Verifies that the `RetakeScheduler` can be constructed without throwing exceptions. -- **Checks:** - - The node is created successfully and is not `nullptr`. - - -### 2. ActionClientCreationTest - -- **Purpose:** - Ensures that the `RetakeScheduler` node creates the expected action client services for the retake action. -- **Checks:** - - At least one of the retake action client services (`/retake_action/_action/cancel_goal`, `/retake_action/_action/get_result`, `/retake_action/_action/send_goal`) is present in the node's service graph. - - -### 3. ParameterTest - -- **Purpose:** - Confirms that the node's parameters are set to their expected default values. -- **Checks:** - - The `retake_check_interval_sec` parameter defaults to `120`. - - -### 4. ActionClientAllServicesPresentTest - -- **Purpose:** - Verifies that all required action client services for the retake action are available. -- **Checks:** - - The following services are present: - - `/retake_action/_action/cancel_goal` - - `/retake_action/_action/get_result` - - `/retake_action/_action/send_goal` - - -### 5. ConstructorWithNullDatabaseManager - -- **Purpose:** - Tests the node's behavior when constructed with a `nullptr` database manager. -- **Checks:** - - The node can be constructed without throwing, even if the database manager is `nullptr`. -