22NOTE: SET COOLTERM BAUD RATE TO 115,200
33*/
44
5+ #include <conversions/conversions.h>
6+
57#include "../../src/imu.h"
68
79void receive_and_print_packets (uint16_t count ) {
@@ -45,7 +47,7 @@ void test_prod_id(void) {
4547void test_accel_once (void ) {
4648 print ("\nGetting acceleration...\n\n" );
4749
48- int16_t x = 0 , y = 0 , z = 0 ;
50+ uint16_t x = 0 , y = 0 , z = 0 ;
4951 if (!get_imu_accel (& x , & y , & z )) {
5052 print ("\nGet acceleration: FAIL\n\n" );
5153 return ;
@@ -69,7 +71,7 @@ void test_accel_inf(void) {
6971}
7072
7173void test_accel_fast_once (void ) {
72- int16_t x = 0 , y = 0 , z = 0 ;
74+ uint16_t x = 0 , y = 0 , z = 0 ;
7375 get_imu_accel (& x , & y , & z );
7476 print ("Acceleration: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
7577 imu_raw_data_to_double (x , IMU_ACCEL_Q ),
@@ -80,8 +82,8 @@ void test_accel_fast_once(void) {
8082void test_uncal_gyro_once (void ) {
8183 print ("\nGetting uncalibrated gyroscope...\n\n" );
8284
83- int16_t x = 0 , y = 0 , z = 0 ;
84- int16_t bias_x = 0 , bias_y = 0 , bias_z = 0 ;
85+ uint16_t x = 0 , y = 0 , z = 0 ;
86+ uint16_t bias_x = 0 , bias_y = 0 , bias_z = 0 ;
8587 if (!get_imu_uncal_gyro (& x , & y , & z , & bias_x , & bias_y , & bias_z )) {
8688 print ("\nGet uncalibrated gyroscope: FAIL\n\n" );
8789 return ;
@@ -91,14 +93,14 @@ void test_uncal_gyro_once(void) {
9193 print ("Get uncalibrated gyroscope: SUCCESS\n" );
9294 print ("Raw: x = %d, y = %d, z = %d\n" , x , y , z );
9395 print ("Converted: x = %.6f, y = %.6f, z = %.6f\n" ,
94- imu_raw_data_to_double ( x , IMU_UNCAL_GYRO_Q ),
95- imu_raw_data_to_double ( y , IMU_UNCAL_GYRO_Q ),
96- imu_raw_data_to_double ( z , IMU_UNCAL_GYRO_Q ));
96+ imu_raw_data_to_gyro ( x ),
97+ imu_raw_data_to_gyro ( y ),
98+ imu_raw_data_to_gyro ( z ));
9799 print ("Raw: bias_x = %d, bias_y = %d, bias_z = %d\n" , bias_x , bias_y , bias_z );
98100 print ("Converted: bias_x = %.6f, bias_y = %.6f, bias_z = %.6f\n" ,
99- imu_raw_data_to_double (bias_x , IMU_UNCAL_GYRO_Q ),
100- imu_raw_data_to_double (bias_y , IMU_UNCAL_GYRO_Q ),
101- imu_raw_data_to_double (bias_z , IMU_UNCAL_GYRO_Q ));
101+ imu_raw_data_to_gyro (bias_x ),
102+ imu_raw_data_to_gyro (bias_y ),
103+ imu_raw_data_to_gyro (bias_z ));
102104 print ("\n" );
103105}
104106
@@ -110,18 +112,18 @@ void test_uncal_gyro_inf(void) {
110112}
111113
112114void test_uncal_gyro_fast_once (void ) {
113- int16_t x = 0 , y = 0 , z = 0 ;
115+ uint16_t x = 0 , y = 0 , z = 0 ;
114116 get_imu_uncal_gyro (& x , & y , & z , NULL , NULL , NULL );
115117 print ("Uncalibrated Gyroscope: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
116- imu_raw_data_to_double ( x , IMU_UNCAL_GYRO_Q ),
117- imu_raw_data_to_double ( y , IMU_UNCAL_GYRO_Q ),
118- imu_raw_data_to_double ( z , IMU_UNCAL_GYRO_Q ));
118+ imu_raw_data_to_gyro ( x ),
119+ imu_raw_data_to_gyro ( y ),
120+ imu_raw_data_to_gyro ( z ));
119121}
120122
121123void test_cal_gyro_once (void ) {
122124 print ("\nGetting calibrated gyroscope...\n\n" );
123125
124- int16_t x = 0 , y = 0 , z = 0 ;
126+ uint16_t x = 0 , y = 0 , z = 0 ;
125127 if (!get_imu_cal_gyro (& x , & y , & z )) {
126128 print ("\nGet calibrated gyroscope.: FAIL\n\n" );
127129 return ;
@@ -131,9 +133,9 @@ void test_cal_gyro_once(void) {
131133 print ("Get calibrated gyroscope.: SUCCESS\n" );
132134 print ("Raw: x = %d, y = %d, z = %d\n" , x , y , z );
133135 print ("Converted: x = %.6f, y = %.6f, z = %.6f\n" ,
134- imu_raw_data_to_double ( x , IMU_CAL_GYRO_Q ),
135- imu_raw_data_to_double ( y , IMU_CAL_GYRO_Q ),
136- imu_raw_data_to_double ( z , IMU_CAL_GYRO_Q ));
136+ imu_raw_data_to_gyro ( x ),
137+ imu_raw_data_to_gyro ( y ),
138+ imu_raw_data_to_gyro ( z ));
137139 print ("\n" );
138140}
139141
@@ -146,38 +148,38 @@ void test_cal_gyro_inf(void) {
146148
147149// Without success/fail print statements
148150void test_cal_gyro_fast_once (void ) {
149- int16_t x = 0 , y = 0 , z = 0 ;
151+ uint16_t x = 0 , y = 0 , z = 0 ;
150152 get_imu_cal_gyro (& x , & y , & z );
151153 print ("Calibrated Gyroscope: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
152- imu_raw_data_to_double ( x , IMU_CAL_GYRO_Q ),
153- imu_raw_data_to_double ( y , IMU_CAL_GYRO_Q ),
154- imu_raw_data_to_double ( z , IMU_CAL_GYRO_Q ));
154+ imu_raw_data_to_gyro ( x ),
155+ imu_raw_data_to_gyro ( y ),
156+ imu_raw_data_to_gyro ( z ));
155157}
156158
157159// Compare uncalibrated with calibrated
158160void test_gyro_comp_inf (void ) {
159161 print ("\nGetting gyroscope...\n\n" );
160162
161163 while (1 ) {
162- int16_t uncal_x = 0 , uncal_y = 0 , uncal_z = 0 ;
163- int16_t bias_x = 0 , bias_y = 0 , bias_z = 0 ;
164+ uint16_t uncal_x = 0 , uncal_y = 0 , uncal_z = 0 ;
165+ uint16_t bias_x = 0 , bias_y = 0 , bias_z = 0 ;
164166 get_imu_uncal_gyro (& uncal_x , & uncal_y , & uncal_z , & bias_x , & bias_y , & bias_z );
165- int16_t cal_x = 0 , cal_y = 0 , cal_z = 0 ;
167+ uint16_t cal_x = 0 , cal_y = 0 , cal_z = 0 ;
166168 get_imu_cal_gyro (& cal_x , & cal_y , & cal_z );
167169
168170 print ("\n" );
169171 print ("Uncalibrated: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
170- imu_raw_data_to_double (uncal_x , IMU_UNCAL_GYRO_Q ),
171- imu_raw_data_to_double (uncal_y , IMU_UNCAL_GYRO_Q ),
172- imu_raw_data_to_double (uncal_z , IMU_UNCAL_GYRO_Q ));
172+ imu_raw_data_to_gyro (uncal_x ),
173+ imu_raw_data_to_gyro (uncal_y ),
174+ imu_raw_data_to_gyro (uncal_z ));
173175 print ("Calibrated: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
174- imu_raw_data_to_double (cal_x , IMU_CAL_GYRO_Q ),
175- imu_raw_data_to_double (cal_y , IMU_CAL_GYRO_Q ),
176- imu_raw_data_to_double (cal_z , IMU_CAL_GYRO_Q ));
176+ imu_raw_data_to_gyro (cal_x ),
177+ imu_raw_data_to_gyro (cal_y ),
178+ imu_raw_data_to_gyro (cal_z ));
177179 print ("Bias: x = %+.6f, y = %+.6f, z = %+.6f\n" ,
178- imu_raw_data_to_double (bias_x , IMU_UNCAL_GYRO_Q ),
179- imu_raw_data_to_double (bias_y , IMU_UNCAL_GYRO_Q ),
180- imu_raw_data_to_double (bias_z , IMU_UNCAL_GYRO_Q ));
180+ imu_raw_data_to_gyro (bias_x ),
181+ imu_raw_data_to_gyro (bias_y ),
182+ imu_raw_data_to_gyro (bias_z ));
181183 }
182184}
183185
0 commit comments