ev3 First Testfiles
This commit is contained in:
parent
60be6862b0
commit
3d0bc3c4d9
@ -1,11 +1,11 @@
|
|||||||
Adafruit-Blinka==8.16.1
|
# Adafruit-Blinka==8.16.1 # Raspy only, not possible on other devices -> commented out
|
||||||
adafruit-circuitpython-busdevice==5.2.4
|
# adafruit-circuitpython-busdevice==5.2.4
|
||||||
adafruit-circuitpython-dht==3.7.8
|
# adafruit-circuitpython-dht==3.7.8
|
||||||
adafruit-circuitpython-requests==1.13.1
|
# adafruit-circuitpython-requests==1.13.1
|
||||||
adafruit-circuitpython-tsl2561==3.3.15
|
# adafruit-circuitpython-tsl2561==3.3.15
|
||||||
adafruit-circuitpython-typing==1.9.0
|
# adafruit-circuitpython-typing==1.9.0
|
||||||
Adafruit-PlatformDetect==3.43.0
|
# Adafruit-PlatformDetect==3.43.0
|
||||||
Adafruit-PureIO==1.1.10
|
# Adafruit-PureIO==1.1.10
|
||||||
certifi==2022.12.7
|
certifi==2022.12.7
|
||||||
charset-normalizer==3.0.1
|
charset-normalizer==3.0.1
|
||||||
click==8.1.3
|
click==8.1.3
|
||||||
@ -16,15 +16,16 @@ itsdangerous==2.1.2
|
|||||||
Jinja2==3.1.2
|
Jinja2==3.1.2
|
||||||
MarkupSafe==2.1.2
|
MarkupSafe==2.1.2
|
||||||
paho-mqtt==1.6.1
|
paho-mqtt==1.6.1
|
||||||
pkg_resources==0.0.0
|
# pkg_resources==0.0.0
|
||||||
pyftdi==0.54.0
|
# pyftdi==0.54.0
|
||||||
pyserial==3.5
|
# pyserial==3.5
|
||||||
pyusb==1.2.1
|
# pyusb==1.2.1
|
||||||
requests==2.28.2
|
requests==2.28.2
|
||||||
rpi-ws281x==4.3.4
|
# rpi-ws281x==4.3.4
|
||||||
RPi.GPIO==0.7.1
|
# RPi.GPIO==0.7.1
|
||||||
sysv-ipc==1.1.0
|
# sysv-ipc==1.1.0
|
||||||
typing_extensions==4.5.0
|
typing_extensions==4.5.0
|
||||||
urllib3==1.26.14
|
urllib3==1.26.14
|
||||||
Werkzeug==2.2.3
|
Werkzeug==2.2.3
|
||||||
zipp==3.15.0
|
zipp==3.15.0
|
||||||
|
python-ev3dev2==2.1.0.post1
|
||||||
|
21
software/roboter/ev3/sensortest.py
Normal file
21
software/roboter/ev3/sensortest.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from ev3dev2.motor import LargeMotor, OUTPUT_A, SpeedPercent
|
||||||
|
from ev3dev2.sensor.lego import TouchSensor, UltrasonicSensor
|
||||||
|
from ev3dev2.sensor import INPUT_1, INPUT_4
|
||||||
|
|
||||||
|
m = LargeMotor(OUTPUT_A)
|
||||||
|
touch = TouchSensor(INPUT_1)
|
||||||
|
ultraSonic = UltrasonicSensor(INPUT_4)
|
||||||
|
ultraSonic.MODE_US_DIST_CM
|
||||||
|
|
||||||
|
m.on(SpeedPercent(50))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if ultraSonic.distance_centimeters < 10:
|
||||||
|
m.on(SpeedPercent(25))
|
||||||
|
break
|
||||||
|
|
||||||
|
touch.wait_for_pressed(timeout_ms=None, sleep_ms=10)
|
||||||
|
m.off()
|
||||||
|
|
||||||
|
|
@ -6,6 +6,15 @@ from raspySensors import RaspySensors
|
|||||||
sensors = RaspySensors()
|
sensors = RaspySensors()
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region
|
||||||
|
|
||||||
|
def measureSendData():
|
||||||
|
'''Measure Data via sensor class and send via MQTT'''
|
||||||
|
sensorData = sensors.readSensors()
|
||||||
|
client.publish("Robot/Data", json.dumps(sensorData, indent=4))
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region MQTT callbacks
|
#region MQTT callbacks
|
||||||
@ -14,8 +23,15 @@ def send_data_json(client, userdata, message):
|
|||||||
dataDict = json.loads(strIn)
|
dataDict = json.loads(strIn)
|
||||||
print("Received data: ", json.dumps(dataDict))
|
print("Received data: ", json.dumps(dataDict))
|
||||||
|
|
||||||
|
#Function for all Plants or one which changes according to request
|
||||||
def drive_plant_1(clients, userdata, message):
|
def drive_plant_1(clients, userdata, message):
|
||||||
|
#TODO Start drive forward
|
||||||
print("Driving to plant 1")
|
print("Driving to plant 1")
|
||||||
|
measureSendData()
|
||||||
|
#TODO Start Drive Back Function
|
||||||
|
print("Driving back to start position")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user