我正在通过 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);