You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem to get the data of the actual positions of the 3D-printer. I have connected my computer to the Raspberry Pi with an Ethernet-cable. This is my Python Code to read out the position (the g-code position).
import requests
import time
moonraker_ip = "192.168.1.2"
api_endpoint = f"http://{moonraker_ip}/printer/objects/query?gcode_move&toolhead&extruder=target,temperature"
session = requests.Session()
try:
while True:
# HTTP-Anfrage senden
response = session.get(api_endpoint)
# Überprüfen, ob die Anfrage erfolgreich war (Statuscode 200)
if response.status_code == 200:
# Antwort als JSON-Daten erhalten
data = response.json()
# Positionsdaten des Extruders aus den erhaltenen Daten extrahieren
extruder_position = data['result']['status']['toolhead']['position']
# X-, Y- und Z-Position des Extruders extrahieren
x = extruder_position[0]
y = extruder_position[1]
z = extruder_position[2]
# Zeitstempel erzeugen
zeitstempel = data['result']['eventtime']
# Ausgabe erstellen
output = f"{zeitstempel} - Extruderposition (mm): X: {x}, Y: {y}, Z: {z}"
print(output)
else:
# Anfrage war nicht erfolgreich
print(f"Fehler bei der Anfrage. Statuscode: {response.status_code}")
time.sleep(1)
except requests.exceptions.RequestException as e:
# Fehler bei der Verbindung oder Anfrage
print(f"Fehler bei der Verbindung: {e}")
I would like to read out the actual position of the printer like when using mainsail for example. If i move the extruder head in z direction from 100 mm to 200 mm the output of my Python Program is in like that:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello all,
I have a problem to get the data of the actual positions of the 3D-printer. I have connected my computer to the Raspberry Pi with an Ethernet-cable. This is my Python Code to read out the position (the g-code position).
I would like to read out the actual position of the printer like when using mainsail for example. If i move the extruder head in z direction from 100 mm to 200 mm the output of my Python Program is in like that:
135.096046468 - Extruderposition (mm): X: 491.0, Y: 1079.0, Z: 100.0
135.848502978 - Extruderposition (mm): X: 491.0, Y: 1079.0, Z: 200.0
That means I am using the wrong variable the read out the position, because it just shows me the "gcode"-position.
Did someone had a similar problem and have solved that problem?
Beta Was this translation helpful? Give feedback.
All reactions