예제 #1
0
    def __init__(self, move_robot, camera_interface: CameraInterface,
                 segmentation_weight_path):
        self.move_robot = move_robot
        self.camera = camera_interface
        self.vision = Vision(segmentation_weight_path)
        self.box_detector = BoxDetector()
        self.surface_normals = SurfaceNormals()
        self.detected_objects = None
        self.masks = None
        self.unsuccessful_grip_counter = 0
        self.unsuccessful_grip_shake_counter = 0
        self.area_threshold = 2000000
        self.score_threshold = 0.6
        self.reference_image = None
        self.depth_image = None
        self.part_position_details = None
        self.first_box_move = 0
        self.picked_parts = {
            PartCategoryEnum.BOTTOM_COVER.value: 0,
            PartCategoryEnum.PCB.value: 0,
            PartCategoryEnum.BLACK_COVER.value: 0,
            PartCategoryEnum.BLUE_COVER.value: 0,
            PartCategoryEnum.WHITE_COVER.value: 0
        }

        print("[I] Controller running")
예제 #2
0
파일: simulator.py 프로젝트: sdp-2011/sdp-9
 def initVision(self):
     if self.vision:
         logging.info("Starting simulator vision bridge")
         world = self.world
         if not self.real_world:
             # Vision must always use the real World
             world = common.world.World(self.colour)
         self.vision = Vision(simulator=self, world=world)
         self.visionFile = tempfile.mktemp(suffix='.bmp')
예제 #3
0
    def __init__(self, pitch, color, our_side, video_port=0, comm_port='/dev/ttyUSB0', comms=1):
        """
        Entry point for the SDP system.

        Params:
            [int] video_port                port number for the camera
            [string] comm_port              port number for the arduino
            [int] pitch                     0 - main pitch, 1 - secondary pitch
            [string] our_side               the side we're on - 'left' or 'right'
            *[int] port                     The camera port to take the feed from
            *[Robot_Controller] attacker    Robot controller object - Attacker Robot has a RED
                                            power wire
            *[Robot_Controller] defender    Robot controller object - Defender Robot has a YELLOW
                                            power wire
        """
        assert pitch in [0, 1]
        assert color in ['yellow', 'blue']
        assert our_side in ['left', 'right']

        self.pitch = pitch

        # Set up the Arduino communications
        self.arduino = Arduino(comm_port, 115200, 1, comms)

        # Set up camera for frames
        self.camera = Camera(port=video_port, pitch=self.pitch)
        frame = self.camera.get_frame()
        center_point = self.camera.get_adjusted_center(frame)

        # Set up vision
        self.calibration = tools.get_colors(pitch)
        self.vision = Vision(
            pitch=pitch, color=color, our_side=our_side,
            frame_shape=frame.shape, frame_center=center_point,
            calibration=self.calibration)

        # Set up postprocessing for vision
        self.postprocessing = Postprocessing()

        # Set up main planner
        self.planner = Planner(our_side=our_side, pitch_num=self.pitch)

        # Set up GUI
        self.GUI = GUI(calibration=self.calibration, arduino=self.arduino, pitch=self.pitch)

        self.color = color
        self.side = our_side

        self.preprocessing = Preprocessing()

        self.attacker = Attacker_Controller()
        self.defender = Defender_Controller()
예제 #4
0
corner_right = ObjectDimension(
    Object.CANVAS_WIDTH - margin_delta - corner_radius * 2, margin_delta,
    corner_radius * 2, corner_radius * 2)

simulation = Simulation(motor_left, motor_right, corner_left, corner_right)
app = Window(root, simulation)

camera = SimulationCamera(app)

image_to_draw = prepare_image("vision/test_bild.jpg")

if image_to_draw is None:
    print("Image can not be null to continue.")
    exit(-1)

motor_interface = SimulationMotorInterface(simulation, 0.001, 5)

vision = Vision(motor_interface, 1.5, camera, image_to_draw,
                ((motor_right.center.x - motor_left.center.x) / 2, 25),
                corner_right.center.x - corner_left.center.x)
vision.run_in_thread()


def on_destroy_callback():
    vision.quit()


app.set_on_destroy_callback(on_destroy_callback)

root.after(16, app.frame)
root.mainloop()