Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MotorController.cpp 余剰ゲイン算出部の正方向および負方向動作の不一致 #2

Open
cuborex-admin opened this issue Apr 24, 2023 · 0 comments

Comments

@cuborex-admin
Copy link

float MotorController::limitSpeed(){
if(!initialized_){
return -1.0;
}
float surplus; //Iゲイン自動整合用の余剰制御量を算出
surplus = speed_ - max_speed_;

// speed_ を範囲内に調整
if(speed_ > max_speed_){
speed_ = max_speed_;
//Serial.println("更新+: " + String(speed_));
return surplus;
}else if(speed_ < -max_speed_) {
speed_ = -max_speed_;
//Serial.println("更新-: " + String(speed_));
return surplus;
} else {
return 0.0;
}

}


surplus = speed_ - max_speed_;

正回転時はsurplusは記述の通りの計算となるが、逆回転時、

speed < 0となるため、

surplus = speed_ + max_speed_;

とならなければならない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant