补充调试页接口测试样例

This commit is contained in:
zhangshun
2026-06-01 17:38:29 +08:00
parent 3df459cb33
commit 12310de782

View File

@@ -123,6 +123,33 @@
margin-top: 16px;
}
.sample-bar {
display: grid;
gap: 10px;
margin-top: 16px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(255, 255, 255, 0.72);
}
.sample-row {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
select {
width: 100%;
border: 1px solid var(--line);
border-radius: 12px;
padding: 11px 12px;
font-size: 14px;
color: var(--text);
background: #fff;
}
button {
border: 0;
border-radius: 12px;
@@ -268,10 +295,28 @@
"req_param": {}
}</textarea>
<div class="sample-bar">
<label for="sample-select">接口测试样例</label>
<div class="sample-row">
<select id="sample-select">
<option value="listRobots">机器人列表 Cmd_ListRobots</option>
<option value="kinematicsForwardZero">运动学正解 Cmd_Kinematics_forward_pose_str</option>
<option value="kinematicsForwardAllJoints">全关节正解 Cmd_Kinematics_forward_all_joints</option>
<option value="spcBasic">SPC 计算 Cmd_Spc</option>
<option value="fourBarValid">四连杆有效样例 Cmd_FourBar_CrankSlider</option>
<option value="fourBarInvalid">四连杆异常样例 Cmd_FourBar_CrankSlider</option>
<option value="quadrupedPoints">四足姿态点位 Cmd_QuadrupedRobot_CalculateAllPointsFromMotorAngles</option>
<option value="quadrupedForwardGait">四足步态正解 Cmd_QuadrupedRobot_PerformForwardKinematics</option>
</select>
</div>
<div class="sample-row">
<button class="secondary" id="sample-btn" type="button">填充选中样例</button>
</div>
</div>
<div class="actions">
<button class="primary" id="init-btn" type="button">初始化 WASM</button>
<button class="primary" id="run-btn" type="button">发送请求</button>
<button class="secondary" id="sample-btn" type="button">填充四杆样例</button>
<button class="secondary" id="clear-btn" type="button">清空输出</button>
</div>
@@ -321,11 +366,174 @@
const requestStatus = document.getElementById("request-status");
const requestBox = document.getElementById("request");
const output = document.getElementById("output");
const sampleSelect = document.getElementById("sample-select");
const metaSuccess = document.getElementById("meta-success");
const metaCode = document.getElementById("meta-code");
const metaCmd = document.getElementById("meta-cmd");
const metaReq = document.getElementById("meta-req");
const requestSamples = {
listRobots: {
msg: "list robots after init",
req_code: "CASE_LIST_001",
req_from: "local_debug",
req_cmd: "Cmd_ListRobots",
req_param: {
detail: true
}
},
kinematicsForwardZero: {
msg: "fk zero pose",
req_code: "CASE_FK_001",
req_from: "local_debug",
req_cmd: "Cmd_Kinematics_forward_pose_str",
req_param: {
robot_uuid: "abb_irb120_3_58",
q_init_str: "0,0,0,0,0,0"
}
},
kinematicsForwardAllJoints: {
msg: "fk all joints path",
req_code: "CASE_FK_ALL_001",
req_from: "local_debug",
req_cmd: "Cmd_Kinematics_forward_all_joints",
req_param: {
robot_uuid: "abb_irb120_3_58",
joints_str: "0,0,0,0,0,0;10,20,30,40,50,60"
}
},
spcBasic: {
msg: "spc basic 5x30",
req_code: "CASE_SPC_001",
req_from: "local_debug",
req_cmd: "Cmd_Spc",
req_param: {
n: 5,
k: 30,
usl: 1.7,
lsl: 1.5,
x: [
1.55, 1.58, 1.61, 1.6, 1.6, 1.58, 1.63, 1.63, 1.62, 1.63,
1.62, 1.63, 1.62, 1.59, 1.58, 1.58, 1.6, 1.61, 1.62, 1.63,
1.58, 1.64, 1.63, 1.62, 1.62, 1.62, 1.62, 1.63, 1.61, 1.57,
1.64, 1.62, 1.61, 1.6, 1.58, 1.57, 1.59, 1.61, 1.62, 1.63,
1.58, 1.61, 1.6, 1.62, 1.63, 1.6, 1.61, 1.64, 1.64, 1.63,
1.58, 1.6, 1.62, 1.63, 1.65, 1.62, 1.58, 1.59, 1.57, 1.58,
1.57, 1.57, 1.58, 1.59, 1.64, 1.61, 1.64, 1.62, 1.6, 1.59,
1.65, 1.62, 1.62, 1.6, 1.58, 1.57, 1.59, 1.57, 1.59, 1.62,
1.56, 1.57, 1.57, 1.61, 1.62, 1.56, 1.58, 1.59, 1.6, 1.62,
1.58, 1.6, 1.6, 1.62, 1.63, 1.58, 1.59, 1.6, 1.63, 1.62,
1.58, 1.59, 1.62, 1.63, 1.64, 1.58, 1.59, 1.62, 1.63, 1.61,
1.58, 1.59, 1.6, 1.61, 1.63, 1.57, 1.59, 1.61, 1.61, 1.62,
1.58, 1.58, 1.6, 1.61, 1.63, 1.62, 1.58, 1.58, 1.58, 1.57,
1.63, 1.59, 1.57, 1.58, 1.57, 1.58, 1.62, 1.61, 1.63, 1.61,
1.58, 1.57, 1.59, 1.6, 1.62, 1.62, 1.6, 1.6, 1.57, 1.57
]
}
},
fourBarValid: {
msg: "fourbar valid",
req_code: "CASE_FB_001",
req_from: "local_debug",
req_cmd: "Cmd_FourBar_CrankSlider",
req_param: {
L_AB: 0.5,
L_BS: 2.0,
S_OFS: 0.0,
angleDeg: 45.0
}
},
fourBarInvalid: {
msg: "fourbar invalid",
req_code: "CASE_FB_002",
req_from: "local_debug",
req_cmd: "Cmd_FourBar_CrankSlider",
req_param: {
L_AB: 0.0,
L_BS: 0.2,
S_OFS: 0.5,
angleDeg: 30.0
}
},
quadrupedPoints: {
msg: "quadruped points from motor angles",
req_code: "CASE_QP_001",
req_from: "local_debug",
req_cmd: "Cmd_QuadrupedRobot_CalculateAllPointsFromMotorAngles",
req_param: {
Param: {
LF: {
thigh_angle_deg: -37.4784578338516,
shank_angle_deg: -22.4917532451628,
ankle_angle_deg: 0.0
},
LH: {
thigh_angle_deg: -34.0564623655754,
shank_angle_deg: -22.1353106546916,
ankle_angle_deg: 0.0
},
RF: {
thigh_angle_deg: 34.0564623655754,
shank_angle_deg: 22.1353106546916,
ankle_angle_deg: 0.0
},
RH: {
thigh_angle_deg: 37.4784578338516,
shank_angle_deg: 22.4917532451628,
ankle_angle_deg: 0.0
}
}
}
},
quadrupedForwardGait: {
msg: "quadruped forward gait",
req_code: "CASE_QP_002",
req_from: "local_debug",
req_cmd: "Cmd_QuadrupedRobot_PerformForwardKinematics",
req_param: {
GaitInfo: {
GaitType: "trot",
Period: 0.8,
Frequency: 50.0,
StepTime: 0.02,
SupportTime: 0.4,
SwingTime: 0.4,
SupportRatio: 0.5,
SwingRatio: 0.5,
TotalFrames: 40,
TotalTime: 0.8
},
SystemParameters: {
A_x: 0.0,
A_y: 500.0,
L10: 300.0,
L20: 286.0,
L30: 55.0,
StepLength: 60.0,
StepHeight: 50.0,
X: 30.0,
DeltaX: 0.0,
L21: 70.0,
L22: 292.0,
L23: 80.0,
Beta1: 166.0,
BB2_BC_Angle: 3.3859387489,
C1_B_Length: 107.0,
CC1: 179.0,
L31: 32.0,
C2C3_Length: 32.0,
Lead: 10.0,
D1_L_Offset: 90.0,
D2_L_Offset: 50.0,
C4_D2_Offset: 18.0,
ThighMotorReduction: 1.0,
ShankMotorReduction: 1.0,
AnkleMotorReduction: 1.0
}
}
}
};
function escapeHtml(value) {
return value
.replaceAll("&", "&amp;")
@@ -403,19 +611,13 @@
return ptr;
}
function sampleFourBar() {
requestBox.value = JSON.stringify({
msg: "fourbar valid",
req_code: "CASE_FB_001",
req_from: "local_debug",
req_cmd: "Cmd_FourBar_CrankSlider",
req_param: {
L_AB: 0.5,
L_BS: 2.0,
S_OFS: 0.0,
angleDeg: 45.0
}
}, null, 2);
function loadSelectedSample() {
const selectedKey = sampleSelect.value;
const sample = requestSamples[selectedKey];
if (!sample) {
return;
}
requestBox.value = JSON.stringify(sample, null, 2);
}
async function ensureModule() {
@@ -481,7 +683,7 @@
document.getElementById("init-btn").addEventListener("click", initializeBusinessApi);
document.getElementById("run-btn").addEventListener("click", runRequest);
document.getElementById("sample-btn").addEventListener("click", sampleFourBar);
document.getElementById("sample-btn").addEventListener("click", loadSelectedSample);
document.getElementById("clear-btn").addEventListener("click", () => {
requestStatus.textContent = "等待操作";
resetMeta();
@@ -489,6 +691,7 @@
});
resetMeta();
loadSelectedSample();
</script>
</body>
</html>