0
我正在通過Python進行黑客攻擊;在Python中映射磁力計數據
現在我正試圖讓使用Python的磁力儀使用機器人的標題。問題是我想通過將基於度的值映射到我自己的集上來設置「北」。如果我編程Arduino,我會使用map()函數。 Python中有類似的東西嗎?
// how many degrees are we off
int diff = compassValue-direc;
// modify degress
if(diff > 180)
diff = -360+diff;
else if(diff < -180)
diff = 360+diff;
// Make the robot turn to its proper orientation
diff = map(diff, -180, 180, -255, 255);
可能重複(http://stackoverflow.com/questions/1969240/mapping-a-range-of - 值到另一個) – leon