new start to work on this
This commit is contained in:
+11
-29
@@ -65,20 +65,22 @@
|
|||||||
// PS3 Controller
|
// PS3 Controller
|
||||||
// ESP32 MAC BL 24:62:AB:F2:4B:3A
|
// ESP32 MAC BL 24:62:AB:F2:4B:3A
|
||||||
|
|
||||||
#define TPMOBIL
|
#define RHEDE
|
||||||
|
|
||||||
//Network config DORTMUND
|
//Network config RHEDE
|
||||||
#ifdef DORTMUND
|
#ifdef RHEDE
|
||||||
#define WLAN_SSID "Kleiax2"
|
#define WLAN_SSID "LebennigHuus"
|
||||||
#define WLAN_PASSWORD "Punica-699"
|
#define WLAN_PASSWORD "Punica-699"
|
||||||
#define WLAN_IP 0x0101a8c0 //192.168.1.1
|
#define WLAN_IP 0x040BA8C0 //192.168.11.4
|
||||||
#define WLAN_SUBNETMASK 0x0000FFFF //255.255.0.0
|
#define WLAN_SUBNETMASK 0x0080FFFF //255.255.128.0
|
||||||
#define WLAN_GATEWAY 0x0100a8c0 //192.168.0.1
|
#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_PORT 1883
|
||||||
#define MQTT_BUFFER_SITE 128
|
#define MQTT_BUFFER_SITE 128
|
||||||
#define NTP_SERVER 0x0201a8c0 //192.168.1.2
|
#define MQTT_USER "kleiax"
|
||||||
#endif //DORTMUND
|
#define MQTT_PASSWORD "p?{$_~5%hBM7wrcFkr55KWr#"
|
||||||
|
#define NTP_SERVER 0x0100a8c0 //192.168.0.1
|
||||||
|
#endif //RHEDE
|
||||||
|
|
||||||
//Network config FRENZY
|
//Network config FRENZY
|
||||||
#ifdef FRENZY
|
#ifdef FRENZY
|
||||||
@@ -93,26 +95,6 @@
|
|||||||
#define NTP_SERVER 0x0201a8c0 //192.168.1.2
|
#define NTP_SERVER 0x0201a8c0 //192.168.1.2
|
||||||
#endif //FRENZY
|
#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
|
//Network config TPMOBIL
|
||||||
#ifdef TPMOBIL
|
#ifdef TPMOBIL
|
||||||
#define WLAN_SSID "TP-Mobil"
|
#define WLAN_SSID "TP-Mobil"
|
||||||
|
|||||||
@@ -7,34 +7,38 @@ ConsolControl::ConsolControl() {
|
|||||||
|
|
||||||
void ConsolControl::init(MoveControl *MoveControl) {
|
void ConsolControl::init(MoveControl *MoveControl) {
|
||||||
this->moveControl = moveControl;
|
this->moveControl = moveControl;
|
||||||
this->left_pid = this->moveControl->getPID(0);
|
|
||||||
this->right_pid = this->moveControl->getPID(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsolControl::run() {
|
void ConsolControl::run() {
|
||||||
PID *selectedPID;
|
uint8_t side = -1;
|
||||||
|
|
||||||
if (Serial.available()) {
|
if (Serial.available()) {
|
||||||
char cmd = Serial.read();
|
char cmd = Serial.read();
|
||||||
if (cmd == 'l') {
|
if (cmd == 'l') {
|
||||||
selectedPID = this->left_pid;
|
side = 0;
|
||||||
} else if (cmd == 'r') {
|
} else if (cmd == 'r') {
|
||||||
selectedPID = this->right_pid;
|
side = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double p = Serial.parseFloat();
|
double p = Serial.parseFloat();
|
||||||
double i = Serial.parseFloat();
|
double i = Serial.parseFloat();
|
||||||
double d = 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");
|
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 {
|
} else {
|
||||||
|
this->moveControl->setDrivingStatus(DrivingStatus::stop);
|
||||||
printManual();
|
printManual();
|
||||||
|
debug->sendMsg(Loglevel::error, "not all double are not zero");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printManual() {
|
void ConsolControl::printManual() {
|
||||||
Serial.println("r 12.0 13.0 4.0 // site p i d");
|
Serial.println("r 12.0 13.0 4.0 // site p i d s r");
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,6 @@ class ConsolControl {
|
|||||||
|
|
||||||
MoveControl *moveControl;
|
MoveControl *moveControl;
|
||||||
DebugMqtt *debug;
|
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) {
|
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...");
|
debug->sendMsg(Loglevel::info, "Init...");
|
||||||
|
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
|
||||||
this->pwm_pin = pwm_pin;
|
this->pwm_pin = pwm_pin;
|
||||||
|
|||||||
+1
-1
@@ -144,7 +144,7 @@ void reconnectMqtt() {
|
|||||||
String clientId = "ESP32Rover-";
|
String clientId = "ESP32Rover-";
|
||||||
clientId += String(random(0xffff), HEX);
|
clientId += String(random(0xffff), HEX);
|
||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
if (mqtt_client.connect(clientId.c_str())) {
|
if (mqtt_client.connect(clientId.c_str(), MQTT_USER, MQTT_PASSWORD)) {
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
// Once connected, publish an announcement...
|
// Once connected, publish an announcement...
|
||||||
mqtt_client.publish("Rover/Info", "Connected to Mqtt-Broker");
|
mqtt_client.publish("Rover/Info", "Connected to Mqtt-Broker");
|
||||||
|
|||||||
+14
-14
@@ -48,11 +48,11 @@ void MoveControl::runMoveControl() {
|
|||||||
this->calcWheelSpeed();
|
this->calcWheelSpeed();
|
||||||
this->regulateMotors();
|
this->regulateMotors();
|
||||||
|
|
||||||
// char str[128];
|
char str[128];
|
||||||
// sprintf(str, "x_speed: %3.2f, rotation_speed: %3.2f, tar_left: %3.2f, tar_right: %3.2f",
|
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_target,
|
this->x_speed, this->rotation_speed, this->wheelspeed_left,
|
||||||
// this->wheelspeed_right_target);
|
this->wheelspeed_right);
|
||||||
// debug->sendMsg(Loglevel::debug, str);
|
debug->sendMsg(Loglevel::debug, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::setDrivingStatus(DrivingStatus status) {
|
void MoveControl::setDrivingStatus(DrivingStatus status) {
|
||||||
@@ -68,14 +68,15 @@ void MoveControl::setRotationspeed(double speed) {
|
|||||||
this->rotation_speed = speed;
|
this->rotation_speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
PID* MoveControl::getPID(uint8_t i) {
|
void MoveControl::setPidTunings(uint8_t side, double p, double i, double d) {
|
||||||
if (i == 0) {
|
PID* selectedPID = nullptr;
|
||||||
return this->left_pid;
|
if (side == 0)
|
||||||
} else if (i == 1) {
|
selectedPID = this->left_pid;
|
||||||
return this->right_pid;
|
else if (side == 1)
|
||||||
} else {
|
selectedPID = this->right_pid;
|
||||||
return nullptr;
|
|
||||||
}
|
selectedPID->SetTunings(p, i, d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::calcWheelSpeed() {
|
void MoveControl::calcWheelSpeed() {
|
||||||
@@ -95,7 +96,6 @@ void MoveControl::calcWheelSpeed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::regulateMotors() {
|
void MoveControl::regulateMotors() {
|
||||||
double ratio = 0;
|
|
||||||
switch (this->driving_status) {
|
switch (this->driving_status) {
|
||||||
case DrivingStatus::stop :
|
case DrivingStatus::stop :
|
||||||
this->left_motor->setTargetPower(0);
|
this->left_motor->setTargetPower(0);
|
||||||
|
|||||||
+1
-2
@@ -22,8 +22,7 @@ class MoveControl {
|
|||||||
void setDrivingStatus(DrivingStatus status);
|
void setDrivingStatus(DrivingStatus status);
|
||||||
void setSpeed(double speed);
|
void setSpeed(double speed);
|
||||||
void setRotationspeed(double speed);
|
void setRotationspeed(double speed);
|
||||||
|
void setPidTunings(uint8_t side, double p, double i, double d);
|
||||||
PID* getPID(uint8_t i);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calcWheelSpeed();
|
void calcWheelSpeed();
|
||||||
|
|||||||
Reference in New Issue
Block a user