Rleg  2
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Macros | Functions
datalogger.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DATALOGGER_MODULE_ENABLED   1
 
#define DATALOGGER_DEBUG_MODE   0
 
#define DATALOGGER_ENABLE_NEW_FILE_ENNUMERATION   0
 
#define DATALOGGER_FILE_NAME   "rleg"
 
#define DATALOGGER_FOLDER   "matlabdatafiles"
 
#define DATALOGGER_STANDARD_QUEUE_SIZE   750
 
#define DATALOGGER_LOG_TIME   1
 
#define DATALOGGER_LOG_EXECTIMES   1
 
#define DATALOGGER_LOG_RAW_IMU   1
 
#define DATALOGGER_LOG_EFFORTS   1
 
#define DATALOGGER_LOG_MRA   1
 
#define DATALOGGER_LOG_CALIBRATED_IMU   1
 
#define DATALOGGER_NOT_INITIALIZED   0
 
#define DATALOGGER_INITIALIZED   1
 
#define DATALOGGER_NOT_RUNNING   0
 
#define DATALOGGER_RUNNING   1
 
#define DATALOGGER_VARIABLE_NOT_INSERTED   0
 
#define DATALOGGER_VARIABLE_INSERTED   1
 
#define DATALOGGER_SUCCESS   1
 
#define DATALOGGER_FAILURE   -1
 
#define DATALOGGER_ERROR_NOT_INITIALIZED   -2
 
#define DATALOGGER_VARIBALE_ALREADY_INSERTED   -3
 

Functions

int datalogger_init (void)
 
int datalogger_close (void)
 
int datalogger_write_file (void)
 
int datalogger_update_IPC (void)
 
int datalogger_update (double t_s, double t_control_exec_s, double t_ui_exec_s, double t0_s, IMU_DATA_STRUCT *pimu_data, EFF_DATA_STRUCT *peff_data, MRA_DATA_STRUCT *pmra_data)
 
int datalogger_set_Ts (double Ts)
 
int datalogger_status (void)
 
int datalogger_start (void)
 
int datalogger_stop (void)
 
int datalogger_file_exists (const char *filename)
 

Macro Definition Documentation

#define DATALOGGER_DEBUG_MODE   0

Definition at line 6 of file datalogger.h.

#define DATALOGGER_ENABLE_NEW_FILE_ENNUMERATION   0

Definition at line 9 of file datalogger.h.

#define DATALOGGER_ERROR_NOT_INITIALIZED   -2
#define DATALOGGER_FAILURE   -1

Definition at line 36 of file datalogger.h.

Referenced by datalogger_file_exists(), and datalogger_init().

#define DATALOGGER_FILE_NAME   "rleg"

Definition at line 10 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_FOLDER   "matlabdatafiles"

Definition at line 11 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_INITIALIZED   1
#define DATALOGGER_LOG_CALIBRATED_IMU   1

Definition at line 22 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_LOG_EFFORTS   1

Definition at line 18 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_LOG_EXECTIMES   1

Definition at line 16 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_LOG_MRA   1

Definition at line 19 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_LOG_RAW_IMU   1

Definition at line 17 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_LOG_TIME   1

Definition at line 15 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_MODULE_ENABLED   1

Definition at line 5 of file datalogger.h.

#define DATALOGGER_NOT_INITIALIZED   0

Definition at line 27 of file datalogger.h.

Referenced by datalogger_close().

#define DATALOGGER_NOT_RUNNING   0
#define DATALOGGER_RUNNING   1
#define DATALOGGER_STANDARD_QUEUE_SIZE   750

Definition at line 12 of file datalogger.h.

Referenced by datalogger_init().

#define DATALOGGER_SUCCESS   1
#define DATALOGGER_VARIABLE_INSERTED   1

Definition at line 32 of file datalogger.h.

Referenced by datalogger_set_Ts().

#define DATALOGGER_VARIABLE_NOT_INSERTED   0

Definition at line 31 of file datalogger.h.

Referenced by datalogger_set_Ts().

#define DATALOGGER_VARIBALE_ALREADY_INSERTED   -3

Definition at line 38 of file datalogger.h.

Referenced by datalogger_set_Ts().

Function Documentation

int datalogger_close ( void  )

Definition at line 215 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), datalogger_mutex, DATALOGGER_NOT_INITIALIZED, DATALOGGER_SUCCESS, datalogger_unlock_mutex(), gDataLogger_Close(), and gDataLogger_MatfileUpdate().

Referenced by main(), and threads_linux_init().

216 {
217  #if DATALOGGER_MODULE_ENABLED
220  {
223  }
224 
225  gDataLogger_MatfileUpdate(&gDataLogger); // Update data
226  gDataLogger_Close(&gDataLogger); // Close datalogger
227 
230 
231  #if ANU_COMPILE_FOR_XENOMAI
232  rt_mutex_delete(&datalogger_mutex);
233  #endif //ANU_COMPILE_FOR_XENOMAI
234 
235  #endif //DATALOGGER_MODULE_ENABLED
236 
237  return DATALOGGER_SUCCESS;
238 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
#define DATALOGGER_NOT_INITIALIZED
Definition: datalogger.h:27
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
pthread_mutex_t datalogger_mutex
Definition: datalogger.c:34
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
int gDataLogger_MatfileUpdate(PGDATALOGGER pgDataLogger)
Definition: gdatalogger.c:245
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
int gDataLogger_Close(PGDATALOGGER pgDataLogger)
Definition: gdatalogger.c:362
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_file_exists ( const char *  filename)

Definition at line 618 of file datalogger.c.

References DATALOGGER_FAILURE, and DATALOGGER_SUCCESS.

Referenced by datalogger_init().

619 {
620  FILE *file;
621  if((file = fopen(filename, "r")))
622  {
623  fclose(file);
624  return DATALOGGER_SUCCESS;
625  }
626  return DATALOGGER_FAILURE;
627 }
#define DATALOGGER_FAILURE
Definition: datalogger.h:36
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35

Here is the caller graph for this function:

int datalogger_init ( void  )

Definition at line 41 of file datalogger.c.

References DATALOGGER_FAILURE, datalogger_file_exists(), DATALOGGER_FILE_NAME, DATALOGGER_FOLDER, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_LOG_CALIBRATED_IMU, DATALOGGER_LOG_EFFORTS, DATALOGGER_LOG_EXECTIMES, DATALOGGER_LOG_MRA, DATALOGGER_LOG_RAW_IMU, DATALOGGER_LOG_TIME, datalogger_mutex, DATALOGGER_NOT_RUNNING, datalogger_running, DATALOGGER_STANDARD_QUEUE_SIZE, DATALOGGER_SUCCESS, datalogger_unlock_mutex(), gDataLogger_DeclareVariable(), gDataLogger_Init(), and gDataLogger_InsertVariable().

Referenced by main(), and threads_linux_init().

42 {
43  #if DATALOGGER_MODULE_ENABLED
44  double enabled_variables[16][1];
45  char datalogger_filename[256];
46  #if ANU_COMPILE_FOR_XENOMAI
47  rt_mutex_create(&datalogger_mutex,"Data Logger Mutex");
48  #endif
50 
52  {
54  return DATALOGGER_FAILURE;
55  }
56 
58 
59  // Init datalogger
60  strcpy(datalogger_filename, DATALOGGER_FOLDER);
61  strcat(datalogger_filename, "/");
62  strcat(datalogger_filename, DATALOGGER_FILE_NAME);
63  strcat(datalogger_filename, ".mat");
64  #if DATALOGGER_ENABLE_NEW_FILE_ENNUMERATION
65  char datalogger_tmp[256];
66  int i = 0;
67  if(datalogger_file_exists(datalogger_filename) == DATALOGGER_SUCCESS) // File exists
68  {
69  strcpy(datalogger_tmp, DATALOGGER_FOLDER);
70  strcat(datalogger_tmp, "/");
71  strcat(datalogger_tmp, DATALOGGER_FILE_NAME);
72  strcat(datalogger_tmp, "_%d.mat");
73  do
74  {
75  sprintf(datalogger_filename, datalogger_tmp, ++i);
76  }
77  while((datalogger_file_exists(datalogger_filename) == DATALOGGER_SUCCESS) && (i<100));
78  if(i == 100)
79  {
81  return DATALOGGER_FAILURE;
82  }
83  }
84  #endif //DATALOGGER_ENABLE_NEW_FILE_ENNUMERATION
85 
86  if(!gDataLogger_Init(&gDataLogger, datalogger_filename, NULL))
87  {
89  return DATALOGGER_FAILURE;
90  }
91 
92  // Declare variables
93  // Arguments for gDataLogger_DeclareVariable:
94  // datalogger pointer, variable name, units, number of rows, number of columns, queue size
95 
96  // Variable that tells MATLAB which variables are enabled
97  enabled_variables[0][0] = (double) DATALOGGER_LOG_TIME;
98  enabled_variables[1][0] = (double) DATALOGGER_LOG_EXECTIMES;
99  enabled_variables[2][0] = (double) DATALOGGER_LOG_RAW_IMU;
100  enabled_variables[3][0] = (double) DATALOGGER_LOG_CALIBRATED_IMU;
101  enabled_variables[4][0] = (double) DATALOGGER_LOG_EFFORTS;
102  enabled_variables[5][0] = (double) DATALOGGER_LOG_MRA;
103  //enabled_variables[12][0] = (double) DATALOGGER_LOG_LOCAL_COORDINATE_SYSTEM;
104  //enabled_variables[13][0] = (double) DATALOGGER_LOG_LOCAL_FIELDS;
105  //enabled_variables[14][0] = (double) DATALOGGER_LOG_ESTIMATOR;
106  //enabled_variables[15][0] = (double) DATALOGGER_LOG_CONTROLLERS;
107 
108  gDataLogger_DeclareVariable(&gDataLogger, "enabled_vars", "", 6, 1, 1);
109  gDataLogger_InsertVariable(&gDataLogger, "enabled_vars", &enabled_variables[0][0]);
110 
111  #if DATALOGGER_LOG_TIME
113  gDataLogger_DeclareVariable(&gDataLogger, "Ts", "s", 1, 1, 1);
114  #endif // DATALOGGER_LOG_TIME
115 
116  #if DATALOGGER_LOG_EXECTIMES
119  #endif // DATALOGGER_LOG_EXECTIMES
120 
121  #if DATALOGGER_LOG_RAW_IMU
122  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_x_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
123  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_y_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
124  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_z_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
125  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_x_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
126  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_y_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
127  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_z_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
128  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_x_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
129  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_y_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
130  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_z_raw", "raw", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
132  #endif // DATALOGGER_LOG_IMU
133 
134  #if DATALOGGER_LOG_EFFORTS
137  #endif
138 
139  #if DATALOGGER_LOG_MRA
142  #endif
143 
144  #if DATALOGGER_LOG_CALIBRATED_IMU
145  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_x_g", "g", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
146  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_y_g", "g", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
147  gDataLogger_DeclareVariable(&gDataLogger, "imu_accelerometer_z_g", "g", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
148  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_x_B", "B", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
149  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_y_B", "B", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
150  gDataLogger_DeclareVariable(&gDataLogger, "imu_magnetometer_z_B", "B", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
151  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_x_rads", "rads", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
152  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_y_rads", "rads", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
153  gDataLogger_DeclareVariable(&gDataLogger, "imu_gyrometer_z_rads", "rads", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
154  gDataLogger_DeclareVariable(&gDataLogger, "imu_calibrated_valid_data", "", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
155  //gDataLogger_DeclareVariable(&gDataLogger, "imu_calibrated_valid_accelerometer_data", "", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
156  //gDataLogger_DeclareVariable(&gDataLogger, "imu_calibrated_valid_gyrometer_data", "", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
157  //gDataLogger_DeclareVariable(&gDataLogger, "imu_calibrated_valid_magnetometer_data", "", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
158  #endif // DATALOGGER_LOG_CALIBRATED_IMU
159 
160 
161 /*
162  #if DATALOGGER_LOG_LOCAL_COORDINATE_SYSTEM
163  gDataLogger_DeclareVariable(&gDataLogger, "initial_altitude", "m", 1, 1, 1);
164  gDataLogger_DeclareVariable(&gDataLogger, "initial_latitude", "radians", 1, 1, 1);
165  gDataLogger_DeclareVariable(&gDataLogger, "initial_longitude", "radians", 1, 1, 1);
166  gDataLogger_DeclareVariable(&gDataLogger, "initial_ecef_x", "m", 1, 1, 1);
167  gDataLogger_DeclareVariable(&gDataLogger, "initial_ecef_y", "m", 1, 1, 1);
168  gDataLogger_DeclareVariable(&gDataLogger, "initial_ecef_z", "m", 1, 1, 1);
169  gDataLogger_DeclareVariable(&gDataLogger, "rotation_matrix", "matrix", 3, 3, 1);
170  #endif // DATALOGGER_LOG_LOCAL_COORDINATE_SYSTEM
171 
172  #if DATALOGGER_LOG_LOCAL_FIELDS
173  gDataLogger_DeclareVariable(&gDataLogger, "local_magnetic", "field", 3, 1, 1);
174  gDataLogger_DeclareVariable(&gDataLogger, "local_gravity", "field", 3, 1, 1);
175  gDataLogger_DeclareVariable(&gDataLogger, "magnetic_magnitude", "uT", 1, 1, 1);
176  gDataLogger_DeclareVariable(&gDataLogger, "gravity_magnitude", "ms2", 1, 1, 1);
177  #endif // DATALOGGER_LOG_LOCAL_FIELDS
178 
179  #if DATALOGGER_LOG_ESTIMATOR
180  gDataLogger_DeclareVariable(&gDataLogger, "estimated_roll_angle_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
181  gDataLogger_DeclareVariable(&gDataLogger, "estimated_pitch_angle_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
182  gDataLogger_DeclareVariable(&gDataLogger, "estimated_yaw_angle_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
183  gDataLogger_DeclareVariable(&gDataLogger, "estimated_q0", "quaternion", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
184  gDataLogger_DeclareVariable(&gDataLogger, "estimated_q1", "quaternion", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
185  gDataLogger_DeclareVariable(&gDataLogger, "estimated_q2", "quaternion", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
186  gDataLogger_DeclareVariable(&gDataLogger, "estimated_q3", "quaternion", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
187  gDataLogger_DeclareVariable(&gDataLogger, "estimated_x_position_meters", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
188  gDataLogger_DeclareVariable(&gDataLogger, "estimated_y_position_meters", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
189  gDataLogger_DeclareVariable(&gDataLogger, "estimated_z_position_meters", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
190  gDataLogger_DeclareVariable(&gDataLogger, "estimated_x_velocity_meters_second", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
191  gDataLogger_DeclareVariable(&gDataLogger, "estimated_y_velocity_meters_second", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
192  gDataLogger_DeclareVariable(&gDataLogger, "estimated_z_velocity_meters_second", "meters", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
193  #endif // DATALOGGER_LOG_ESTIMATOR
194 
195  #if DATALOGGER_LOG_CONTROLLERS
196  gDataLogger_DeclareVariable(&gDataLogger, "control_roll_angle_trim_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
197  gDataLogger_DeclareVariable(&gDataLogger, "control_pitch_angle_trim_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
198  gDataLogger_DeclareVariable(&gDataLogger, "control_yaw_angle_trim_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
199  gDataLogger_DeclareVariable(&gDataLogger, "control_left_aileron_trim", "us", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
200  gDataLogger_DeclareVariable(&gDataLogger, "control_right_aileron_trim", "us", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
201  gDataLogger_DeclareVariable(&gDataLogger, "control_elevator_trim", "us", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
202  gDataLogger_DeclareVariable(&gDataLogger, "control_rudder_trim", "us", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
203  gDataLogger_DeclareVariable(&gDataLogger, "control_roll_angle_reference_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
204  gDataLogger_DeclareVariable(&gDataLogger, "control_pitch_angle_reference_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
205  gDataLogger_DeclareVariable(&gDataLogger, "control_yaw_angle_reference_radians", "radians", 1, 1, DATALOGGER_STANDARD_QUEUE_SIZE);
206  #endif // DATALOGGER_LOG_CONTROLLERS
207 */
210  #endif //DATALOGGER_MODULE_ENABLED
211 
212  return DATALOGGER_SUCCESS;
213 }
int gDataLogger_InsertVariable(PGDATALOGGER pgDataLogger, char *varname, double *varvalue)
Definition: gdatalogger.c:199
#define DATALOGGER_FILE_NAME
Definition: datalogger.h:10
#define DATALOGGER_LOG_TIME
Definition: datalogger.h:15
#define DATALOGGER_STANDARD_QUEUE_SIZE
Definition: datalogger.h:12
#define DATALOGGER_LOG_RAW_IMU
Definition: datalogger.h:17
#define DATALOGGER_LOG_EXECTIMES
Definition: datalogger.h:16
#define DATALOGGER_LOG_EFFORTS
Definition: datalogger.h:18
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
#define DATALOGGER_LOG_CALIBRATED_IMU
Definition: datalogger.h:22
unsigned int datalogger_initialized
Definition: datalogger.c:29
pthread_mutex_t datalogger_mutex
Definition: datalogger.c:34
#define DATALOGGER_LOG_MRA
Definition: datalogger.h:19
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
#define DATALOGGER_FAILURE
Definition: datalogger.h:36
#define DATALOGGER_NOT_RUNNING
Definition: datalogger.h:29
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
int gDataLogger_DeclareVariable(PGDATALOGGER pgDataLogger, char *varname, char *varunit, int nrows, int ncols, int queuesize)
Definition: gdatalogger.c:173
#define DATALOGGER_FOLDER
Definition: datalogger.h:11
int datalogger_file_exists(const char *filename)
Definition: datalogger.c:618
int gDataLogger_Init(PGDATALOGGER pgDataLogger, char *filename, char *dirname)
Definition: gdatalogger.c:42
unsigned int datalogger_running
Definition: datalogger.c:30
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_set_Ts ( double  Ts)

Definition at line 540 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_SUCCESS, datalogger_unlock_mutex(), DATALOGGER_VARIABLE_INSERTED, DATALOGGER_VARIABLE_NOT_INSERTED, DATALOGGER_VARIBALE_ALREADY_INSERTED, and gDataLogger_InsertVariable().

Referenced by control_task(), periodic_task_1(), and threads_linux_periodic_task_1().

541 {
542  static int datalogger_Ts_inserted = DATALOGGER_VARIABLE_NOT_INSERTED;
543 
545 
547  {
550  }
551 
552  #if DATALOGGER_LOG_TIME
553  if(datalogger_Ts_inserted == DATALOGGER_VARIABLE_NOT_INSERTED)
554  {
555  datalogger_Ts_inserted = DATALOGGER_VARIABLE_INSERTED;
557  }
558  else
559  {
562  }
563  #else
564  double tmp = Ts; // Remove warning
565  #endif // DATALOGGER_LOG_TIME
566 
568  return DATALOGGER_SUCCESS;
569 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
#define DATALOGGER_VARIABLE_NOT_INSERTED
Definition: datalogger.h:31
int gDataLogger_InsertVariable(PGDATALOGGER pgDataLogger, char *varname, double *varvalue)
Definition: gdatalogger.c:199
#define DATALOGGER_VARIABLE_INSERTED
Definition: datalogger.h:32
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
#define DATALOGGER_VARIBALE_ALREADY_INSERTED
Definition: datalogger.h:38
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_start ( void  )

Definition at line 584 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), datalogger_running, DATALOGGER_RUNNING, DATALOGGER_SUCCESS, and datalogger_unlock_mutex().

Referenced by ui_update().

585 {
586  #if DATALOGGER_MODULE_ENABLED
589  {
592  }
593 
596  #endif
597 
598  return DATALOGGER_SUCCESS;
599 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
#define DATALOGGER_RUNNING
Definition: datalogger.h:30
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
unsigned int datalogger_running
Definition: datalogger.c:30
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_status ( void  )

Definition at line 571 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), datalogger_running, and datalogger_unlock_mutex().

Referenced by control_task(), main(), periodic_task_1(), threads_linux_init(), threads_linux_periodic_task_1(), ui_overview_data(), and ui_update().

572 {
575  {
578  }
579 
581  return datalogger_running;
582 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
unsigned int datalogger_running
Definition: datalogger.c:30
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_stop ( void  )

Definition at line 601 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_NOT_RUNNING, datalogger_running, DATALOGGER_SUCCESS, and datalogger_unlock_mutex().

Referenced by main(), and ui_update().

602 {
603  #if DATALOGGER_MODULE_ENABLED
606  {
609  }
610 
613  #endif
614 
615  return DATALOGGER_SUCCESS;
616 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
#define DATALOGGER_NOT_RUNNING
Definition: datalogger.h:29
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
unsigned int datalogger_running
Definition: datalogger.c:30
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_update ( double  t_s,
double  t_control_exec_s,
double  t_ui_exec_s,
double  t0_s,
IMU_DATA_STRUCT pimu_data,
EFF_DATA_STRUCT peff_data,
MRA_DATA_STRUCT pmra_data 
)

Definition at line 272 of file datalogger.c.

References IMU_DATA_STRUCT::acc, IMU_DATA_STRUCT::calibrated::acc, IMU_DATA_STRUCT::calib, DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_SUCCESS, datalogger_unlock_mutex(), EFF_DATA_STRUCT::F, gDataLogger_InsertVariable(), IMU_DATA_STRUCT::gyr, IMU_DATA_STRUCT::calibrated::gyr, IMU_DATA_STRUCT::mag, IMU_DATA_STRUCT::calibrated::mag, IMU_DATA_STRUCT::new_data, EFF_DATA_STRUCT::new_data, MRA_DATA_STRUCT::v_ctl, MRA_DATA_STRUCT::v_ctl_read, DATA_XYZ::x, DATA_XYZ_DOUBLE::x, DATA_XYZ::y, DATA_XYZ_DOUBLE::y, DATA_XYZ::z, and DATA_XYZ_DOUBLE::z.

Referenced by control_task(), periodic_task_1(), and threads_linux_periodic_task_1().

273 {
274  double tmp = 0.0;
275 
277 
279  {
282  }
283 
284  #if DATALOGGER_LOG_TIME
285  double tmp_t = t_s - t0_s;
287  #else
288  double tmp_t = 0.0;
289  tmp_t = t_s; // Remove warning
290  #endif // DATALOGGER_LOG_TIME
291 
292  #if DATALOGGER_LOG_EXECTIMES
293  gDataLogger_InsertVariable(&gDataLogger, "t_control_exec", &t_control_exec_s);
294  gDataLogger_InsertVariable(&gDataLogger, "t_ui_exec", &t_ui_exec_s);
295  #else
296  double tmp_e = 0.0; // Remove warning
297  tmp_e = t_control_exec_s; // Remove warning
298  tmp_e = t_ui_exec_s; // Remove warning
299  #endif // DATALOGGER_LOG_EXECTIMES
300 
301 
302  #if DATALOGGER_LOG_RAW_IMU
303  tmp = (double) pimu_data->acc.x;
304  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_x_raw", &tmp);
305  tmp = (double) pimu_data->acc.y;
306  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_y_raw", &tmp);
307  tmp = (double) pimu_data->acc.z;
308  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_z_raw", &tmp);
309  tmp = (double) pimu_data->mag.x;
310  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_x_raw", &tmp);
311  tmp = (double) pimu_data->mag.y;
312  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_y_raw", &tmp);
313  tmp = (double) pimu_data->mag.z;
314  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_z_raw", &tmp);
315  tmp = (double) pimu_data->gyr.x;
316  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_x_raw", &tmp);
317  tmp = (double) pimu_data->gyr.y;
318  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_y_raw", &tmp);
319  tmp = (double) pimu_data->gyr.z;
320  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_z_raw", &tmp);
321  tmp = (double) pimu_data->new_data;
322  gDataLogger_InsertVariable(&gDataLogger, "imu_valid_data", &tmp);
323  #else
324  double tmp_ri = 0; // Remove warning
325  tmp_ri = pimu_data->new_data; // Remove warning ???
326  #endif //DATALOGGER_LOG_RAW_IMU
327 
328  #if DATALOGGER_LOG_EFFORTS
329  tmp = (double) peff_data->F.x;
330  gDataLogger_InsertVariable(&gDataLogger, "Vin0", &tmp);
331  tmp = (double) peff_data->new_data;
332  gDataLogger_InsertVariable(&gDataLogger, "Vin0_valid_data", &tmp);
333  #endif
334 
335  #if DATALOGGER_LOG_MRA
336  tmp = (double) pmra_data->v_ctl;
337  gDataLogger_InsertVariable(&gDataLogger, "v_ctl", &tmp);
338  tmp = (double) pmra_data->v_ctl_read;
339  gDataLogger_InsertVariable(&gDataLogger, "v_ctl_read", &tmp);
340  #endif
341 
342 
343 
344  #if DATALOGGER_LOG_CALIBRATED_IMU
345  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_x_g", &(pimu_data->calib.acc.x));
346  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_y_g", &(pimu_data->calib.acc.y));
347  gDataLogger_InsertVariable(&gDataLogger, "imu_accelerometer_z_g", &(pimu_data->calib.acc.z));
348  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_x_B", &(pimu_data->calib.mag.x));
349  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_y_B", &(pimu_data->calib.mag.y));
350  gDataLogger_InsertVariable(&gDataLogger, "imu_magnetometer_z_B", &(pimu_data->calib.mag.z));
351  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_x_rads", &(pimu_data->calib.gyr.x));
352  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_y_rads", &(pimu_data->calib.gyr.y));
353  gDataLogger_InsertVariable(&gDataLogger, "imu_gyrometer_z_rads", &(pimu_data->calib.gyr.z));
354  tmp = (double) pimu_data->new_data;
355  gDataLogger_InsertVariable(&gDataLogger, "imu_calibrated_valid_data", &tmp);
356  //tmp = pimu_measure->FlagValidAccerometerMeasure;
357  //gDataLogger_InsertVariable(&gDataLogger, "imu_calibrated_valid_accelerometer_data", &tmp);
358  //tmp = pimu_measure->FlagValidGyrometerMeasure;
359  //gDataLogger_InsertVariable(&gDataLogger, "imu_calibrated_valid_gyrometer_data", &tmp);
360  //tmp = pmagnetometer_measure->FlagValidMeasure;
361  //gDataLogger_InsertVariable(&gDataLogger, "imu_calibrated_valid_magnetometer_data", &tmp);
362  #else
363  double tmp_ci = 0.0;
364  tmp_ci = pimu_measure->ax; // Remove warning
365  tmp_ci = pmagnetometer_measure->mx; // Remove warning
366  #endif // DATALOGGER_LOG_CALIBRATED_IMU
367 
368  /*
369  #if DATALOGGER_LOG_ESTIMATOR
370  gDataLogger_InsertVariable(&gDataLogger, "estimated_roll_angle_radians", &(pestimation_data->roll_angle_radians));
371  gDataLogger_InsertVariable(&gDataLogger, "estimated_pitch_angle_radians", &(pestimation_data->pitch_angle_radians));
372  gDataLogger_InsertVariable(&gDataLogger, "estimated_yaw_angle_radians", &(pestimation_data->yaw_angle_radians));
373  gDataLogger_InsertVariable(&gDataLogger, "estimated_q0", &(pestimation_data->q0));
374  gDataLogger_InsertVariable(&gDataLogger, "estimated_q1", &(pestimation_data->q1));
375  gDataLogger_InsertVariable(&gDataLogger, "estimated_q2", &(pestimation_data->q2));
376  gDataLogger_InsertVariable(&gDataLogger, "estimated_q3", &(pestimation_data->q3));
377  gDataLogger_InsertVariable(&gDataLogger, "estimated_x_position_meters", &(pestimation_data->x_position_meters));
378  gDataLogger_InsertVariable(&gDataLogger, "estimated_y_position_meters", &(pestimation_data->y_position_meters));
379  gDataLogger_InsertVariable(&gDataLogger, "estimated_z_position_meters", &(pestimation_data->z_position_meters));
380  gDataLogger_InsertVariable(&gDataLogger, "estimated_x_velocity_meters_second", &(pestimation_data->x_velocity_meters_second));
381  gDataLogger_InsertVariable(&gDataLogger, "estimated_y_velocity_meters_second", &(pestimation_data->y_velocity_meters_second));
382  gDataLogger_InsertVariable(&gDataLogger, "estimated_z_velocity_meters_second", &(pestimation_data->z_velocity_meters_second));
383  #else
384  double tmp_est = 0.0;
385  tmp_est = pestimation_data->roll_angle_radians; // Remove warning
386  #endif // DATALOGGER_LOG_ESTIMATOR
387 
388  #if DATALOGGER_LOG_CONTROLLERS
389  gDataLogger_InsertVariable(&gDataLogger, "control_roll_angle_trim_radians", &(pcontrol_data->roll_angle_trim_radians));
390  gDataLogger_InsertVariable(&gDataLogger, "control_pitch_angle_trim_radians", &(pcontrol_data->pitch_angle_trim_radians));
391  gDataLogger_InsertVariable(&gDataLogger, "control_yaw_angle_trim_radians", &(pcontrol_data->yaw_angle_trim_radians));
392  gDataLogger_InsertVariable(&gDataLogger, "control_left_aileron_trim", &(pcontrol_data->left_aileron_trim));
393  gDataLogger_InsertVariable(&gDataLogger, "control_right_aileron_trim", &(pcontrol_data->right_aileron_trim));
394  gDataLogger_InsertVariable(&gDataLogger, "control_elevator_trim", &(pcontrol_data->elevator_trim));
395  gDataLogger_InsertVariable(&gDataLogger, "control_rudder_trim", &(pcontrol_data->rudder_trim));
396  gDataLogger_InsertVariable(&gDataLogger, "control_roll_angle_reference_radians", &(pcontrol_data->roll_angle_reference_radians));
397  gDataLogger_InsertVariable(&gDataLogger, "control_pitch_angle_reference_radians", &(pcontrol_data->pitch_angle_reference_radians));
398  gDataLogger_InsertVariable(&gDataLogger, "control_yaw_angle_reference_radians", &(pcontrol_data->yaw_angle_reference_radians));
399  #else
400  double tmp_control = 0.0;
401  tmp_control = pcontrol_data->roll_angle_trim_radians;
402  #endif // DATALOGGER_LOG_CONTROLLERS
403 */
405 
406  return DATALOGGER_SUCCESS;
407 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
int gDataLogger_InsertVariable(PGDATALOGGER pgDataLogger, char *varname, double *varvalue)
Definition: gdatalogger.c:199
short int y
Definition: communication.h:77
DATA_XYZ mag
Magnetormeter Vector.
Definition: communication.h:96
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
short int v_ctl_read
Voltage level read from the actuator.
DATA_XYZ acc
Accel Vector.
Definition: communication.h:94
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
short int z
Definition: communication.h:78
struct IMU_DATA_STRUCT::calibrated calib
DATA_XYZ gyr
Gyrometer Vector.
Definition: communication.h:95
short int x
Definition: communication.h:76
short int v_ctl
Voltage level for control output.
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_update_IPC ( void  )

Definition at line 256 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_SUCCESS, datalogger_unlock_mutex(), and gDataLogger_IPCUpdate().

Referenced by threads_linux_init().

257 {
258  #if DATALOGGER_MODULE_ENABLED
261  {
264  }
265 
266  gDataLogger_IPCUpdate(&gDataLogger); // Manages IPC
268  #endif
269  return DATALOGGER_SUCCESS;
270 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
int gDataLogger_IPCUpdate(PGDATALOGGER pgDataLogger)
Definition: gdatalogger.c:274
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function:

int datalogger_write_file ( void  )

Definition at line 240 of file datalogger.c.

References DATALOGGER_ERROR_NOT_INITIALIZED, DATALOGGER_INITIALIZED, datalogger_initialized, datalogger_lock_mutex(), DATALOGGER_SUCCESS, datalogger_unlock_mutex(), and gDataLogger_MatfileUpdate().

Referenced by main(), and threads_linux_init().

241 {
242  #if DATALOGGER_MODULE_ENABLED
245  {
248  }
249  gDataLogger_MatfileUpdate(&gDataLogger); // Empty buffers in the file
251  #endif
252 
253  return DATALOGGER_SUCCESS;
254 }
#define DATALOGGER_ERROR_NOT_INITIALIZED
Definition: datalogger.h:37
int datalogger_unlock_mutex(void)
Definition: datalogger.c:639
unsigned int datalogger_initialized
Definition: datalogger.c:29
GDATALOGGER gDataLogger
Definition: datalogger.c:28
#define DATALOGGER_INITIALIZED
Definition: datalogger.h:28
int gDataLogger_MatfileUpdate(PGDATALOGGER pgDataLogger)
Definition: gdatalogger.c:245
#define DATALOGGER_SUCCESS
Definition: datalogger.h:35
int datalogger_lock_mutex(void)
Definition: datalogger.c:629

Here is the call graph for this function:

Here is the caller graph for this function: