Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
rombie18 committed May 3, 2023
1 parent 2af68d1 commit 60e5101
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Software/threads/customthreads.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ def __controller_add(self, joy):
'time': datetime.now(),
'type': "add"
}
logging.debug("Controller added: " + str(joy))
self.pipe.append(data)

def __controller_remove(self, joy):
data = {
'time': datetime.now(),
'type': "remove",
}
logging.debug("Controller removed: " + str(joy))
self.pipe.append(data)

def __controller_process(self, key):
Expand All @@ -189,6 +191,7 @@ def __controller_process(self, key):
'type': "event",
'key': key
}
logging.debug("Controller event: " + str(key))
self.pipe.append(data)

def __controller_alive(self):
Expand Down Expand Up @@ -248,11 +251,17 @@ def run(self):
# continue

# Plot the region of interest on the image
lane_obj.plot_roi(plot=False)
lane_obj.plot_roi(plot=True)

# Perform the perspective transform to generate a bird's eye view
# If Plot == True, show image with new region of interest
warped_frame = lane_obj.perspective_transform(plot=False)
warped_frame = lane_obj.perspective_transform(plot=True)

# If detected to little pixels, skip futher calculations
detected_pixels = numpy.sum(warped_frame == 255)
if detected_pixels < 3000:
logging.debug("Only {} valid pixels, skipping this frame".format(detected_pixels))
continue

# Generate the image histogram to serve as a starting point
# for finding lane line pixels
Expand All @@ -269,17 +278,19 @@ def run(self):
frame_with_lane_lines = lane_obj.overlay_lane_lines(plot=False)

# Calculate lane line curvature (left and right lane lines)
lane_obj.calculate_curvature(print_to_terminal=True)
lane_obj.calculate_curvature(print_to_terminal=False)

# Calculate center offset
lane_obj.calculate_car_position(print_to_terminal=True)
lane_obj.calculate_car_position(print_to_terminal=False)

# Calculate turning angle
wheel_base = 0.3
curvem = (lane_obj.left_curvem + lane_obj.right_curvem) / 2
angle = math.degrees(math.atan(wheel_base / curvem))
angle = math.degrees(math.atan(wheel_base / curvem)) * 6 + 90

print(angle)
logging.debug("Curve radius left: " + str(angle))
logging.debug("Curve radius right: " + str(angle))
logging.debug("Steering angle: " + str(angle))

# Append result to pipe
self.pipe.append({
Expand Down

0 comments on commit 60e5101

Please sign in to comment.