qt折线图修改
This commit is contained in:
@@ -58,6 +58,8 @@ from .main import build_controller
|
||||
|
||||
|
||||
PLOT_POINTS = 180
|
||||
PLOT_FORCE_Y_MIN_N = 0.0
|
||||
PLOT_FORCE_Y_MAX_N = 3.0
|
||||
CURVE_COLOR = "#00E5FF"
|
||||
|
||||
|
||||
@@ -250,7 +252,7 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
|
||||
top = QHBoxLayout()
|
||||
top.setSpacing(8)
|
||||
title = QLabel("Gripper Demo 02")
|
||||
title = QLabel("Orisys 夹爪")
|
||||
title.setObjectName("Title")
|
||||
self.status_chip = QLabel("state=--")
|
||||
self.status_chip.setObjectName("StatusChip")
|
||||
@@ -295,18 +297,22 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
self.shear_force = MetricBox("最大切向力", "--")
|
||||
self.force_diff = MetricBox("左右差值", "--")
|
||||
self.force_pct_box = MetricBox("force_pct", "--")
|
||||
self.target_force_box = MetricBox("目标力", "--")
|
||||
self.speed_box = MetricBox("速度", "--")
|
||||
self.trigger_box = MetricBox("触发/武装", "--")
|
||||
self.contact_box = MetricBox("接触", "--")
|
||||
self.release_box = MetricBox("释放检测", "--")
|
||||
boxes = [
|
||||
self.left_force,
|
||||
self.right_force,
|
||||
self.shear_force,
|
||||
self.force_diff,
|
||||
self.force_pct_box,
|
||||
self.target_force_box,
|
||||
self.speed_box,
|
||||
self.trigger_box,
|
||||
self.contact_box,
|
||||
self.release_box,
|
||||
]
|
||||
for idx, box in enumerate(boxes):
|
||||
metrics_grid.addWidget(box, idx // 2, idx % 2)
|
||||
@@ -343,9 +349,22 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
self.plot.showGrid(x=False, y=True, alpha=0.12)
|
||||
self.plot.setLabel("bottom", "时间", units="s")
|
||||
self.plot.setLabel("left", "力", units="N")
|
||||
self.left_curve = self.plot.plot(pen=pg.mkPen(CURVE_COLOR, width=2), name="L")
|
||||
self.right_curve = self.plot.plot(pen=pg.mkPen("#ffb000", width=2), name="R")
|
||||
self.shear_curve = self.plot.plot(pen=pg.mkPen("#7ddc8a", width=2), name="Shear")
|
||||
self.plot.setYRange(PLOT_FORCE_Y_MIN_N, PLOT_FORCE_Y_MAX_N, padding=0)
|
||||
self.plot.setLimits(yMin=PLOT_FORCE_Y_MIN_N, yMax=PLOT_FORCE_Y_MAX_N)
|
||||
self.plot.enableAutoRange(axis=pg.ViewBox.YAxis, enable=False)
|
||||
self.plot.addLegend(offset=(-12, 12), labelTextColor="#d0d0d0")
|
||||
self.left_curve = self.plot.plot(
|
||||
pen=pg.mkPen(CURVE_COLOR, width=2),
|
||||
name="左法向 (N)",
|
||||
)
|
||||
self.right_curve = self.plot.plot(
|
||||
pen=pg.mkPen("#ffb000", width=2),
|
||||
name="右法向 (N)",
|
||||
)
|
||||
self.shear_curve = self.plot.plot(
|
||||
pen=pg.mkPen("#7ddc8a", width=2),
|
||||
name="最大切向 (N)",
|
||||
)
|
||||
|
||||
def start_control(self):
|
||||
if self.control_thread is not None and self.control_thread.is_alive():
|
||||
@@ -422,6 +441,10 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
str(status.get("force_pct", "--")),
|
||||
f"hold_pos={status.get('hold_pos')}",
|
||||
)
|
||||
self.target_force_box.set_value(
|
||||
str(status.get("adaptive_target_force", "--")),
|
||||
f"adaptive={int(bool(status.get('adaptive_grip_enabled')))}",
|
||||
)
|
||||
self.speed_box.set_value(
|
||||
str(status.get("speed_pct", "--")),
|
||||
"speed_pct",
|
||||
@@ -434,6 +457,10 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
str(int(bool(status.get("grip_contact")))),
|
||||
self._contact_text(status),
|
||||
)
|
||||
self.release_box.set_value(
|
||||
str(int(bool(status.get("release_armed")))),
|
||||
"release_armed",
|
||||
)
|
||||
|
||||
left_sample = status.get("left_sample") or {}
|
||||
right_sample = status.get("right_sample") or {}
|
||||
@@ -462,6 +489,8 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
f"max={fmt(status.get('max_normal'), unit)}",
|
||||
f"L_shear={fmt(status.get('left_shear'), shear_unit)}",
|
||||
f"R_shear={fmt(status.get('right_shear'), shear_unit)}",
|
||||
f"target={status.get('adaptive_target_force', '--')}",
|
||||
f"release_armed={int(bool(status.get('release_armed')))}",
|
||||
f"flow L/R={self._flow_text(left_sample)} / {self._flow_text(right_sample)}",
|
||||
]
|
||||
)
|
||||
@@ -475,6 +504,7 @@ class GripperDemo02Viewer(QMainWindow):
|
||||
self.left_curve.setData(x, data[:, 1])
|
||||
self.right_curve.setData(x, data[:, 2])
|
||||
self.shear_curve.setData(x, data[:, 3])
|
||||
self.plot.setYRange(PLOT_FORCE_Y_MIN_N, PLOT_FORCE_Y_MAX_N, padding=0)
|
||||
if len(x) >= 2:
|
||||
self.plot.setXRange(max(0.0, x[-1] - 6.0), max(6.0, x[-1]), padding=0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user