Added python debugger and added hw1 enviroment
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Connected with result code "+str(rc))
|
||||||
|
|
||||||
|
# Subscribing in on_connect() means that if we lose the connection and
|
||||||
|
# reconnect then subscriptions will be renewed.
|
||||||
|
client.subscribe("Rover/Info")
|
||||||
|
client.subscribe("Rover/Warn")
|
||||||
|
client.subscribe("Rover/Error")
|
||||||
|
client.subscribe("Rover/Info")
|
||||||
|
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
print(msg.topic+" -> "+str(msg.payload)[2:-1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
client = mqtt.Client()
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.on_message = on_message
|
||||||
|
|
||||||
|
client.connect("dz-pi.hw1.fb4.fh", 1883, 60)
|
||||||
|
|
||||||
|
client.loop_forever()
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Connected with result code "+str(rc))
|
||||||
|
|
||||||
|
# Subscribing in on_connect() means that if we lose the connection and
|
||||||
|
# reconnect then subscriptions will be renewed.
|
||||||
|
client.subscribe("Rover/Debug")
|
||||||
|
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
print(msg.topic+" -> "+str(msg.payload)[2:-1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
client = mqtt.Client()
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.on_message = on_message
|
||||||
|
|
||||||
|
client.connect("dz-pi.hw1.fb4.fh", 1883, 60)
|
||||||
|
|
||||||
|
client.loop_forever()
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Connected with result code "+str(rc))
|
||||||
|
|
||||||
|
# Subscribing in on_connect() means that if we lose the connection and
|
||||||
|
# reconnect then subscriptions will be renewed.
|
||||||
|
client.subscribe("Rover/Info")
|
||||||
|
client.subscribe("Rover/Warn")
|
||||||
|
client.subscribe("Rover/Error")
|
||||||
|
client.subscribe("Rover/Info")
|
||||||
|
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
print(msg.topic+" -> "+str(msg.payload)[2:-1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
client = mqtt.Client()
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.on_message = on_message
|
||||||
|
|
||||||
|
client.connect("192.168.1.2", 1883, 60)
|
||||||
|
|
||||||
|
client.loop_forever()
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Connected with result code "+str(rc))
|
||||||
|
|
||||||
|
# Subscribing in on_connect() means that if we lose the connection and
|
||||||
|
# reconnect then subscriptions will be renewed.
|
||||||
|
client.subscribe("Rover/Debug")
|
||||||
|
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
print(msg.topic+" -> "+str(msg.payload)[2:-1])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
client = mqtt.Client()
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.on_message = on_message
|
||||||
|
|
||||||
|
client.connect("192.168.1.2", 1883, 60)
|
||||||
|
|
||||||
|
client.loop_forever()
|
||||||
+16
-1
@@ -65,7 +65,7 @@
|
|||||||
// PS3 Controller
|
// PS3 Controller
|
||||||
// ESP32 MAC BL 24:62:AB:F2:4B:3A
|
// ESP32 MAC BL 24:62:AB:F2:4B:3A
|
||||||
|
|
||||||
#define RHEDE
|
#define HW1
|
||||||
|
|
||||||
//Network config RHEDE
|
//Network config RHEDE
|
||||||
#ifdef RHEDE
|
#ifdef RHEDE
|
||||||
@@ -77,11 +77,26 @@
|
|||||||
#define MQTT_SERVER 0x0701A8C0 //192.168.1.7
|
#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 MQTT_AUTH
|
||||||
#define MQTT_USER "kleiax"
|
#define MQTT_USER "kleiax"
|
||||||
#define MQTT_PASSWORD "p?{$_~5%hBM7wrcFkr55KWr#"
|
#define MQTT_PASSWORD "p?{$_~5%hBM7wrcFkr55KWr#"
|
||||||
#define NTP_SERVER 0x0100a8c0 //192.168.0.1
|
#define NTP_SERVER 0x0100a8c0 //192.168.0.1
|
||||||
#endif //RHEDE
|
#endif //RHEDE
|
||||||
|
|
||||||
|
|
||||||
|
//Network config HW1
|
||||||
|
#ifdef HW1
|
||||||
|
#define WLAN_SSID "hw1_gast"
|
||||||
|
#define WLAN_PASSWORD "KeineAhnung"
|
||||||
|
#define WLAN_IP 0x3400a8c0 //192.168.0.67
|
||||||
|
#define WLAN_SUBNETMASK 0x00FFFFFF //255.255.255.0
|
||||||
|
#define WLAN_GATEWAY 0x0100a8c0 //192.168.0.1
|
||||||
|
#define MQTT_SERVER "dz-pi.hw1.fb4.fh"
|
||||||
|
#define MQTT_PORT 1883
|
||||||
|
#define MQTT_BUFFER_SITE 128
|
||||||
|
#define NTP_SERVER "2.de.pool.ntp.org"
|
||||||
|
#endif //HW1
|
||||||
|
|
||||||
//Network config FRENZY
|
//Network config FRENZY
|
||||||
#ifdef FRENZY
|
#ifdef FRENZY
|
||||||
#define WLAN_SSID "GNX7EDD84-2"
|
#define WLAN_SSID "GNX7EDD84-2"
|
||||||
|
|||||||
+8
-2
@@ -38,7 +38,7 @@ ConsolControl consolControl;
|
|||||||
IPAddress local_IP(WLAN_IP);
|
IPAddress local_IP(WLAN_IP);
|
||||||
IPAddress gateway(WLAN_GATEWAY);
|
IPAddress gateway(WLAN_GATEWAY);
|
||||||
IPAddress subnet(WLAN_SUBNETMASK);
|
IPAddress subnet(WLAN_SUBNETMASK);
|
||||||
IPAddress mqtt_server(MQTT_SERVER);
|
// IPAddress mqtt_server(MQTT_SERVER);
|
||||||
|
|
||||||
WiFiClient wifi_client;
|
WiFiClient wifi_client;
|
||||||
PubSubClient mqtt_client(wifi_client);
|
PubSubClient mqtt_client(wifi_client);
|
||||||
@@ -71,7 +71,8 @@ void setup() {
|
|||||||
Serial.println("IP address: ");
|
Serial.println("IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
mqtt_client.setServer(mqtt_server, MQTT_PORT);
|
// mqtt_client.setServer(mqtt_server, MQTT_PORT);
|
||||||
|
mqtt_client.setServer(MQTT_SERVER, MQTT_PORT);
|
||||||
reconnectMqtt();
|
reconnectMqtt();
|
||||||
|
|
||||||
configTime(3600, 3600, "192.168.1.2");
|
configTime(3600, 3600, "192.168.1.2");
|
||||||
@@ -144,7 +145,12 @@ void reconnectMqtt() {
|
|||||||
String clientId = "ESP32Rover-";
|
String clientId = "ESP32Rover-";
|
||||||
clientId += String(random(0xffff), HEX);
|
clientId += String(random(0xffff), HEX);
|
||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
|
#ifdef MQTT_AUTH
|
||||||
if (mqtt_client.connect(clientId.c_str(), MQTT_USER, MQTT_PASSWORD)) {
|
if (mqtt_client.connect(clientId.c_str(), MQTT_USER, MQTT_PASSWORD)) {
|
||||||
|
#endif //MQTT_AUTH
|
||||||
|
#ifndef MQTT_AUTH
|
||||||
|
if (mqtt_client.connect(clientId.c_str())) {
|
||||||
|
#endif //MQTT_AUTH
|
||||||
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");
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ MoveControl::MoveControl() {
|
|||||||
PID_LEFT_P, PID_LEFT_I, PID_LEFT_D,
|
PID_LEFT_P, PID_LEFT_I, PID_LEFT_D,
|
||||||
DIRECT);
|
DIRECT);
|
||||||
this->right_pid = new PID( &this->wheelspeed_right,
|
this->right_pid = new PID( &this->wheelspeed_right,
|
||||||
&this->left_pid_out,
|
&this->right_pid_out,
|
||||||
&this->wheelspeed_right_target,
|
&this->wheelspeed_right_target,
|
||||||
PID_RIGHT_P, PID_RIGHT_I, PID_RIGHT_D,
|
PID_RIGHT_P, PID_RIGHT_I, PID_RIGHT_D,
|
||||||
DIRECT);
|
DIRECT);
|
||||||
|
|||||||
Reference in New Issue
Block a user