in str/apps/src/Walker.cpp [97:146]
void Walker::angleChange(int angle, int rotation) {
int32_t defaultAngleL;
int8_t dAngle = 75; // 45度におけるモーター回転数(床材によって変わる?)
if(rotation >= 0) {
if(leftRight == 1) {
rotation = 1;
} else {
rotation = -1;
}
} else {
if(leftRight == 1) {
rotation = -1;
} else {
rotation = 1;
}
}
/*
* 本来は45度単位だから、angleは45で割る
* ベータ機能として5度単位でも曲がれるようにしている
* そのため、もしangleが5度単位である場合はdAngleを9分割する
*/
if(angle % 5 == 0 && angle % 45 != 0) {
dAngle = 8;
angle /= 5;
} else {
angle -= angle % 45;
angle /= 45;
}
defaultAngleL = leftWheel.getCount();
while(1) {
run(0, 10 * rotation);
if(rotation >= 0) {
if(leftWheel.getCount() - defaultAngleL < -dAngle * angle * rotation ||
leftWheel.getCount() - defaultAngleL > dAngle * angle * rotation) {
break;
}
} else {
if(leftWheel.getCount() - defaultAngleL > -dAngle * angle * rotation ||
leftWheel.getCount() - defaultAngleL < dAngle * angle * rotation) {
break;
}
}
clock.sleep(4);
}
stop();
}