new start to work on this
This commit is contained in:
+11
-29
@@ -65,20 +65,22 @@
|
||||
// PS3 Controller
|
||||
// ESP32 MAC BL 24:62:AB:F2:4B:3A
|
||||
|
||||
#define TPMOBIL
|
||||
#define RHEDE
|
||||
|
||||
//Network config DORTMUND
|
||||
#ifdef DORTMUND
|
||||
#define WLAN_SSID "Kleiax2"
|
||||
//Network config RHEDE
|
||||
#ifdef RHEDE
|
||||
#define WLAN_SSID "LebennigHuus"
|
||||
#define WLAN_PASSWORD "Punica-699"
|
||||
#define WLAN_IP 0x0101a8c0 //192.168.1.1
|
||||
#define WLAN_SUBNETMASK 0x0000FFFF //255.255.0.0
|
||||
#define WLAN_IP 0x040BA8C0 //192.168.11.4
|
||||
#define WLAN_SUBNETMASK 0x0080FFFF //255.255.128.0
|
||||
#define WLAN_GATEWAY 0x0100a8c0 //192.168.0.1
|
||||
#define MQTT_SERVER 0x0201a8c0 //192.168.1.2
|
||||
#define MQTT_SERVER 0x0701A8C0 //192.168.1.7
|
||||
#define MQTT_PORT 1883
|
||||
#define MQTT_BUFFER_SITE 128
|
||||
#define NTP_SERVER 0x0201a8c0 //192.168.1.2
|
||||
#endif //DORTMUND
|
||||
#define MQTT_USER "kleiax"
|
||||
#define MQTT_PASSWORD "p?{$_~5%hBM7wrcFkr55KWr#"
|
||||
#define NTP_SERVER 0x0100a8c0 //192.168.0.1
|
||||
#endif //RHEDE
|
||||
|
||||
//Network config FRENZY
|
||||
#ifdef FRENZY
|
||||
@@ -93,26 +95,6 @@
|
||||
#define NTP_SERVER 0x0201a8c0 //192.168.1.2
|
||||
#endif //FRENZY
|
||||
|
||||
//Network config VOERDE
|
||||
#ifdef VOERDE
|
||||
// #define KELLER
|
||||
#ifndef KELLER
|
||||
#define WLAN_SSID "Der Neue"
|
||||
#define WLAN_PASSWORD "Punica-699"
|
||||
#endif // KELLLER
|
||||
#ifdef KELLER
|
||||
#define WLAN_SSID "Keller-Wlan"
|
||||
#define WLAN_PASSWORD "Punica-699"
|
||||
#endif // KELLER
|
||||
#define WLAN_IP 0x4db2a8c0 //192.168.178.77
|
||||
#define WLAN_SUBNETMASK 0x00FFFFFF //255.255.255.0
|
||||
#define WLAN_GATEWAY 0x01b2a8c0 //192.168.178.1
|
||||
#define MQTT_SERVER 0x4eb2a8c0 //192.168.178.78
|
||||
#define MQTT_PORT 1883
|
||||
#define MQTT_BUFFER_SITE 128
|
||||
#define NTP_SERVER 0x01b2a8c0 //192.168.178.1
|
||||
#endif // VOERDE
|
||||
|
||||
//Network config TPMOBIL
|
||||
#ifdef TPMOBIL
|
||||
#define WLAN_SSID "TP-Mobil"
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
@@ -15,9 +15,6 @@ class ConsolControl {
|
||||
|
||||
MoveControl *moveControl;
|
||||
DebugMqtt *debug;
|
||||
PID *left_pid;
|
||||
PID *right_pid;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ MotorControl::MotorControl() {
|
||||
|
||||
void MotorControl::init(uint8_t pwm_pin, uint8_t pwm_channel, uint8_t direction_pin_1, uint8_t direction_pin_2, String name) {
|
||||
debug->sendMsg(Loglevel::info, "Init...");
|
||||
|
||||
this->name = name;
|
||||
|
||||
this->pwm_pin = pwm_pin;
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ void reconnectMqtt() {
|
||||
String clientId = "ESP32Rover-";
|
||||
clientId += String(random(0xffff), HEX);
|
||||
// Attempt to connect
|
||||
if (mqtt_client.connect(clientId.c_str())) {
|
||||
if (mqtt_client.connect(clientId.c_str(), MQTT_USER, MQTT_PASSWORD)) {
|
||||
Serial.println("connected");
|
||||
// Once connected, publish an announcement...
|
||||
mqtt_client.publish("Rover/Info", "Connected to Mqtt-Broker");
|
||||
|
||||
+14
-14
@@ -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);
|
||||
|
||||
+1
-2
@@ -22,8 +22,7 @@ class MoveControl {
|
||||
void setDrivingStatus(DrivingStatus status);
|
||||
void setSpeed(double speed);
|
||||
void setRotationspeed(double speed);
|
||||
|
||||
PID* getPID(uint8_t i);
|
||||
void setPidTunings(uint8_t side, double p, double i, double d);
|
||||
|
||||
private:
|
||||
void calcWheelSpeed();
|
||||
|
||||
Reference in New Issue
Block a user