new start to work on this

This commit is contained in:
2021-11-08 11:23:51 +01:00
parent 028b82e81a
commit fc5850303a
7 changed files with 40 additions and 59 deletions
+14 -14
View File
@@ -48,11 +48,11 @@ void MoveControl::runMoveControl() {
this->calcWheelSpeed();
this->regulateMotors();
// char str[128];
// sprintf(str, "x_speed: %3.2f, rotation_speed: %3.2f, tar_left: %3.2f, tar_right: %3.2f",
// this->x_speed, this->rotation_speed, this->wheelspeed_left_target,
// this->wheelspeed_right_target);
// debug->sendMsg(Loglevel::debug, str);
char str[128];
sprintf(str, "x_speed: %3.2f, rotation_speed: %3.2f, left: %3.2f, right: %3.2f",
this->x_speed, this->rotation_speed, this->wheelspeed_left,
this->wheelspeed_right);
debug->sendMsg(Loglevel::debug, str);
}
void MoveControl::setDrivingStatus(DrivingStatus status) {
@@ -68,14 +68,15 @@ void MoveControl::setRotationspeed(double speed) {
this->rotation_speed = speed;
}
PID* MoveControl::getPID(uint8_t i) {
if (i == 0) {
return this->left_pid;
} else if (i == 1) {
return this->right_pid;
} else {
return nullptr;
}
void MoveControl::setPidTunings(uint8_t side, double p, double i, double d) {
PID* selectedPID = nullptr;
if (side == 0)
selectedPID = this->left_pid;
else if (side == 1)
selectedPID = this->right_pid;
selectedPID->SetTunings(p, i, d);
}
void MoveControl::calcWheelSpeed() {
@@ -95,7 +96,6 @@ void MoveControl::calcWheelSpeed() {
}
void MoveControl::regulateMotors() {
double ratio = 0;
switch (this->driving_status) {
case DrivingStatus::stop :
this->left_motor->setTargetPower(0);