Initial commit

This commit is contained in:
2026-07-03 16:31:37 +07:00
commit 899c7c637d
1939 changed files with 641750 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
using Microsoft.AspNetCore.Mvc;
namespace RobotNet10.RobotApp.MarkerDetection;
public static class MarkerDetectionApiEndpoints
{
// Marker Detection Control API
public static IEndpointRouteBuilder MapMarkerDetectionApiEndpoints(this IEndpointRouteBuilder app)
{
var markerApi = app.MapGroup("/api/marker-detection").DisableAntiforgery();
// Enable or disable marker detection
markerApi.MapPost("/detection/enable", async (HttpRequest request, [FromServices] MarkerDetectionIntegrationService service) =>
{
try
{
var body = await request.ReadFromJsonAsync<Dictionary<string, bool>>();
var enable = body?["enable"] ?? true;
service.SetEnableDetection(enable);
return Results.Ok(new
{
status = "success",
message = $"Marker detection {(enable ? "enabled" : "disabled")}",
enabled = enable
});
}
catch (Exception ex)
{
return Results.BadRequest(new { status = "error", message = ex.Message });
}
});
// Get current marker pose
markerApi.MapGet("/pose/current", ([FromServices] MarkerDetectionIntegrationService service) =>
{
try
{
var pose = service.GetMarkerPose();
if (pose == null)
return Results.NotFound(new { status = "error", message = "No marker pose available" });
return Results.Ok(new
{
status = "success",
pose = new
{
header = new
{
seq = pose.Header.Seq,
stamp = pose.Header.Stamp,
frameId = pose.Header.FrameId
},
position = new
{
x = pose.Pose.Position[0],
y = pose.Pose.Position[1],
z = pose.Pose.Position[2]
},
orientation = new
{
x = pose.Pose.Orientation[0],
y = pose.Pose.Orientation[1],
z = pose.Pose.Orientation[2],
w = pose.Pose.Orientation[3]
}
}
});
}
catch (Exception ex)
{
return Results.BadRequest(new { status = "error", message = ex.Message });
}
});
return app;
}
}