我需要校准两个颜色传感器,但是不幸的是,它们似乎在硬件方面有所不同(型号相同,从它们发出的光的反射不同,一个更亮),因为它们以相同的精度测量不同的值条件。
所以,我想到了“标准化”一个。
基本上,当我校准传感器时,我得到了计算比例所需的比率。
这是一个例子:
// lx_sensor_red -> 310
// rx_sensor_red -> 250
// Again, remember they are sitting on the same color, under the same lighting
float rx_red_ratio = ((float)lx_sensor_red)/((float)rx_sensor_red); // Not sure if I use too many parenthesis
// I do this for green and blue too
...
...
int rx_red;
get_sensor_value(0, rx_sensor, &rx_red);
rx_red = (int)(rx_red * rx_red_ratio);
// And so on..
我想知道,这合适吗?似乎可行,但是我不确定是否有更好的方法,或者在某些情况下是否会失败?