generated from wessel/boilerplate
docs: Update documentation for new assignment
This commit is contained in:
@@ -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
|
||||
@@ -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<g2_2025_interfaces::srv::Exams>::SharedFuture future, StudentCourse studentCourseCombo)`**
|
||||
- Verifies database connection
|
||||
- Publishes final student message to ROS2 topic
|
||||
- Logs final grade information
|
||||
- Stores final course result in database
|
||||
@@ -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
|
||||
29
doc/architecture/nodes/IMUDatabaseWriter.md
Normal file
29
doc/architecture/nodes/IMUDatabaseWriter.md
Normal file
@@ -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.
|
||||
@@ -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<DatabaseManager> 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<g2_2025_interfaces::srv::Exams>::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<const g2_2025_interfaces::action::Retake::Goal> 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<rclcpp_action::ServerGoalHandle<g2_2025_interfaces::action::Retake>> goal_handle)`**
|
||||
- Handles retake action cancellation requests
|
||||
- Returns `ACCEPT` for all cancellation requests
|
||||
|
||||
**`void spawn_callback_thread(const std::shared_ptr<rclcpp_action::ServerGoalHandle<g2_2025_interfaces::action::Retake>> goal_handle)`**
|
||||
- Creates detached thread for asynchronous retake action execution
|
||||
- Ensures non-blocking retake processing
|
||||
|
||||
**`void async_execute_callback_thread(const std::shared_ptr<rclcpp_action::ServerGoalHandle<g2_2025_interfaces::action::Retake>> 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
|
||||
@@ -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<DatabaseManager> 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<RetakeAction>::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<RetakeAction>::WrappedResult &result)`**
|
||||
- Processes final retake action results
|
||||
- Logs appropriate messages based on retake completion status
|
||||
|
||||
**`void request_feedback_callback(rclcpp_action::ClientGoalHandle<RetakeAction>::SharedPtr goal_handle, const std::shared_ptr<const RetakeAction::Feedback> feedback)`**
|
||||
Reference in New Issue
Block a user