beagleboard / librobotcontrol

Robotics Focused library for embedded Linux computers. Mirror of https://git.beagleboard.org/beagleboard/librobotcontrol
https://beagleboard.org/librobotcontrol
MIT License
195 stars 157 forks source link

Debian Buster: gcc 7.3.0-3 build noise/warnings [Wdouble-promotion] #114

Closed RobertCNelson closed 6 years ago

RobertCNelson commented 6 years ago

Hi James,

Noticed tonight some new Warnings with debian buster's 7.3.0 based gcc, it didn't stop the build or break anything, just something to aware off. (gcc 8.x.x is probally incoming into buster later this year)

Regards,

Generated: bin/am335x-pru0-rc-encoder-fw bin/am335x-pru1-rc-servo-fw
made: build/model.o
made: build/motor.o
src/dsm.c: In function 'rc_dsm_ch_normalized':
src/dsm.c:622:27: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(fabsf(range_up[ch-1]) < zero_tolerance || fabsf(range_down[ch-1]) < zero_tolerance || channels[ch-1]==0) return 0.0f;
                           ^
src/dsm.c:622:71: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(fabsf(range_up[ch-1]) < zero_tolerance || fabsf(range_down[ch-1]) < zero_tolerance || channels[ch-1]==0) return 0.0f;
                                                                       ^
made: build/dsm.o
made: build/button.o
made: build/math/other.o
src/math/polynomial.c: In function 'rc_poly_butter':
src/math/polynomial.c:330:17: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
   P3.d[0] = 1.0f/(wc*wc);  // Initialize leading coefficient based on crossover
                 ^
src/math/polynomial.c:334:43: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                                           ^
src/math/polynomial.c:334:48: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                                                ^
src/math/polynomial.c:334:19: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                   ^
src/math/polynomial.c:350:17: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
   P2.d[0] = 1.0f/wc;
                 ^
src/math/polynomial.c:358:17: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
   P3.d[0] = 1.0f/(wc*wc);
                 ^
src/math/polynomial.c:361:43: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                                           ^
src/math/polynomial.c:361:48: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                                                ^
src/math/polynomial.c:361:19: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
    P3.d[1] = -2.0f*cos((2.0f*i + N - 1.0f)*M_PI/(2.0f*N))/wc;
                   ^
made: build/math/polynomial.o
made: build/math/algebra_common.o
made: build/math/matrix.o
src/math/kalman.c: In function 'rc_kalman_reset':
src/math/kalman.c:156:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
made: build/math/kalman.o
src/math/vector.c: In function 'rc_vector_norm':
src/math/vector.c:237:6: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(p<1.001f && p>0.999f){
      ^
src/math/vector.c:237:18: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(p<1.001f && p>0.999f){
                  ^
src/math/vector.c:242:6: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(p<2.001f && p>1.999f){
      ^
src/math/vector.c:242:18: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(p<2.001f && p>1.999f){
                  ^
made: build/math/vector.o
src/math/filter.c: In function 'rc_filter_first_order_lowpass':
src/math/filter.c:587:13: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  den[1] = c -1.0f;
             ^
src/math/filter.c: In function 'rc_filter_first_order_highpass':
src/math/filter.c:613:15: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  num[0] = 1.0f-c;
               ^
src/math/filter.c:614:12: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  num[1] = c-1.0f;
            ^
src/math/filter.c:616:12: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  den[1] = c-1.0f;
            ^
made: build/math/filter.o
made: build/math/ring_buffer.o
made: build/math/quaternion.o
src/math/algebra.c: In function 'rc_algebra_qr_decomp':
src/math/algebra.c:148:9: warning: unused variable 'norm' [-Wunused-variable]
  double norm;
         ^~~~
src/math/algebra.c:147:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,steps;
        ^
made: build/math/algebra.o
made: build/version.o
made: build/pinmux.o
made: build/led.o
made: build/bmp/bmp.o
made: build/pthread.o
made: build/encoder.o
made: build/cpu.o
made: build/time.o
made: build/deprecated.o
made: build/pru/encoder_pru.o
made: build/pru/pru.o
src/pru/servo.c: In function 'rc_servo_send_pulse_normalized':
src/pru/servo.c:156:10: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-1.5-TOL) || input>(1.5+TOL)){
          ^
src/pru/servo.c:156:30: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-1.5-TOL) || input>(1.5+TOL)){
                              ^
src/pru/servo.c:161:28: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  us = 1500 + lroundf((input*600.0));
                            ^
src/pru/servo.c: In function 'rc_servo_send_esc_pulse_normalized':
src/pru/servo.c:170:10: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-0.1-TOL) || input>(1.0+TOL)){
          ^
src/pru/servo.c:170:30: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-0.1-TOL) || input>(1.0+TOL)){
                              ^
src/pru/servo.c:174:28: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  us = 1000 + lroundf((input*1000.0));
                            ^
src/pru/servo.c: In function 'rc_servo_send_oneshot_pulse_normalized':
src/pru/servo.c:183:10: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-0.1-TOL) || input>(1.0+TOL)){
          ^
src/pru/servo.c:183:30: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  if(input<(-0.1-TOL) || input>(1.0+TOL)){
                              ^
src/pru/servo.c:187:26: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  us = 125 + lroundf(input*125.0);
                          ^
made: build/pru/servo.o
made: build/start_stop.o
made: build/io/spi.o
made: build/io/i2c.o
made: build/io/uart.o
made: build/io/adc.o
made: build/io/gpio.o
made: build/io/encoder_eqep.o
made: build/io/pwm.o
made: build/mavlink_udp.o
src/mpu/mpu.c: In function 'rc_mpu_calibrate_mag_routine':
src/mpu/mpu.c:2889:22: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  new_scale[0] = 70.0f/lengths.d[0];
                      ^
src/mpu/mpu.c:2890:22: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  new_scale[1] = 70.0f/lengths.d[1];
                      ^
src/mpu/mpu.c:2891:22: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  new_scale[2] = 70.0f/lengths.d[2];
                      ^
made: build/mpu/mpu.o
Done making lib/libroboticscape.so

Regards,

StrawsonDesign commented 6 years ago

thanks for the head up!! Thing brings up something I've had floating (pun not intended) around the back of my head for a while now. Since promoting all the math library to double-precision, I was thinking of promoting the rest of the library to doubles even when it's not strictly necessary, for consistency and to perhaps avoid similar warnings in other people's projects. Everything was single-precision at first because the Sitara only does vectorized math at single-precision, but I found that in practice single-precision is simply not good enough for linear algebra and some of the control systems I do. Thoughts?

StrawsonDesign commented 6 years ago

fixed warnings with 3026d76892951504b04a5e130166b463ed269c69