39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace RobotNet10.RobotApp.TF3;
|
|
|
|
public static class Tf3ApiEndpoints
|
|
{
|
|
// TF3 Static Transform Configuration API
|
|
public static IEndpointRouteBuilder MapTf3ApiEndpoints(this IEndpointRouteBuilder app)
|
|
{
|
|
var tf3Api = app.MapGroup("/api/tf3").DisableAntiforgery();
|
|
|
|
// TF3 data - LIDAR static transforms (base_link -> scan_N), for map renderer LIDAR drawing
|
|
tf3Api.MapGet("/lidar_transforms", ([FromServices] IConfiguration configuration) =>
|
|
{
|
|
var transforms = configuration.GetSection("Tf3:StaticTransforms")
|
|
.Get<List<Tf3StaticTransformConfig>>() ?? new();
|
|
|
|
return Results.Ok(new
|
|
{
|
|
status = "success",
|
|
transforms = transforms.Select(t => new
|
|
{
|
|
frameId = t.FrameId,
|
|
childFrameId = t.ChildFrameId,
|
|
x = t.Pose.Position.X,
|
|
y = t.Pose.Position.Y,
|
|
z = t.Pose.Position.Z,
|
|
qx = t.Pose.Orientation.X,
|
|
qy = t.Pose.Orientation.Y,
|
|
qz = t.Pose.Orientation.Z,
|
|
qw = t.Pose.Orientation.W
|
|
}).ToArray()
|
|
});
|
|
});
|
|
|
|
return app;
|
|
}
|
|
}
|