Example #1
0
def put_sphere() -> RespT:
    """Add or update collision sphere.
        ---
        put:
            tags:
                - Collisions
            description: Add or update collision sphere.
            parameters:
                - name: sphereId
                  in: query
                  schema:
                    type: string
                - name: radius
                  in: query
                  schema:
                    type: number
                    format: float
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Pose
            responses:
                200:
                  description: Ok
    """

    args = convert_keys(request.args.to_dict(), camel_case_to_snake_case)
    sphere = object_type.Sphere(args["sphere_id"], float(args["radius"]))
    collision_objects[sphere.id] = sphere
    return "ok", 200
Example #2
0
    def read_project_data(self, file_name: str, cls: Type[T]) -> T:

        try:

            with open(os.path.join("data", file_name + ".json")) as scene_file:

                data_dict = json.loads(scene_file.read())
                data_dict = convert_keys(data_dict,
                                         hlp.camel_case_to_snake_case)

                return cls.from_dict(data_dict)

        except JsonSchemaValidationError as e:
            raise ResourcesException(f"Invalid project/scene: {e}")
Example #3
0
def put_mesh() -> RespT:
    """Add or update collision mesh.
        ---
        put:
            tags:
                - Collisions
            description: Add or update collision mesh.
            parameters:
                - name: meshId
                  in: query
                  schema:
                    type: string
                - name: uri
                  in: query
                  schema:
                    type: string
                - name: meshScaleX
                  in: query
                  schema:
                    type: number
                    format: float
                    default: 1
                - name: meshScaleY
                  in: query
                  schema:
                    type: number
                    format: float
                    default: 1
                - name: meshScaleZ
                  in: query
                  schema:
                    type: number
                    format: float
                    default: 1
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Pose
            responses:
                200:
                  description: Ok
    """

    args = convert_keys(request.args.to_dict(), camel_case_to_snake_case)
    mesh = object_type.Mesh(args["mesh_id"], args["uri"])
    collision_objects[mesh.id] = mesh
    return "ok", 200
Example #4
0
def put_box() -> RespT:
    """Add or update collision box.
        ---
        put:
            tags:
                - Collisions
            description: Add or update collision box.
            parameters:
                - name: boxId
                  in: query
                  schema:
                    type: string
                - name: sizeX
                  in: query
                  schema:
                    type: number
                    format: float
                - name: sizeY
                  in: query
                  schema:
                    type: number
                    format: float
                - name: sizeZ
                  in: query
                  schema:
                    type: number
                    format: float
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Pose
            responses:
                200:
                  description: Ok
    """

    args = convert_keys(request.args.to_dict(), camel_case_to_snake_case)
    box = object_type.Box(args["box_id"], float(args["size_x"]),
                          float(args["size_y"]), float(args["size_z"]))
    collision_objects[box.id] = box
    return "ok", 200
Example #5
0
def put_sphere():
    """Add or update sphere.
        ---
        put:
            tags:
                - Models
            description: Add or update sphere.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Sphere
            responses:
                200:
                  description: Ok
    """

    sphere = object_type.Sphere.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    SPHERES[sphere.id] = sphere
    return "ok", 200
Example #6
0
def put_cylinder():
    """Add or update box.
        ---
        put:
            tags:
                - Models
            description: Add or update service type.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Cylinder
            responses:
                200:
                  description: Ok
    """

    cylinder = object_type.Cylinder.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    CYLINDERS[cylinder.id] = cylinder
    return "ok", 200
Example #7
0
def put_box():
    """Add or update box.
        ---
        put:
            tags:
                - Models
            description: Add or update service type.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Box
            responses:
                200:
                  description: Ok
    """

    box = object_type.Box.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    BOXES[box.id] = box
    return "ok", 200
Example #8
0
def put_service_type():
    """Add or update service type.
        ---
        put:
            tags:
                - ServiceType
            description: Add or update service type.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: ServiceType
            responses:
                200:
                  description: Ok
    """

    srv_type = services.ServiceType.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    SERVICE_TYPES[srv_type.id] = srv_type
    return "ok", 200
Example #9
0
def put_object_type():
    """Add or update object type.
        ---
        put:
            tags:
                - ObjectType
            description: Add or update object type.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: ObjectType
            responses:
                200:
                  description: Ok
    """

    obj_type = object_type.ObjectType.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    OBJECT_TYPES[obj_type.id] = obj_type
    return "ok", 200
Example #10
0
def put_project():
    """Add or update project.
        ---
        put:
            tags:
                - Project
            description: Add or update project.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Project
            responses:
                200:
                  description: Ok
    """

    project = common.Project.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    project.modified = datetime.now(tz=timezone.utc)
    PROJECTS[project.id] = project
    return "ok", 200
Example #11
0
def put_scene():
    """Add or update scene.
        ---
        put:
            tags:
                - Scene
            description: Add or update scene.
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Scene
            responses:
                200:
                  description: Ok
    """

    scene = common.Scene.from_dict(convert_keys(request.json, camel_case_to_snake_case))
    scene.modified = datetime.now(tz=timezone.utc)
    SCENES[scene.id] = scene
    return "ok", 200
Example #12
0
def put_cylinder() -> RespT:
    """Add or update collision cylinder.
        ---
        put:
            tags:
                - Collisions
            description: Add or update collision cylinder.
            parameters:
                - name: cylinderId
                  in: query
                  schema:
                    type: string
                - name: radius
                  in: query
                  schema:
                    type: number
                    format: float
                - name: height
                  in: query
                  schema:
                    type: number
                    format: float
            requestBody:
                  content:
                    application/json:
                      schema:
                        $ref: Pose
            responses:
                200:
                  description: Ok
    """

    args = convert_keys(request.args.to_dict(), camel_case_to_snake_case)
    cylinder = object_type.Cylinder(args["cylinder_id"], float(args["radius"]),
                                    float(args["height"]))
    collision_objects[cylinder.id] = cylinder
    return "ok", 200