diff --git a/Control/Jetson/vision_cargo_approach.py b/Control/Jetson/vision_cargo_approach.py index 0c76d9a..6007b44 100644 --- a/Control/Jetson/vision_cargo_approach.py +++ b/Control/Jetson/vision_cargo_approach.py @@ -148,7 +148,7 @@ class VisionCargoApproacher: self.centre_distance_thresh = (-0.2, 0.2) # horizontal tolerance for pallet alignment pre fork alignment self.centre_angle_thresh = (-0.2, 0.2) # angular tolerance for pallet alignment pre fork alignment self.horizontal_camera_offset = 0 # In case the camera isn't perfectly straight, we can compansate for that in code - self.steering_log_file = open("slf.file", 'w+') + self.steering_log_file = 'slf.file" def navigate_to_cargo_vision(self): self.log.info("Starting vision system") @@ -169,7 +169,9 @@ class VisionCargoApproacher: delta_PWM = remap(delta, 0.7, -0.7, 1900, 1100) # Converting steering law output into PWM values little_log = f"Error y: {delta} | error theta {error_x} | steering_raw {error_theta} | steering_conv: {delta_PWM}, tag_area: {area}" self.log.info(little_log) - self.steering_log_file.writelines([little_log]) + + with open(self.steering_log_file, 'a+') as myfile: + myfile.writelines([little_log]) if area < self.max_approach_area_thresh: # If we are far enough from the cargo, move towards it speed_pwm = remap(area, 40000, 1000, 1500, 2000)