From ece430b6c3e8088da125f87e31f0cf3557f2ae25 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Fri, 16 May 2025 13:48:34 +0000 Subject: [PATCH] NR UE: use shorter member names for position_t structure --- executables/position_interface.h | 12 ++++++------ openair2/LAYER2/NR_MAC_UE/config_ue.c | 20 ++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/executables/position_interface.h b/executables/position_interface.h index 0324bceb15..8ef0b3144b 100644 --- a/executables/position_interface.h +++ b/executables/position_interface.h @@ -41,16 +41,16 @@ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/ // clang-format off #define POSITION_CONFIG_PARAMS_DEF { \ - {CONFIG_STRING_POSITION_X, HELP_STRING_POSITION, 0, .dblptr=&(position->positionX), .defuintval=0, TYPE_DOUBLE, 0}, \ - {CONFIG_STRING_POSITION_Y, HELP_STRING_POSITION, 0, .dblptr=&(position->positionY), .defuintval=0, TYPE_DOUBLE, 0}, \ - {CONFIG_STRING_POSITION_Z, HELP_STRING_POSITION, 0, .dblptr=&(position->positionZ), .defuintval=0, TYPE_DOUBLE, 0} \ + {CONFIG_STRING_POSITION_X, HELP_STRING_POSITION, 0, .dblptr=&(position->X), .defuintval=0, TYPE_DOUBLE, 0}, \ + {CONFIG_STRING_POSITION_Y, HELP_STRING_POSITION, 0, .dblptr=&(position->Y), .defuintval=0, TYPE_DOUBLE, 0}, \ + {CONFIG_STRING_POSITION_Z, HELP_STRING_POSITION, 0, .dblptr=&(position->Z), .defuintval=0, TYPE_DOUBLE, 0} \ } // clang-format on typedef struct position { - double positionX; - double positionY; - double positionZ; + double X; + double Y; + double Z; } position_t; void get_position_coordinates(int Mod_id, position_t *position); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 8bf20428c2..2381bdb3e3 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -272,30 +272,22 @@ static void calculate_ue_sat_ta(const position_t *position_params, ntn_timing_advance_componets_t *ntn_ta) { // get UE position coordinates - double pos_ue_x = position_params->positionX; - double pos_ue_y = position_params->positionY; - double pos_ue_z = position_params->positionZ; + const position_t pos_ue = *position_params; // get sat position coordinates - double pos_sat_x = (double)sat_pos->positionX_r17 * 1.3; - double pos_sat_y = (double)sat_pos->positionY_r17 * 1.3; - double pos_sat_z = (double)sat_pos->positionZ_r17 * 1.3; + const position_t pos_sat = {sat_pos->positionX_r17 * 1.3, sat_pos->positionY_r17 * 1.3, sat_pos->positionZ_r17 * 1.3}; // calculate directional vector from SAT to UE - double dir_sat_ue_x = pos_ue_x - pos_sat_x; - double dir_sat_ue_y = pos_ue_y - pos_sat_y; - double dir_sat_ue_z = pos_ue_z - pos_sat_z; + const position_t dir_sat_ue = {pos_ue.X - pos_sat.X, pos_ue.Y - pos_sat.Y, pos_ue.Z - pos_sat.Z}; // calculate distance between SAT and UE - double distance = sqrt(dir_sat_ue_x * dir_sat_ue_x + dir_sat_ue_y * dir_sat_ue_y + dir_sat_ue_z * dir_sat_ue_z); + double distance = sqrt(dir_sat_ue.X * dir_sat_ue.X + dir_sat_ue.Y * dir_sat_ue.Y + dir_sat_ue.Z * dir_sat_ue.Z); // get sat velocity vector - double vel_sat_x = (double)sat_pos->velocityVX_r17 * 0.06; - double vel_sat_y = (double)sat_pos->velocityVY_r17 * 0.06; - double vel_sat_z = (double)sat_pos->velocityVZ_r17 * 0.06; + const position_t vel_sat = {sat_pos->velocityVX_r17 * 0.06, sat_pos->velocityVY_r17 * 0.06, sat_pos->velocityVZ_r17 * 0.06}; // calculate SAT velocity towards UE - double velocity = (vel_sat_x * dir_sat_ue_x + vel_sat_y * dir_sat_ue_y + vel_sat_z * dir_sat_ue_z) / distance; + double velocity = (vel_sat.X * dir_sat_ue.X + vel_sat.Y * dir_sat_ue.Y + vel_sat.Z * dir_sat_ue.Z) / distance; ntn_ta->N_UE_TA_adj = (2 * distance / SPEED_OF_LIGHT) * 1e3; // in ms ntn_ta->N_UE_TA_drift = (2 * -velocity / SPEED_OF_LIGHT) * 1e6; // in µs/s