예제 #1
0
    def from_dict(request_dict):

        id = request_dict.get('id', generate_uuid())
        request = TaskRequest(id=id)

        request.load_type = request_dict["loadType"]
        request.load_id = request_dict["loadId"]
        request.user_id = request_dict["userId"]
        request.earliest_pickup_time = TimeStamp.from_str(
            request_dict["earliestPickupTime"])
        request.latest_pickup_time = TimeStamp.from_str(
            request_dict["latestPickupTime"])

        pickup_area_dict = request_dict.get('pickup_pose', None)
        if pickup_area_dict:
            request.pickup_pose = Area.from_dict(pickup_area_dict)
        else:  # when the provided dict is from json schema
            request.pickup_pose = Area()
            request.pickup_pose.name = request_dict.get("pickupLocation", '')
            request.pickup_pose.floor_number = request_dict.get(
                "pickupLocationLevel", 0)

        delivery_area_dict = request_dict.get('delivery_pose', None)
        if delivery_area_dict:
            request.delivery_pose = Area.from_dict(delivery_area_dict)
        else:  # when the provided dict is from json schema
            request.delivery_pose = Area()
            request.delivery_pose.name = request_dict.get(
                "deliveryLocation", '')
            request.delivery_pose.floor_number = request_dict.get(
                "deliveryLocationLevel", 0)

        request.priority = request_dict["priority"]

        return request
예제 #2
0
 def from_dict(sub_area_reservation_dict):
     sub_area_reservation = SubAreaReservation()
     sub_area_reservation.sub_area_id = sub_area_reservation_dict[
         'subAreaId']
     sub_area_reservation.task_id = sub_area_reservation_dict['taskId']
     sub_area_reservation.robot_id = sub_area_reservation_dict['robotId']
     sub_area_reservation.start_time = TimeStamp.from_str(
         sub_area_reservation_dict['startTime'])
     sub_area_reservation.end_time = TimeStamp.from_str(
         sub_area_reservation_dict['endTime'])
     sub_area_reservation.status = sub_area_reservation_dict['status']
     sub_area_reservation.required_capacity = sub_area_reservation_dict[
         'requiredCapacity']
     return sub_area_reservation
예제 #3
0
    def from_dict(task_dict):
        task = Task()
        task.id = task_dict['id']
        task.loadType = task_dict['loadType']
        task.loadId = task_dict['loadId']
        task.team_robot_ids = task_dict['team_robot_ids']
        task.earliest_start_time = TimeStamp.from_str(
            task_dict['earliest_start_time'])
        task.latest_start_time = TimeStamp.from_str(
            task_dict['latest_start_time'])
        task.estimated_duration = datetime.timedelta(
            minutes=task_dict['estimated_duration'])
        task.earliest_finish_time = TimeStamp.from_str(
            task_dict['earliest_finish_time'])
        task.latest_finish_time = TimeStamp.from_str(
            task_dict['latest_finish_time'])

        start_time = task_dict.get('start_time', None)
        if start_time:
            task.start_time = TimeStamp.from_str(start_time)
        else:
            task.start_time = start_time

        finish_time = task_dict.get('finish_time', None)
        if finish_time:
            task.finish_time = TimeStamp.from_str(finish_time)
        else:
            task.finish_time = finish_time

        task.pickup_pose = Area.from_dict(task_dict['pickup_pose'])
        task.delivery_pose = Area.from_dict(task_dict['delivery_pose'])
        task.priority = task_dict['priority']
        task.status = TaskStatus.from_dict(task_dict['status'])
        task.hard_constraints = task_dict['hard_constraints']
        for robot_id, actions in task_dict['robot_actions'].items():
            task.robot_actions[robot_id] = list()
            for action_dict in actions:
                action = Action.from_dict(action_dict)
                task.robot_actions[robot_id].append(action)
        return task