|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
|
|
|
|
|
|
logging.info(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
|
|
|
|
|
|
logging.error(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at starting position", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at starting position", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
|
|
|
|
|
|
logging.info(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
|
|
|
|
|
|
logging.error(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plantID}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plantID}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
|
|
|
|
|
|
logging.info(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
|
|
|
|
|
|
logging.error(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at starting position", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at starting position", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
|
|
|
|
|
|
logging.info(f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}") |
|
|
|
|
|
|
|
|
logging.error(f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
errorMessage = "Motor or Sensor unplugged" |
|
|
|
|
|
|
|
|
logging.info(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
|
|
|
|
|
|
logging.error(f"{errorMessage}, Drive Plant aborted, Robot at starting position") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], f"{errorMessage}, Drive Plant aborted, Robot at plant {plant}", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
client.publish(Topics["ROBOT_DATA_ROBOTREADY"], "True", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
batteryLevel = int(os.popen('sshpass -p maker ssh robot@ev3dev.local cat /sys/devices/platform/battery/power_supply/lego-ev3-battery/voltage_now').read()) |
|
|
batteryLevel = int(os.popen('sshpass -p maker ssh robot@ev3dev.local cat /sys/devices/platform/battery/power_supply/lego-ev3-battery/voltage_now').read()) |
|
|
except: |
|
|
except: |
|
|
logging.error("EV3 not connected") |
|
|
logging.error("EV3 not connected") |
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], "Robot not connected", qos=1) |
|
|
|
|
|
|
|
|
client.publish(Topics["ROBOT_DATA_ERROR"], "EV3 not connected", qos=1) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
batteryLevel = round(batteryLevel / 1000000, 2) # Conversion to Volt |
|
|
batteryLevel = round(batteryLevel / 1000000, 2) # Conversion to Volt |