fix(Config,Database): Remove references to assignment one

This commit is contained in:
2025-11-05 15:50:56 +01:00
parent 523709e349
commit e6123e5702
9 changed files with 33 additions and 64 deletions

View File

@@ -1,9 +1,9 @@
# DatabaseManager (`assignments::one::DatabaseManager`)
# DatabaseManager (`assignments::two::DatabaseManager`)
## Overview
The `DatabaseManager` class is a PostgreSQL database interface for the ROS2 grade calculator.
It handles all database operations including connection management, table creation and data insertion.
The `DatabaseManager` class is a PostgreSQL database interface for the ROS2 IMU data collection system.
It handles all database operations including connection management, table creation and data storage.
## Implementation Details
@@ -28,7 +28,7 @@ DatabaseManager(rclcpp::Logger logger)
> Returns `true` on successful connection, `false` on failure
- Establishes connection to PostgreSQL database using connection information from the config TOML
- Connection string format: `"host=localhost port=5432 dbname=grades user=postgres password=postgres"`
- Connection string format: `"host=localhost port=5432 dbname=imu_data user=postgres password=postgres"`
**`bool is_connected() const`**
> Returns `true` if connection exists and is open
@@ -47,56 +47,25 @@ DatabaseManager(rclcpp::Logger logger)
**`void create_tables()`**
- Creates all required database tables using SQL queries from `SQLQueries.hpp`
- Tables created:
- `enrollments`: Student course enrollments
- `exam_results`: Individual exam scores
- `course_results`: Final course grades and statistics
- `imu_data`: IMU sensor readings with linear acceleration and angular velocity data
- Uses transactions for atomic table creation
**`void insert_sample_data()`**
- Inserts predefined sample student data
### Data Operations
#### Student Course Management
#### IMU Data Storage
**`std::vector<StudentCourse> queue_pending_combinations()`**
> Returns vector of StudentCourse objects for processing queue
**`bool store_imu_data(double linear_accel_x, double linear_accel_y, double linear_accel_z, double angular_vel_x, double angular_vel_y, double angular_vel_z)`**
> Returns `true` on successful storage, `false` on failure
- Gets all student-course combinations that need exam results generated
- Executes complex SQL query to find missing exam results
**`bool enroll_student_into_course(const StudentCourse& sc)`**
> Returns `true` on successful enrollment, `false` on failure
- Enrolls a student into a specific course
#### Exam Result Processing
**`bool store_exam_result(const std::string& student_name, const std::string& course_name, int grade)`**
- Stores individual exam results in the database
- Stores IMU sensor readings in the database
- Parameters:
- `student_name`: Name of the student
- `course_name`: Name of the course
- `grade`: Exam score (10-100)
**`bool store_final_course_result(const StudentCourse& sc, int exam_count, int final_grade)`**
- Stores calculated final course results
- Parameters:
- `sc`: StudentCourse object containing student and course names
- `exam_count`: Number of exams taken
- `final_grade`: Calculated final grade
- Used by grade calculation nodes for final result storage
#### Grade Retrieval
**`int get_final_course_grade(const StudentCourse& sc)`**
> Returns:
> - `> 0`: Valid final grade (rounded average)
> - `-1`: No exams taken or no results found
- Gets final calculated grade for a student-course combination
- Performs average calculation with proper rounding
- Used by nodes to check if final grading is complete
- `linear_accel_x`: Linear acceleration on X-axis
- `linear_accel_y`: Linear acceleration on Y-axis
- `linear_accel_z`: Linear acceleration on Z-axis
- `angular_vel_x`: Angular velocity around X-axis
- `angular_vel_y`: Angular velocity around Y-axis
- `angular_vel_z`: Angular velocity around Z-axis
- Automatically adds timestamp on insertion
### Logging
@@ -117,9 +86,9 @@ DatabaseManager db_manager(node->get_logger());
// Check connection status
if (db_manager.is_connected()) {
// Database ready for operations
bool success = db_manager.store_exam_result("Wessel", "ROS2", 85);
bool success = db_manager.store_imu_data(1.2, -0.5, 9.8, 0.01, 0.02, 0.03);
if (success) {
RCLCPP_INFO(logger, "Exam result stored successfully");
RCLCPP_INFO(logger, "IMU data stored successfully");
}
}
```