Bug fixes, drive_all started
This commit is contained in:
parent
b70d445480
commit
a0c7bc9077
@ -12,6 +12,7 @@ BACKEND_CLIENT_ID = "smart_farming_server"
|
|||||||
# Topics:
|
# Topics:
|
||||||
Topics = {
|
Topics = {
|
||||||
"ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE",
|
"ROBOT_ACTION_DRIVE": "ROBOT/ACTION/DRIVE",
|
||||||
|
"ROBOT_ACTION_DRIVEALL": "ROBOT/ACTION/DRIVEALL",
|
||||||
"ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION",
|
"ROBOT_ACTION_GETPOSITION": "ROBOT/ACTION/GETPOSITION",
|
||||||
"ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY",
|
"ROBOT_ACTION_GETBATTERY": "ROBOT/ACTION/GETBATTERY",
|
||||||
|
|
||||||
|
@ -68,10 +68,19 @@ def drive_plant_thread(plantID, actionID, client: mqtt.Client):
|
|||||||
return
|
return
|
||||||
|
|
||||||
logging.info("Robot home")
|
logging.info("Robot home")
|
||||||
|
|
||||||
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1)
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO thread all plants
|
||||||
|
def drive_plant_all(plantID, actionID, client: mqtt.Client):
|
||||||
|
|
||||||
|
# TODO loop through plantID array
|
||||||
|
|
||||||
|
logging.info("Robot home")
|
||||||
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region MQTT callbacks
|
#region MQTT callbacks
|
||||||
|
|
||||||
def drive_plant(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
def drive_plant(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
||||||
@ -96,6 +105,21 @@ def drive_plant(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
|||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
|
# TODO Drive all Plants
|
||||||
|
# TODO plantID array
|
||||||
|
# TODO only possible with color codes
|
||||||
|
def drive_plant_all(client: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
||||||
|
dictMessage = json.loads(str(message.payload.decode("UTF-8")))
|
||||||
|
|
||||||
|
plantID = dictMessage["PlantID"]
|
||||||
|
actionID = dictMessage["ActionID"]
|
||||||
|
|
||||||
|
logging.info(f"Received Drive-request to plants {plantID}, ActionID: {actionID}")
|
||||||
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "False", qos=1)
|
||||||
|
|
||||||
|
thread = threading.Thread(target= drive_plant_all, args=(plantID, actionID, client), daemon=True)
|
||||||
|
thread.start()
|
||||||
|
|
||||||
def get_position(clients: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
def get_position(clients: mqtt.Client, userdata, message: mqtt.MQTTMessage):
|
||||||
"""
|
"""
|
||||||
Callback function for GPS position request
|
Callback function for GPS position request
|
||||||
|
BIN
software/roboter/raspy/picture.png
Normal file
BIN
software/roboter/raspy/picture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 MiB |
@ -81,9 +81,9 @@ def readMCP3008():
|
|||||||
val = spi.xfer2([1,(8+channel) << 4, 0])
|
val = spi.xfer2([1,(8+channel) << 4, 0])
|
||||||
data = ((val[1] & 3) << 9) +val[2]
|
data = ((val[1] & 3) << 9) +val[2]
|
||||||
percentage = data - 680 # Return values between ~1780 and ~680
|
percentage = data - 680 # Return values between ~1780 and ~680
|
||||||
percentage = round((1100 - percentage) / 1100, 2) # 680 -> 100% moisture, 1780 -> 0% moisture
|
percentage = round(((1100 - percentage) / 1100) *100, 2) # 680 -> 100% moisture, 1780 -> 0% moisture
|
||||||
|
|
||||||
if percentage > 1 or percentage < 0: # If not connected values above 100% appear
|
if percentage > 100 or percentage < 0: # If not connected values above 100% appear
|
||||||
percentage = 0
|
percentage = 0
|
||||||
raise Exception("YL69 not connected")
|
raise Exception("YL69 not connected")
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ def readPosition():
|
|||||||
def main():
|
def main():
|
||||||
value = SENSORDATA
|
value = SENSORDATA
|
||||||
try:
|
try:
|
||||||
readSensors()
|
readMCP3008()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user