2026-07-21 11:11:01 +08:00
|
|
|
using ClumsyCore;
|
2026-07-21 17:38:16 +08:00
|
|
|
using ClumsyCore.DTools;
|
2026-07-21 11:11:01 +08:00
|
|
|
using ClumsyCore.Interfaces;
|
|
|
|
|
using ClumsyCore.Pilot;
|
2026-07-21 17:38:16 +08:00
|
|
|
using MDCSToolBox.Commons.Controllers;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Numerics;
|
2026-07-21 11:11:01 +08:00
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
namespace MultiWheelC
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
public abstract class DstTrackerTestBase : MovementTest
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
public bool UseInteractivePick = true;
|
|
|
|
|
public float srcX;
|
|
|
|
|
public float srcY;
|
|
|
|
|
public float dstX;
|
|
|
|
|
public float dstY;
|
|
|
|
|
public float carDirectionBias;
|
2026-07-21 11:11:01 +08:00
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
private readonly Painter _painter = UI.GetPainter("DstTrackerTest");
|
|
|
|
|
private DriveTask _dt;
|
2026-07-21 11:11:01 +08:00
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
protected DstTrackerTestBase(float defaultCarDirectionBias)
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
carDirectionBias = defaultCarDirectionBias;
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
public override void TestStop()
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
_dt?.Stop();
|
|
|
|
|
_painter?.Clear();
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
public override void Test()
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
Vector2 p1;
|
|
|
|
|
Vector2 p2;
|
|
|
|
|
if (UseInteractivePick)
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
p1 = UI.GetPoint("point1");
|
|
|
|
|
p2 = UI.GetPoint("point2");
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
p1 = new Vector2(srcX, srcY);
|
|
|
|
|
p2 = new Vector2(dstX, dstY);
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
_painter.Clear();
|
|
|
|
|
_dt = new DriveTask(new DstTracker
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
Src = p1,
|
|
|
|
|
Dst = p2,
|
|
|
|
|
CarDirectionBias = carDirectionBias,
|
|
|
|
|
}.Get());
|
|
|
|
|
_dt.Wait();
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
[MovementTest(name = "测试终点跟踪动作-前进")]
|
|
|
|
|
public sealed class DstTrackerForward : DstTrackerTestBase
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
public DstTrackerForward() : base(0f) { }
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
[MovementTest(name = "测试终点跟踪动作-后退")]
|
|
|
|
|
public sealed class DstTrackerBackward : DstTrackerTestBase
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
public DstTrackerBackward() : base(180f) { }
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
[MovementTest(name = "底盘旋转测试")]
|
|
|
|
|
public class RotateToAngleTest : MovementTest
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
// 底盘旋转测试不支持停止操作。
|
|
|
|
|
public override void TestStop()
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
throw new NotImplementedException();
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-21 17:38:16 +08:00
|
|
|
// 交互输入目标角度后执行底盘原地旋转测试。
|
|
|
|
|
public override void Test()
|
2026-07-21 11:11:01 +08:00
|
|
|
{
|
2026-07-21 17:38:16 +08:00
|
|
|
var target = UI.GetInput("输入旋转角度:");
|
|
|
|
|
new DriveTask(new MultiWheelRotateInPlace()
|
|
|
|
|
{
|
|
|
|
|
AngleTarget = float.Parse(target),
|
|
|
|
|
PidparamsRead = () => new PIDParams()
|
|
|
|
|
{
|
|
|
|
|
Kp = PilotDefinition.Conf.InPlaceRotateKp,
|
|
|
|
|
Ki = PilotDefinition.Conf.InPlaceRotateKi,
|
|
|
|
|
Kd = PilotDefinition.Conf.InPlaceRotateKd,
|
|
|
|
|
DeadZone = PilotDefinition.Conf.InPlaceRotateArriveDeg,
|
|
|
|
|
SpeedAccPerSec = PilotDefinition.Conf.InPlaceRotateAcc,
|
|
|
|
|
OutputUpperThreshold = PilotDefinition.Conf.InPlaceRotateMaxSpeed,
|
|
|
|
|
MaxI = PilotDefinition.Conf.InPlaceRotateMaxI,
|
|
|
|
|
}
|
|
|
|
|
}.Get()).Wait();
|
|
|
|
|
}
|
2026-07-21 11:11:01 +08:00
|
|
|
}
|
|
|
|
|
}
|