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
+13 -9
View File
@@ -7,34 +7,38 @@ ConsolControl::ConsolControl() {
void ConsolControl::init(MoveControl *MoveControl) {
this->moveControl = moveControl;
this->left_pid = this->moveControl->getPID(0);
this->right_pid = this->moveControl->getPID(1);
}
void ConsolControl::run() {
PID *selectedPID;
uint8_t side = -1;
if (Serial.available()) {
char cmd = Serial.read();
if (cmd == 'l') {
selectedPID = this->left_pid;
side = 0;
} else if (cmd == 'r') {
selectedPID = this->right_pid;
side = 1;
}
double p = Serial.parseFloat();
double i = Serial.parseFloat();
double d = Serial.parseFloat();
double s = Serial.parseFloat();
double r = Serial.parseFloat();
if (p && i && d) {
if (p && i && d && s && r) {
Serial.println("ConsolControl changeDate");
selectedPID->SetTunings(p, i, d);
this->moveControl->setPidTunings(side, p, i, d);
this->moveControl->setSpeed(s);
this->moveControl->setRotationspeed(r);
} else {
this->moveControl->setDrivingStatus(DrivingStatus::stop);
printManual();
debug->sendMsg(Loglevel::error, "not all double are not zero");
}
}
}
void printManual() {
Serial.println("r 12.0 13.0 4.0 // site p i d");
void ConsolControl::printManual() {
Serial.println("r 12.0 13.0 4.0 // site p i d s r");
}
-3
View File
@@ -15,9 +15,6 @@ class ConsolControl {
MoveControl *moveControl;
DebugMqtt *debug;
PID *left_pid;
PID *right_pid;
};