Пример #1
0
    def feedDatabaseWithCSVData(self):

        # Feed in all the data from the room plan
        existing_rooms = []
        for row in self.csv_room_plan_:
            # Check if the room is already documented and create a new RoomItem otherwise
            room_id = int(row[3])
            room = self.database_.getRoom(room_id)
            if (room == None):
                # Actually, an error should be risen, but for now...
                print "ROOM WITH ID " + str(room_id) + " DOES NOT EXIST!"
                room = database_classes.RoomItem()
                self.database_.rooms_.append(room)
            # Update the data of the concerning RoomItem
            room.room_position_id_ = row[0]
            room.room_floor_id_ = row[1]
            room.room_building_id_ = row[2]
            room.room_id_ = room_id
            room.room_name_ = row[4]
            room.room_surface_type_ = int(row[6])
            room.room_cleaning_type_ = int(row[7])
            room.room_surface_area_ = float(row[8])
            room.room_trashcan_count_ = int(row[9])
            existing_rooms.append(room.room_id_)

        # Save the database
        self.database_.saveRoomDatabase(temporal=False)

        # Feed in all the data from the territory plan
        for row in self.csv_territory_plan_:
            room_id = int(row[3])
            room = self.database_.getRoom(room_id)
            if (room == None):
                # Actually, an error should be risen, but for now...
                print "ROOM WITH ID " + str(room_id) + " DOES NOT EXIST!"
                room = database_classes.RoomItem()
                self.database_.rooms_.append(room)
            # Update the data of the concerning RoomItem
            scheduled_days = []
            for day in range(14):
                scheduled_days.append(row[11 + day])
            room.room_scheduled_days_ = scheduled_days

        # Save the database
        self.database_.saveRoomDatabase(temporal=False)

        # Remove all rooms which were not listed in the room plan
        for room in self.database_.rooms_:
            if (not (room.room_id_ in existing_rooms)):
                self.database_.rooms_.remove(room)
            # Save the database
            self.database_.saveRoomDatabase(temporal=False)

        # Save the database
        self.database_.saveRoomDatabase(temporal=False)
Пример #2
0
	def createRoomEntries(self):
		for i in range(len(self.segmentation_result_.room_information_in_pixel)):
			print "Creating room " + str(i)
			cv_image = self.getMapSegmentAsImage(self.cvBridge2OpenCv(self.segmentation_result_.segmented_map), i)
			img_file_name = "map_" + str(i) + ".png"
			cv2.imwrite("resources/maps/" + str(img_file_name), cv_image)
			room = database_classes.RoomItem()
			room.room_name_ = "room_" + str(i)
			room.room_id_ = i
			room.room_position_id_ = "1_" + str(i)
			room.room_floor_id_ = "1st Floor"
			room.room_building_id_ = "Building C"
			room.room_territory_id_ = "42"
			room.room_surface_type = 2
			room.room_cleaning_method_ = 2
			room.room_surface_area_ = 3.141
			room.room_trashcan_count_ = 4
			room.room_cleaning_datestamps_ = [None, None, None]
			room.room_issues = []
			room.room_map_ = img_file_name
			room.room_map_data = self.openCv2CvBridge(cv_image)
			room.room_map_filename_ = img_file_name
			room.room_information_in_pixel_ = self.segmentation_result_.room_information_in_pixel[i]
			room.room_information_in_meter_ = self.segmentation_result_.room_information_in_meter[i]
			room.room_scheduled_days_ = ["","","","","","","","","","","","","",""]
			room.open_cleaning_tasks_ = []
			self.database_.rooms_.append(room)
Пример #3
0
	def updateRoomsList(self, dict):
		self.rooms_ = []
		for room_key in dict:
			room_issues = []
			current_room = database_classes.RoomItem()
			# Get all issues of a room and get all properties of those issues
			issues_dict = dict.get(room_key).get("room_issues")
			for issue_key in issues_dict:
				current_issue = database_classes.RoomIssue()
				# Get the room issue ID
				current_issue.issue_id_ = issues_dict.get(issue_key).get("issue_id")
				# Get the room issue type
				current_issue.issue_type_ = issues_dict.get(issue_key).get("issue_type")
				# Get the room issue images
				current_issue.issue_images_ = issues_dict.get(issue_key).get("issue_images")
				# Get the room issue coordinates
				issue_coords_list = issues_dict.get(issue_key).get("issue_coords")
				current_issue.issue_coords_ = Point32(x=issue_coords_list[0], y=issue_coords_list[1], z=issue_coords_list[2])
				# Get the date the issue was detected
				current_issue.issue_date_ = self.stringToDatetime(issues_dict.get(issue_key).get("issue_date"))
				# Append current room issue to the room_issues list
				room_issues.append(current_issue)
			current_room.room_issues_ = room_issues
			# Get the name of the room
			current_room.room_name_ = dict.get(room_key).get("room_name")
			# Get the ID of the room
			current_room.room_id_ = dict.get(room_key).get("room_id")
			# Get the position ID of the room
			current_room.room_position_id_ = dict.get(room_key).get("room_position_id")
			# Get the floor of the room
			current_room.room_floor_id_ = dict.get(room_key).get("room_floor_id")
			# Get the building ID of the room
			current_room.room_building_id_ = dict.get(room_key).get("room_building_id")
			# Get the territory the room is in
			current_room.room_territory_id_ = dict.get(room_key).get("room_territory_id")
			# Get the map of the room
			current_room.room_map_filename_ = dict.get(room_key).get("room_map_filename")
			# Get an open cv representation of the map or None if there is no map
			if (current_room.room_map_filename_ != None):
				room_map_file_path = str(self.extracted_file_path) + str("resources/maps/") + str(current_room.room_map_filename_)
				map_opencv = cv2.imread(room_map_file_path, 0)
				bridge = CvBridge()
				current_room.room_map_data_ = bridge.cv2_to_imgmsg(map_opencv, encoding = "mono8")
			else:
				current_room.room_map_data = None
			# Get the room information
			pixel_coords = dict.get(room_key).get("room_information_in_pixel")
			current_room.room_information_in_pixel_ = RoomInformation()
			current_room.room_information_in_pixel_.room_center = Point32(x=pixel_coords[0][0], y=pixel_coords[0][1], z=pixel_coords[0][2])
			current_room.room_information_in_pixel_.room_min_max.points.append(Point32(x=pixel_coords[1][0], y=pixel_coords[1][1], z=pixel_coords[1][2]))
			current_room.room_information_in_pixel_.room_min_max.points.append(Point32(x=pixel_coords[2][0], y=pixel_coords[2][1], z=pixel_coords[2][2]))
			meter_coords = dict.get(room_key).get("room_information_in_meter")
			current_room.room_information_in_meter_ = RoomInformation()
			current_room.room_information_in_meter_.room_center = Point32(x=meter_coords[0][0], y=meter_coords[0][1], z=meter_coords[0][2])
			current_room.room_information_in_meter_.room_min_max.points.append(Point32(x=meter_coords[1][0], y=meter_coords[1][1], z=meter_coords[1][2]))
			current_room.room_information_in_meter_.room_min_max.points.append(Point32(x=meter_coords[2][0], y=meter_coords[2][1], z=meter_coords[2][2]))
			# Get the room surface type
			current_room.room_surface_type_ = dict.get(room_key).get("room_surface_type")
			# Get the cleaning method of the room
			current_room.room_cleaning_method_ = dict.get(room_key).get("room_cleaning_method")
			# Get the room surface area
			current_room.room_surface_area_ = dict.get(room_key).get("room_surface_area")
			# Get the room trashcan count
			current_room.room_trashcan_count_ = dict.get(room_key).get("room_trashcan_count")
			# Get the days where the room has to be cleaned in a specified way
			current_room.room_scheduled_days_ = dict.get(room_key).get("room_scheduled_days")
			# Get the yet open cleaning tasks
			current_room.open_cleaning_tasks_ = dict.get(room_key).get("open_cleaning_tasks")
			
			# Get the list with the datestamps
			string_datestamp_list = dict.get(room_key).get("room_cleaning_datestamps")
			datestamps = []
			for datestamp in string_datestamp_list:
				if (datestamp != None):
					datestamps.append(self.stringToDatetime(datestamp))
				else:
					datestamps.append(None)
			current_room.room_cleaning_datestamps_ = datestamps
			
			# Append current room object to the rooms_ list
			self.rooms_.append(current_room)