✨ feat(config): 更新 RobotConfig.json 以支持运行时速度倍率配置
* 在 RobotConfig.json 中新增 speed_ratio 配置,允许在运行时设置默认速度倍率。 * 调整 ControllerClientCompatService 以使用 speed_ratio 初始化机器人设置。 * 更新 TrajectoryLimitValidator 和 FlyshotExecutionSendSequenceBuilder,支持在飞拍链路中临时关闭 jerk 校验,仅保留速度和加速度约束。 * 新增文档记录对 UTTC_MS11 的 jerk 阻断策略调整,确保飞拍链路的执行效率。 * 增加单元测试以验证 speed_ratio 的加载和 jerk 校验的行为。
This commit is contained in:
@@ -75,6 +75,7 @@ public sealed class ConfigCompatibilityTests
|
||||
Assert.Equal(0.5, loaded.Robot.AccLimitScale);
|
||||
Assert.Equal(0.25, loaded.Robot.JerkLimitScale);
|
||||
Assert.Equal(1.0, loaded.Robot.PlanningSpeedScale);
|
||||
Assert.Equal(1.0, loaded.Robot.SpeedRatio);
|
||||
Assert.True(loaded.Robot.SmoothStartStopTiming);
|
||||
Assert.Equal([0, 0, 0], program.OffsetValues);
|
||||
Assert.All(program.AddressGroups, group => Assert.Empty(group.Addresses));
|
||||
@@ -85,6 +86,46 @@ public sealed class ConfigCompatibilityTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证 RobotConfig.json 可以显式配置运行时默认速度倍率,供 MoveJoint 和后续执行链路初始化使用。
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RobotConfigLoader_LoadsRuntimeSpeedRatio()
|
||||
{
|
||||
var tempRoot = CreateTempDirectory();
|
||||
try
|
||||
{
|
||||
var configPath = Path.Combine(tempRoot, "legacy.json");
|
||||
File.WriteAllText(
|
||||
configPath,
|
||||
"""
|
||||
{
|
||||
"robot": {
|
||||
"use_do": true,
|
||||
"io_keep_cycles": 2,
|
||||
"acc_limit": 1.0,
|
||||
"jerk_limit": 1.0,
|
||||
"speed_ratio": 0.65
|
||||
},
|
||||
"flying_shots": {
|
||||
"demo": {
|
||||
"traj_waypoints": [[0, 1], [2, 3], [4, 5], [6, 7]],
|
||||
"shot_flags": [false, false, false, false]
|
||||
}
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
var loaded = new RobotConfigLoader().Load(configPath);
|
||||
|
||||
Assert.Equal(0.65, loaded.Robot.SpeedRatio, precision: 6);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(tempRoot, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证 RobotConfig.json 可以显式配置规划限速倍率,且该倍率独立于运行时 J519 速度倍率。
|
||||
/// </summary>
|
||||
|
||||
@@ -74,7 +74,8 @@ public sealed class ControllerClientCompatConfigRootTests
|
||||
triggerSampleIndexOffsetCycles: 7,
|
||||
accLimitScale: 1.0,
|
||||
jerkLimitScale: 1.0,
|
||||
adaptIcspTryNum: 5);
|
||||
adaptIcspTryNum: 5,
|
||||
speedRatio: 0.65);
|
||||
var trajectory = TestRobotFactory.CreateUploadedTrajectoryWithSingleShot();
|
||||
|
||||
store.Save("FANUC_LR_Mate_200iD", settings, trajectory);
|
||||
@@ -85,6 +86,7 @@ public sealed class ControllerClientCompatConfigRootTests
|
||||
var loaded = store.LoadAll("FANUC_LR_Mate_200iD", out var loadedSettings);
|
||||
Assert.NotNull(loadedSettings);
|
||||
Assert.Equal(7, loadedSettings.TriggerSampleIndexOffsetCycles);
|
||||
Assert.Equal(0.65, loadedSettings.SpeedRatio, precision: 6);
|
||||
Assert.Contains(trajectory.Name, loaded);
|
||||
|
||||
store.Delete("FANUC_LR_Mate_200iD", trajectory.Name);
|
||||
|
||||
@@ -239,6 +239,36 @@ public sealed class PlanningCompatibilityTests
|
||||
Assert.Contains("dense-acceleration-check", exception.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证飞拍链路临时关闭 jerk 复核时,仍保留速度/加速度校验,但不会再被 jerk 单独阻断。
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TrajectoryLimitValidator_CanSkipJerkValidation_ForFlyshotPath()
|
||||
{
|
||||
var robot = CreateRobotProfile([100.0], [1000.0], [10.0]);
|
||||
IReadOnlyList<IReadOnlyList<double>> rows =
|
||||
[
|
||||
[0.0, 0.0],
|
||||
[0.008, 0.0],
|
||||
[0.016, 0.01],
|
||||
[0.024, 0.02]
|
||||
];
|
||||
|
||||
var exception = Assert.Throws<InvalidOperationException>(() =>
|
||||
TrajectoryLimitValidator.ValidateDenseJointTrajectory(
|
||||
robot,
|
||||
rows,
|
||||
trajectoryName: "dense-jerk-check"));
|
||||
|
||||
Assert.Contains("Jerk", exception.Message);
|
||||
|
||||
TrajectoryLimitValidator.ValidateDenseJointTrajectory(
|
||||
robot,
|
||||
rows,
|
||||
trajectoryName: "dense-jerk-check-skip",
|
||||
validateJerk: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构造一个最小 RobotProfile,便于规划层单元测试聚焦在时间轴逻辑上。
|
||||
/// </summary>
|
||||
|
||||
@@ -887,7 +887,8 @@ public sealed class RuntimeOrchestrationTests
|
||||
"io_keep_cycles": 4,
|
||||
"acc_limit": 0.5,
|
||||
"jerk_limit": 0.25,
|
||||
"adapt_icsp_try_num": 3
|
||||
"adapt_icsp_try_num": 3,
|
||||
"speed_ratio": 0.65
|
||||
},
|
||||
"flying_shots": {}
|
||||
}
|
||||
@@ -907,6 +908,7 @@ public sealed class RuntimeOrchestrationTests
|
||||
var profile = Assert.IsType<RobotProfile>(runtime.LastRobotProfile);
|
||||
Assert.Equal(14.905, profile.JointLimits[2].AccelerationLimit, precision: 3);
|
||||
Assert.Equal(62.115, profile.JointLimits[2].JerkLimit, precision: 3);
|
||||
Assert.Equal(0.65, runtime.GetSpeedRatio(), precision: 6);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user