✨ feat(*): 添加触发样本偏移与实发轨迹分析导出
* 为 RobotConfig 增加 trigger_sample_index_offset_cycles 配置 * 让 DO 事件携带示教点关节角并按最接近 sample 绑定触发 * 调整运行时 IO 地址位掩码映射并补充 ShotEvents 导出 * 新增 2026042802-1 抓包分析脚本、数据产物与结论文档 * 补齐配置兼容、规划绑定和运行时触发相关测试
This commit is contained in:
@@ -170,6 +170,51 @@ public sealed class PlanningCompatibilityTests
|
||||
Assert.Equal(1, doEvent.WaypointIndex);
|
||||
Assert.Equal(1, doEvent.OffsetCycles);
|
||||
Assert.Equal(2, doEvent.HoldCycles);
|
||||
Assert.NotNull(doEvent.ReferenceJointsDegrees);
|
||||
Assert.Equal(RadiansToDegrees(1.0), doEvent.ReferenceJointsDegrees![0], precision: 6);
|
||||
Assert.Equal(0.0, doEvent.ReferenceJointsDegrees![1], precision: 6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证时间轴会把示教点关节角保存到 DO 事件里,供运行时在近时窗内做最小关节差绑定。
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ShotTimelineBuilder_PopulatesReferenceJointsDegreesForRuntimeBinding()
|
||||
{
|
||||
var robot = CreateRobotProfile([1, 1], [1, 1], [1, 1]);
|
||||
var program = new FlyshotProgram(
|
||||
name: "demo",
|
||||
waypoints:
|
||||
[
|
||||
new JointWaypoint([0.0, 0.0]),
|
||||
new JointWaypoint([Math.PI / 6.0, -Math.PI / 4.0])
|
||||
],
|
||||
shotFlags: [false, true],
|
||||
offsetValues: [0, 0],
|
||||
addressGroups:
|
||||
[
|
||||
new IoAddressGroup(Array.Empty<int>()),
|
||||
new IoAddressGroup([1])
|
||||
]);
|
||||
|
||||
var trajectory = new PlannedTrajectory(
|
||||
robot: robot,
|
||||
originalProgram: program,
|
||||
plannedWaypoints: program.Waypoints,
|
||||
waypointTimes: [0.0, 0.5],
|
||||
segmentDurations: [0.5],
|
||||
segmentScales: [1.0],
|
||||
method: PlanningMethod.Icsp,
|
||||
iterations: 1,
|
||||
threshold: 0.0);
|
||||
|
||||
var timeline = new ShotTimelineBuilder(new WaypointTimestampResolver())
|
||||
.Build(trajectory, holdCycles: 1, samplePeriod: TimeSpan.FromMilliseconds(8));
|
||||
|
||||
var trigger = Assert.Single(timeline.TriggerTimeline);
|
||||
Assert.NotNull(trigger.ReferenceJointsDegrees);
|
||||
Assert.Equal(30.0, trigger.ReferenceJointsDegrees![0], precision: 6);
|
||||
Assert.Equal(-45.0, trigger.ReferenceJointsDegrees![1], precision: 6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -271,4 +316,9 @@ public sealed class PlanningCompatibilityTests
|
||||
|
||||
throw new DirectoryNotFoundException("Unable to locate the flyshot workspace root.");
|
||||
}
|
||||
|
||||
private static double RadiansToDegrees(double radians)
|
||||
{
|
||||
return radians * 180.0 / Math.PI;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user