main_helper.c
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // main_helper.c - Epson IMU helper functions for console utilities
4 //
5 //
6 // THE SOFTWARE IS RELEASED INTO THE PUBLIC DOMAIN.
7 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9 // NONINFRINGEMENT, SECURITY, SATISFACTORY QUALITY, AND FITNESS FOR A
10 // PARTICULAR PURPOSE. IN NO EVENT SHALL EPSON BE LIABLE FOR ANY LOSS, DAMAGE
11 // OR CLAIM, ARISING FROM OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF THE
12 // SOFTWARE.
13 //
14 //==============================================================================
15 #include <stdint.h>
16 #include <stdio.h>
17 
18 #include "main_helper.h"
19 #include "sensor_epsonCommon.h"
20 
21 /*****************************************************************************
22 ** Function name: printHeaderRow
23 ** Description: Output header row
24 ** based on EpsonOptions
25 ** Parameters: fp File pointer to send the output data
26 ** struct EpsonOptions
27 ** Return value: None
28 **
29 *****************************************************************************/
30 void printHeaderRow(FILE *fp, struct EpsonOptions options) {
31  fprintf(fp, "\r\nsample[dec]");
32  if (options.flag_out) {
33  fprintf(fp, ", ndflags[hex]");
34  }
35 
36  if (options.temp_out) {
37  fprintf(fp, ", tempC[degC]");
38  }
39 
40  if (options.gyro_out) {
41  fprintf(fp, ", gx[dps], gy[dps], gz[dps]");
42  }
43 
44  if (options.accel_out) {
45  fprintf(fp, ", ax[dps], ay[dps], az[dps]");
46  }
47 
48  if (options.gyro_delta_out) {
49  fprintf(fp, ", dax[deg], day[deg], daz[deg]");
50  }
51 
52  if (options.accel_delta_out) {
53  fprintf(fp, ", dvx[m/s], dvy[m/s], dvz[m/s]");
54  }
55 
56  if (options.qtn_out) {
57  fprintf(fp, ", qtn0, qtn1, qtn2, qtn3");
58  }
59 
60  if (options.atti_out) {
61  fprintf(fp, ", roll[deg], pitch[deg], yaw[deg]");
62  }
63 
64  if (options.gpio_out) {
65  fprintf(fp, ", gpio[hex]");
66  }
67 
68  if (options.count_out) {
69  fprintf(fp, ", count[dec]");
70  }
71  fprintf(fp, "\n");
72 }
73 
74 /*****************************************************************************
75 ** Function name: printSensorRow
76 ** Description: Prints formatted row of sensor data based on how it is
77 ** configured.
78 ** Parameters: fp - file pointer to send data
79 ** options - The struct describing how the IMU is
80 ** configured.
81 ** epson_data - The struct that is filled with data from
82 ** the IMU.
83 ** sample_count - Typically and incrementing index for each
84 ** sample
85 ** Return value: none
86 ** Notes:
87 ******************************************************************************/
88 void printSensorRow(FILE *fp, struct EpsonOptions options,
89  struct EpsonData *epson_data, int sample_count) {
90  fprintf(fp, "%08d", sample_count);
91  if (options.flag_out) {
92  fprintf(fp, ", %04x", epson_data->ndflags);
93  }
94 
95  if (options.temp_out) {
96  fprintf(fp, ", %8.3f", epson_data->temperature);
97  }
98 
99  if (options.gyro_out) {
100  fprintf(fp, ", %8.5f, %8.5f, %8.5f", epson_data->gyro_x * 180.0 / 3.14159,
101  epson_data->gyro_y * 180.0 / 3.14159,
102  epson_data->gyro_z * 180.0 / 3.14159);
103  }
104 
105  if (options.accel_out) {
106  fprintf(fp, ", %8.5f, %8.5f, %8.5f", epson_data->accel_x * 1000 / 9.80665,
107  epson_data->accel_y * 1000 / 9.80665,
108  epson_data->accel_z * 1000 / 9.80665);
109  }
110 
111  if (options.gyro_delta_out) {
112  fprintf(fp, ", %8.5f, %8.5f, %8.5f", epson_data->gyro_delta_x,
113  epson_data->gyro_delta_y, epson_data->gyro_delta_z);
114  }
115 
116  if (options.accel_delta_out) {
117  fprintf(fp, ", %8.5f, %8.5f, %8.5f", epson_data->accel_delta_x,
118  epson_data->accel_delta_y, epson_data->accel_delta_z);
119  }
120 
121  if (options.qtn_out) {
122  fprintf(fp, ", %8.8f, %8.8f, %8.8f, %8.8f", epson_data->qtn0,
123  epson_data->qtn1, epson_data->qtn2, epson_data->qtn3);
124  }
125 
126  if (options.atti_out) {
127  fprintf(fp, ", %8.3f, %8.3f, %8.3f", epson_data->roll * 180.0 / 3.14159,
128  epson_data->pitch * 180.0 / 3.14159,
129  epson_data->yaw * 180.0 / 3.14159);
130  }
131 
132  if (options.gpio_out) {
133  fprintf(fp, ", %04x", epson_data->gpio);
134  }
135 
136  if (options.count_out) {
137  fprintf(fp, ", %09d", epson_data->count);
138  }
139  fprintf(fp, "\n");
140 }
unsigned short gpio
unsigned short ndflags
void printSensorRow(FILE *fp, struct EpsonOptions options, struct EpsonData *epson_data, int sample_count)
Definition: main_helper.c:88
void printHeaderRow(FILE *fp, struct EpsonOptions options)
Definition: main_helper.c:30


ess_imu_ros1_uart_driver
Author(s):
autogenerated on Sun Jun 4 2023 02:59:29