From 5b787bc4009d015b96cfa0525a4080f0c3e95a61 Mon Sep 17 00:00:00 2001 From: d3rped Date: Sun, 18 Mar 2018 14:23:17 +0100 Subject: [PATCH] added more templates and defined basic include/layout --- src/communication.py | 4 +--- src/main.py | 7 +++++-- src/move.py | 15 +++++++++++++++ src/odometry.py | 11 ++++++++++- src/sensor.py | 0 src/wheel.py | 17 +++++++++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 src/move.py create mode 100644 src/sensor.py create mode 100644 src/wheel.py diff --git a/src/communication.py b/src/communication.py index d643dfa..2b248d3 100644 --- a/src/communication.py +++ b/src/communication.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 - # Suggestion: Do not import the ev3dev.ev3 module in this file - class Communication: """ Class to hold the MQTT client @@ -10,7 +8,7 @@ class Communication: Feel free to add functions, change the constructor and the example send_message() to satisfy your requirements and thereby solve the task according to the specifications """ - def __init__(self, mqtt_client): + def __init__(self, mqtt_client, planet): """ Initializes communication module, connect to server, subscribe, etc. """ # THESE TWO VARIABLES MUST NOT BE CHANGED self.client = mqtt_client diff --git a/src/main.py b/src/main.py index a1edf3a..87f839c 100644 --- a/src/main.py +++ b/src/main.py @@ -5,14 +5,17 @@ import uuid import paho.mqtt.client as mqtt from planet import Direction, Planet from communication import Communication +from move import Move -client = None # DO NOT EDIT +# DO NOT EDIT +client = None def run(): # DO NOT EDIT global client - client = mqtt.Client(client_id=str(uuid.uuid4()), # client_id has to be unique among ALL users + # client_id has to be unique among ALL users + client = mqtt.Client(client_id=str(uuid.uuid4()), clean_session=False, protocol=mqtt.MQTTv31) diff --git a/src/move.py b/src/move.py new file mode 100644 index 0000000..6c58b14 --- /dev/null +++ b/src/move.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +from wheel import Wheel +from sensor import Sensor + + +class Move: + def __init__(self, planet): + pass + + def _calibrate(self): + pass + + def _aligntoedge(self): + pass diff --git a/src/odometry.py b/src/odometry.py index 03bdd29..506a0ce 100644 --- a/src/odometry.py +++ b/src/odometry.py @@ -1,2 +1,11 @@ +#!/usr/bin/env python3 # Suggestion: implement odometry as class that is not using the ev3dev.ev3 package -# establish value exchange with main driving class via getters and setters \ No newline at end of file +# establish value exchange with main driving class via getters and setters + +import time +from planet import Direction + + +class Odometry: + def __init__(self, planet): + pass diff --git a/src/sensor.py b/src/sensor.py new file mode 100644 index 0000000..e69de29 diff --git a/src/wheel.py b/src/wheel.py new file mode 100644 index 0000000..c73936f --- /dev/null +++ b/src/wheel.py @@ -0,0 +1,17 @@ +import ev3dev.ev3 as ev3 + + +class Wheel: + def __init__(self, port): + self._motor = ev3.LargeMotor(port) + self._motor.stop_action = 'brake' + self._speed = 50 + + def run(self): + pass + + def stop(self): + pass + + def speed_set(self): + pass