Skip to content

Commit

Permalink
changed: minor changes for better code; added: TODOs in python code;
Browse files Browse the repository at this point in the history
  • Loading branch information
suly520 committed Jun 27, 2023
1 parent bc0a3e4 commit 1b3c442
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
5 changes: 3 additions & 2 deletions Tools/Dynamikcy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from math import tan, atan


cpdef tuple vNeu(WegX, WegY, WegZ, vmax):
#TODO:FIX add real velocity capabilities
#TODO:BEAUTY clean code
vX = 0
vY = 0
vZ = 0
Expand Down Expand Up @@ -88,8 +90,7 @@ cpdef tuple vNeu(WegX, WegY, WegZ, vmax):
return round(vX,6), round(vY,6), round(vZ,6), MotorX, MotorY, MotorZ

cpdef double motor(double ist, double v, int soll, int ziel, bint ZyklStop, int Dir):


#TODO:BEAUTY clean code
if not ZyklStop:
if Dir == 0 and not ZyklStop:
ist = ist + v
Expand Down
10 changes: 5 additions & 5 deletions Tools/Steuerungsklasse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ from threading import RLock
lck = threading.Lock()





class PosError(Exception):
"""Wird aufgerufen wenn ein Positionierungsfehler vorliegt"""
pass
Expand All @@ -27,7 +24,9 @@ class StopProcess(Exception):
pass

class MotorSteuerung:

""""""
#TODO:FEATURE add limitswitch capabilities
#TODO:BEAUTY clean code
def __init__(self, list pinList = [17, 5, 16, 27, 6, 20, 22, 13, 21]):
cdef list achsList = [0, 1, 2] # die Zahlen sollen die Achse repräsentieren 0 = X / 1 = Y / 2 = Z
self.pinList = pinList
Expand Down Expand Up @@ -96,6 +95,7 @@ class MotorSteuerung:

@staticmethod
def Checkpos(int achse, int direction, int pulse, int endMax, int endMin):
#TODO:FIX rework endpose handling
cdef int achsPos = MotorSteuerung.GetPosition(achse)

try:
Expand Down Expand Up @@ -149,7 +149,7 @@ class MotorSteuerung:
cdef double j
cdef int slowdownCounter = 0


#TODO:FEATURE implement parameterizable acceleration control
try:
const = 0.0008 #getestet durch geogebra nur bei 0.0007
if vmax < 0.0007:
Expand Down
5 changes: 3 additions & 2 deletions main_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ def write(self, text):

class MainWindow(QtWidgets.QMainWindow):
"""handles the QT Widgets and all UI relatet operations"""

#TODO:BEAUTY splitt class

def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
super().__init__(parent)
self._init_labels()
self.visu_ui = Ui_VisoWidget()
self.docker_widget = QtWidgets.QDockWidget("Dock", self)
Expand Down
39 changes: 21 additions & 18 deletions vis_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class GLWidget(QtOpenGL.QGLWidget):
"""Widget class containing all tools for handling servo motors and exchanging data between
GLWidget and MainWindow
TODO: Make the OOP concept more clear > better structure and better encapsulation
"""
#TODO:BEAUTY splitt class
updateProgress = QtCore.Signal(int)
updateLCD = QtCore.Signal(list)
updateMotorStatus = QtCore.Signal(list)
Expand All @@ -24,7 +24,7 @@ class GLWidget(QtOpenGL.QGLWidget):
updateSpinnerVal = QtCore.Signal()

def __init__(self, parent=None):
super(GLWidget, self).__init__(parent)
super().__init__(parent)
self.motor_steering = MotorSteuerung()

self.middle_button = False
Expand All @@ -35,6 +35,8 @@ def __init__(self, parent=None):

self.direction_vec = [0, 0, 0]
self.freq_vec = [0, 0, 0]

#TODO:FIX use different velocity support
self.v_vec = [0.0007, 0.0007, 0.0007]
self.max_freq_vec = [1000, 1000, 1000]
self.min_freq_vec = [0, 0, 0]
Expand Down Expand Up @@ -256,6 +258,7 @@ def load_texture(path, texture):

def change_unit(self, axis, inp, to_frequency=False):
"""scales the input to the desired min max value"""
#TODO:FIX change the scaling methode for using blender obj file
if not to_frequency:
outp = inp * \
self.max_visu_area_vec[axis] / self.max_freq_vec[axis]
Expand All @@ -265,9 +268,9 @@ def change_unit(self, axis, inp, to_frequency=False):
return outp

def steering(self):
"""forwards/emits the motion signals to/to the motor module
TODO: use overloading or a seperate function to allow visual only for
better readability and avoiding the multiple branches"""
"""forwards/emits the motion signals to/to the motor module"""
#TODO:BEAUTY use overloading or a seperate function to allow visual only for
# better readability and avoiding the multiple branches
if not self.cycle_stop and not self.is_set and \
(self.calibration_active or self.contouring_active):
self.set_auto_pos()
Expand Down Expand Up @@ -323,7 +326,7 @@ def steering(self):
if not self.visu_only_activ:
self.motor_check_x, self.motor_check_y, self.motor_check_z, _ = \
self.motor_check_list = self.motor_steering.GetMotorStatus() + \
(self.cycle_start,)
(self.cycle_start,)
else:
self.visu_check_vec = (
self.visu_check_x, self.visu_check_y, self.visu_check_z)
Expand All @@ -340,8 +343,9 @@ def steering(self):
self.update_stats_on_main_win()

def set_auto_pos(self):
"""is for automated steering while contouring or calibrating
TODO: add a interpolation funktionality"""
"""is for automated steering while contouring or calibrating"""
#TODO:BEAUTY split in sections for different mods
#TODO:FEATURE add a interpolation funktionality
step_vec = [[0, 0, 0], [4, 4, 1.7], [0, 0, 0],
[4, 4, 0], [0, 0, 1.7], [4, 4, 0],
[0, 0, 0], [4, 0, 1.7], [0, 4, 0],
Expand Down Expand Up @@ -403,10 +407,8 @@ def set_auto_pos(self):
self.move_to_z(target_points[2])

def stepper(self, axis, actual, desired, distance, vel):
"""
steps and commands for the steppermotor
# TODO change to only returnig function
"""
"""steps and commands for the steppermotor"""
#TODO:BEAUTY change to only returnig function
if not self.cycle_stop:
if distance > 0 and not self.cycle_stop:
actual += vel
Expand Down Expand Up @@ -469,6 +471,7 @@ def record_progress(self):

def mouseMoveEvent(self, event: QtGui.QMouseEvent):
"""describes the mouse behaviour in the 3D visualisation mainly for rotate or tranlation"""
#TODO:FIX better control over 3d view
mouse_pos_x = 0
mouse_pos_y = 0
old_pos = []
Expand Down Expand Up @@ -541,8 +544,8 @@ def mousePressEvent(self, event: QtGui.QMouseEvent):
self.right_button = False
return super().mousePressEvent(event)

# def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent):
# """should translate the view in a specific range"""
"""def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent):
# "should translate the view in a specific range"
# if event.button() == QtCore.Qt.MouseButton.RightButton:
# if self.double_click_count < 5:
# self.trans_view_z = 1.5
Expand All @@ -557,7 +560,7 @@ def mousePressEvent(self, event: QtGui.QMouseEvent):
# self.view_translation_matrix, self.view_matrix)
# self.double_click_count += 1
# self.resizeGL(self.width(), self.height())
# return super().mouseDoubleClickEvent(event)
# return super().mouseDoubleClickEvent(event)"""

def wheelEvent(self, event: QtGui.QWheelEvent):
"""handles the weel events for zooming the 3D model view"""
Expand Down Expand Up @@ -791,15 +794,15 @@ def clear_pos(self):

@QtCore.Slot(bool)
def select_contour_1(self):
"""selects a file for the contoutring function
TODO: Make the contouring more efficent"""
"""selects a file for the contoutring function"""
#TODO:FIX Make the contouring more efficent
self.contouring_file = "./ObjFiles/HTL.obj"
print("[info]Contouring file: ", self.contouring_file)

@QtCore.Slot(bool)
def select_contour_2(self):
"""selects a file for the contoutring function"""
self.contouring_file = "./ObjFiles/HalloWelt.obj"
self.contouring_file = "./ObjFiles/cube.obj"
print("[info]Contouring file: ", self.contouring_file)

@QtCore.Slot(bool)
Expand Down

0 comments on commit 1b3c442

Please sign in to comment.