progress
This commit is contained in:
parent
d8b5018cb2
commit
318d0a7893
60 changed files with 746 additions and 524 deletions
|
@ -34,11 +34,11 @@ export abstract class CallbackStrategyWithFilesUploads {
|
|||
abstract call(files: File[]): ResponseBase;
|
||||
}
|
||||
|
||||
interface ISubSetFeatureRouter<T> {
|
||||
interface ISubSetFeatureRouter<A> {
|
||||
method: HttpMethodType;
|
||||
subUrl: string;
|
||||
fn:
|
||||
| CallbackStrategyWithValidationModel<T>
|
||||
| CallbackStrategyWithValidationModel<A>
|
||||
| CallbackStrategyWithEmpty
|
||||
| CallbackStrategyWithIdQuery
|
||||
| CallBackStrategyWithQueryPage
|
||||
|
@ -179,7 +179,7 @@ export class CoreHttpController<V> implements ICoreHttpController {
|
|||
router: this.router,
|
||||
};
|
||||
}
|
||||
public put(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||
public put(usecase: any) {
|
||||
this.routes["PUT"] = usecase;
|
||||
}
|
||||
public delete(usecase: CallbackStrategyWithValidationModel<V>) {
|
||||
|
|
|
@ -2,5 +2,7 @@ export enum StaticFiles {
|
|||
robossembler_assets = "robossembler_assets.json",
|
||||
assets = "/assets/assets.json",
|
||||
parts = '/assets/parts.json',
|
||||
robots = '/robots/'
|
||||
robots = '/robots/',
|
||||
scenes = '/scenes/',
|
||||
behaviorTrees = 'behavior_trees'
|
||||
}
|
||||
|
|
|
@ -5,6 +5,35 @@ export class GetBehaviorTreeSkillsTemplatesUseCase extends CallbackStrategyWithE
|
|||
call = async (): ResponseBase => {
|
||||
return Result.ok({
|
||||
skills: [
|
||||
{
|
||||
SkillPackage: { name: "Robossembler", version: "1.0", format: "1" },
|
||||
Module: { name: "MoveToPose", description: "Move to Pose skill with cartesian controllers" },
|
||||
Launch: { package: "rbss_movetopose", executable: "mtp_cartesian.py", name: "mtp_cartesian" },
|
||||
BTAction: [
|
||||
{
|
||||
name: "move",
|
||||
type: "action",
|
||||
param: [
|
||||
{
|
||||
type: "move_to_pose",
|
||||
dependency: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
Interface: {
|
||||
Input: [
|
||||
{ name: "robotName", type: "ROBOT" },
|
||||
{ name: "pose", type: "POSE" },
|
||||
],
|
||||
Output: [],
|
||||
},
|
||||
Settings: [
|
||||
{ name: "topicServer", value: "cartesian_move_to_pose" },
|
||||
{ name: "end_effector_velocity", value: 1.0 },
|
||||
{ name: "end_effector_acceleration", value: 1.0 },
|
||||
],
|
||||
},
|
||||
{
|
||||
SkillPackage: { name: "Robossembler", version: "1.0", format: "1", type: "Action" },
|
||||
Module: { name: "PoseEstimation", description: "Pose Estimation skill with DOPE" },
|
||||
|
@ -20,12 +49,12 @@ export class GetBehaviorTreeSkillsTemplatesUseCase extends CallbackStrategyWithE
|
|||
},
|
||||
{
|
||||
type: "camera",
|
||||
dependency: {}
|
||||
dependency: {},
|
||||
},
|
||||
{
|
||||
type: "topic",
|
||||
dependency: {}
|
||||
}
|
||||
dependency: {},
|
||||
},
|
||||
],
|
||||
result: ["POSE"],
|
||||
},
|
||||
|
@ -46,28 +75,6 @@ export class GetBehaviorTreeSkillsTemplatesUseCase extends CallbackStrategyWithE
|
|||
{ name: "mesh_scale", value: 0.001 },
|
||||
],
|
||||
},
|
||||
{
|
||||
SkillPackage: { name: "Robossembler", version: "1.0", format: "1" },
|
||||
Module: { name: "MoveToPose", description: "Move to Pose skill with ? controllers" },
|
||||
Launch: { package: "rbss_movetopose", executable: "movetopose.py", name: "skill_move" },
|
||||
BTAction: [
|
||||
{
|
||||
name: "move",
|
||||
type: "action",
|
||||
param: [{ type: "topic", dependency: { } }],
|
||||
result: []
|
||||
}
|
||||
],
|
||||
Interface: {
|
||||
Input: [
|
||||
{ name: "robotName", type: "ROBOT" },
|
||||
{ name: "pose", type: "POSE" }
|
||||
],
|
||||
Output: []
|
||||
},
|
||||
Settings: []
|
||||
}
|
||||
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -12,6 +12,10 @@ export const BehaviorTreeSchema = new Schema({
|
|||
name: {
|
||||
type: String,
|
||||
},
|
||||
scene: {
|
||||
type: Schema.Types.Mixed,
|
||||
default: [],
|
||||
},
|
||||
local_path: {
|
||||
type: String,
|
||||
},
|
||||
|
@ -29,9 +33,8 @@ export const BehaviorTreeSchema = new Schema({
|
|||
skills: {
|
||||
type: Schema.Types.Mixed,
|
||||
},
|
||||
scene: {
|
||||
type: Array,
|
||||
default: null,
|
||||
sceneId: {
|
||||
type: String,
|
||||
},
|
||||
project: {
|
||||
type: Schema.Types.ObjectId,
|
||||
|
|
46
server/src/features/scene/create_new_scene_scenario.ts
Normal file
46
server/src/features/scene/create_new_scene_scenario.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { IsString } from "class-validator";
|
||||
import { CallbackStrategyWithValidationModel, ResponseBase } from "../../core/controllers/http_controller";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { CreateFileUseCase } from "../../core/usecases/create_file_usecase";
|
||||
import { GetActiveProjectIdScenario } from "../projects/domain/get_active_project_id_scenario";
|
||||
import { model } from "mongoose";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
|
||||
import { IProjectModel, ProjectDBModel } from "../projects/models/project_model_database_model";
|
||||
import { StaticFiles } from "../../core/models/static_files";
|
||||
import { CreateDataBaseModelUseCase } from "../../core/usecases/create_database_model_usecase";
|
||||
import { SceneDBModel } from "./scene_database_model";
|
||||
import { SceneValidationModel } from "./scene_validation_model";
|
||||
export class SceneModel {
|
||||
@IsString()
|
||||
name: string;
|
||||
}
|
||||
export class SceneAssets {
|
||||
name: string;
|
||||
scene: [] = [];
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
static empty = () => new SceneAssets("");
|
||||
}
|
||||
export class CreateNewSceneScenario extends CallbackStrategyWithValidationModel<SceneModel> {
|
||||
validationModel: SceneModel = SceneModel;
|
||||
|
||||
call = async (model: SceneModel): ResponseBase =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map(async (projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
|
||||
return (
|
||||
await new CreateFileUseCase().call(
|
||||
`${rootDir}${StaticFiles.scenes}${model.name}.json`,
|
||||
Buffer.from(JSON.stringify(new SceneAssets(model.name)))
|
||||
)
|
||||
).map(async () =>
|
||||
(await new CreateDataBaseModelUseCase(SceneDBModel).call(model)).map(() => Result.ok("Create"))
|
||||
);
|
||||
});
|
||||
}
|
28
server/src/features/scene/edit_scene_scenario.ts
Normal file
28
server/src/features/scene/edit_scene_scenario.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { CallbackStrategyWithValidationModel, ResponseBase } from "../../core/controllers/http_controller";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { StaticFiles } from "../../core/models/static_files";
|
||||
import { CreateFileUseCase } from "../../core/usecases/create_file_usecase";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
|
||||
import { IProjectModel, ProjectDBModel } from "../projects/models/project_model_database_model";
|
||||
import { SceneAssets } from "./create_new_scene_scenario";
|
||||
import { SceneValidationModel } from "./scene_validation_model";
|
||||
|
||||
export class EditSceneScenario extends CallbackStrategyWithValidationModel<SceneValidationModel> {
|
||||
validationModel: SceneValidationModel;
|
||||
call = async (model: SceneValidationModel): ResponseBase =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map(async (projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
|
||||
return (
|
||||
await new CreateFileUseCase().call(
|
||||
`${rootDir}${StaticFiles.scenes}${model.name}.json`,
|
||||
Buffer.from(JSON.stringify(model))
|
||||
)
|
||||
).map(async () => Result.ok("Edit"));
|
||||
});
|
||||
}
|
31
server/src/features/scene/read_scene_scenario.ts
Normal file
31
server/src/features/scene/read_scene_scenario.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { CallbackStrategyWithIdQuery, ResponseBase } from "../../core/controllers/http_controller";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { StaticFiles } from "../../core/models/static_files";
|
||||
import { CreateFileUseCase } from "../../core/usecases/create_file_usecase";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../core/usecases/read_by_id_database_model_usecase";
|
||||
import { ReadFileAndParseJsonUseCase } from "../../core/usecases/read_file_and_parse_json";
|
||||
import { SearchManyDataBaseModelUseCase } from "../../core/usecases/search_many_database_model_usecase";
|
||||
import { CoreValidation } from "../../core/validations/core_validation";
|
||||
import { MongoIdValidation } from "../../core/validations/mongo_id_validation";
|
||||
import { IProjectModel, ProjectDBModel } from "../projects/models/project_model_database_model";
|
||||
import { SceneAssets, SceneModel } from "./create_new_scene_scenario";
|
||||
import { SceneDBModel } from "./scene_database_model";
|
||||
|
||||
export class ReadSceneScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression: CoreValidation = new MongoIdValidation();
|
||||
call = async (id: string): ResponseBase =>
|
||||
(await new ReadByIdDataBaseModelUseCase<SceneModel>(SceneDBModel).call(id)).map(async (model) =>
|
||||
(
|
||||
await new SearchManyDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call(
|
||||
{ isActive: true },
|
||||
"is dont active projects"
|
||||
)
|
||||
).map(async (projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
|
||||
return (await new ReadFileAndParseJsonUseCase().call(`${rootDir}${StaticFiles.scenes}${model.name}.json`)).map(
|
||||
async (sceneAsset) => Result.ok(sceneAsset)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { ReadByIdDataBaseModelScenario } from "../../core/scenarios/read_by_id_database_model_scenario";
|
||||
import { BehaviorTreeDBModel } from "../behavior_trees/models/behavior_tree_database_model";
|
||||
import { BehaviorTreeValidationModel } from "../behavior_trees/models/behavior_tree_validation_model";
|
||||
import { CreateNewSceneScenario } from "./create_new_scene_scenario";
|
||||
import { CreateRobotScenario } from "./create_robot_scenario";
|
||||
import { EditSceneScenario } from "./edit_scene_scenario";
|
||||
import { ReadSceneScenario } from "./read_scene_scenario";
|
||||
import { SceneDBModel } from "./scene_database_model";
|
||||
import { SceneValidationModel } from "./scene_validation_model";
|
||||
|
||||
|
@ -10,10 +16,17 @@ export class ScenePresentation extends CrudController<SceneValidationModel, type
|
|||
validationModel: SceneValidationModel,
|
||||
databaseModel: SceneDBModel,
|
||||
});
|
||||
super.post(new CreateNewSceneScenario().call);
|
||||
super.put(new EditSceneScenario().call);
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "create/robot",
|
||||
fn: new CreateRobotScenario(),
|
||||
});
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "by_id",
|
||||
fn: new ReadSceneScenario(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue