This commit is contained in:
IDONTSUDO 2024-05-13 20:43:11 +03:00
parent 4585d079f6
commit 5162612a77
49 changed files with 1108 additions and 732 deletions

View file

@ -1,4 +1,4 @@
import { BehaviorTreesPresentation } from "../../features/behavior_trees/behavior_trees";
import { BehaviorTreesPresentation } from "../../features/behavior_trees/behavior_trees_presentation";
import { DatasetsPresentation } from "../../features/datasets/datasets_presentation";
import { WeightsPresentation } from "../../features/weights/weights_presentation";
import { ProjectsPresentation } from "../../features/projects/projects_presentation";

View file

@ -0,0 +1,22 @@
import { CallbackStrategyWithIdQuery } from "../controllers/http_controller";
import { Result } from "../helpers/result";
import { ReadByIdDataBaseModelUseCase } from "../usecases/read_by_id_database_model_usecase";
import { CoreValidation } from "../validations/core_validation";
import { MongoIdValidation } from "../validations/mongo_id_validation";
export class ReadByIdDataBaseModelScenario<D> extends CallbackStrategyWithIdQuery {
idValidationExpression: CoreValidation = new MongoIdValidation();
databaseModel: D;
constructor(model) {
super();
this.databaseModel = model;
}
call = async (id: string): Promise<Result<Error, D>> => {
try {
return new ReadByIdDataBaseModelUseCase<D>(this.databaseModel).call(id);
} catch (error) {
return Result.error(error);
}
};
}

View file

@ -1,12 +0,0 @@
import { CoreHttpController } from "../../core/controllers/http_controller";
import { DatasetValidationModel } from "../datasets/models/dataset_validation_model";
import { GetBehaviorTreeSkillsUseCase } from "./get_bt_usecase";
export class BehaviorTreesPresentation extends CoreHttpController<DatasetValidationModel> {
constructor() {
super({
url: "behavior/trees",
validationModel: DatasetValidationModel,
});
super.get(new GetBehaviorTreeSkillsUseCase().call);
}
}

View file

@ -0,0 +1,20 @@
import { CrudController } from "../../core/controllers/crud_controller";
import { GetBehaviorTreeSkillsTemplatesUseCase } from "./get_bt_skills_templates_usecase";
import { BehaviorTreeValidationModel } from "./models/behavior_tree_validation_model";
import { BehaviorTreeDBModel } from "./models/behavior_tree_database_model";
import { ReadByIdDataBaseModelScenario } from "../../core/scenarios/read_by_id_database_model_scenario";
export class BehaviorTreesPresentation extends CrudController<BehaviorTreeValidationModel, typeof BehaviorTreeDBModel> {
constructor() {
super({
url: "behavior/trees",
validationModel: BehaviorTreeValidationModel,
databaseModel: BehaviorTreeDBModel,
});
this.subRoutes.push({ method: "GET", subUrl: "templates", fn: new GetBehaviorTreeSkillsTemplatesUseCase() });
this.subRoutes.push({
method: "GET",
subUrl: "by_id",
fn: new ReadByIdDataBaseModelScenario<BehaviorTreeValidationModel>(BehaviorTreeDBModel),
});
}
}

View file

@ -1,7 +1,8 @@
import { CallbackStrategyWithEmpty, ResponseBase } from "../../core/controllers/http_controller";
import { Result } from "../../core/helpers/result";
export class GetBehaviorTreeSkillsUseCase {
call = () => {
export class GetBehaviorTreeSkillsTemplatesUseCase extends CallbackStrategyWithEmpty {
call = async (): ResponseBase => {
return Result.ok({
skills: [
{
@ -25,8 +26,17 @@ export class GetBehaviorTreeSkillsUseCase {
name: "peConfigure",
format: "yaml",
type: "run",
param: ["object_name", "weights_file"],
result: ["Pose"],
param: [
{
type: "weights",
dependency: {},
},
{
type: "form",
dependency: {},
},
],
result: ["POSE"],
},
{
name: "peStop",
@ -82,72 +92,6 @@ export class GetBehaviorTreeSkillsUseCase {
topicCameraInfo: "/inner_rgbd_camera/camera_info",
},
},
{
SkillPackage: {
name: "Robossembler",
version: "1.0",
format: "1",
},
Module: {
name: "ObjectDetection",
description: "Object detection skill with YOLOv8",
},
Launch: {
executable: "detection_lifecycle.py",
},
ROS2: {
node_name: "lc_detection",
},
BTAction: [
{
name: "odConfigure",
format: "yaml",
args: ["SettingPath", "server_name", "server_timeout"],
result: ["boundBox"],
},
{
name: "odStop",
format: "yaml",
args: ["server_name", "server_timeout"],
result: [],
},
],
Interface: {
Input: [
{
name: "cameraLink",
type: "string",
group: "STD_USER",
},
{
name: "topicImage",
type: "Image",
group: "sensor_msgs.msg",
},
],
Output: [
{
name: "boundBox",
type: "BoundBox",
group: ".msg",
},
],
},
Settings: [
{
name: "publishDelay",
value: 0.5,
},
{
name: "server_timeout",
value: 1000,
},
{
name: "server_name",
value: "/object_detection/change_state",
},
],
},
],
});
};

View file

@ -0,0 +1,39 @@
import { Schema, model } from "mongoose";
import { IProjectModel, projectSchema } from "../../_projects/models/project_database_model";
export interface IBehaviorTreeModel {
name: string;
project?: IProjectModel;
unixTime?: number;
local_path?: string;
}
export const BehaviorTreeSchema = new Schema({
name: {
type: String,
},
local_path: {
type: String,
},
unixTime: {
type: Number,
default: Date.now(),
},
isFinished: {
type: Boolean,
default: false,
},
dependency: {
type: Schema.Types.Mixed,
},
project: {
type: Schema.Types.ObjectId,
ref: projectSchema,
autopopulate: true,
require: true,
},
}).plugin(require("mongoose-autopopulate"));
export const behaviorTreeSchema = "Behavior";
export const BehaviorTreeDBModel = model<IBehaviorTreeModel>(behaviorTreeSchema, BehaviorTreeSchema);

View file

@ -0,0 +1,7 @@
import { IsString } from "class-validator";
import { IBehaviorTreeModel } from "./behavior_tree_database_model";
export class BehaviorTreeValidationModel implements IBehaviorTreeModel {
@IsString()
public name: string;
}

View file

@ -1,4 +1,4 @@
import { IsNumber, IsString } from "class-validator";
import { IsNumber, IsOptional, IsString } from "class-validator";
import { IWeightModel } from "./weights_validation_model";
export class WeightValidationModel implements IWeightModel {
@ -10,4 +10,6 @@ export class WeightValidationModel implements IWeightModel {
public name: string;
public datasetId: string;
public project: string;
@IsOptional()
public isFinished:boolean;
}