新版布局
This commit is contained in:
+27
-5
@@ -172,12 +172,30 @@ void AppContext::triggerEstop()
|
||||
|
||||
void AppContext::setMode(Mode m)
|
||||
{
|
||||
// 洗消作业期间强制机械臂模式:作业时末端要自动俯仰摆动,而 Arm_ControlCmd1 的
|
||||
// 使能位就挂在这个模式上。遥控器**每帧**都会调进来,所以这个覆盖只能放在这里——
|
||||
// 放到 sendWashStart 之类的地方,会被下一帧遥控器报文冲掉。
|
||||
if (washRunning) m = Mode::Arm;
|
||||
|
||||
if (mode == m) return;
|
||||
mode = m;
|
||||
emit modeChanged(m);
|
||||
if (m_comm) m_comm->setArmMode(m == Mode::Arm); // 同步到 Arm_ControlCmd1 的 Arm_modeCmd/Arm_enable
|
||||
}
|
||||
|
||||
void AppContext::setWashRunning(bool on)
|
||||
{
|
||||
if (on == washRunning) return;
|
||||
washRunning = on;
|
||||
|
||||
if (on) {
|
||||
m_modeBeforeWash = mode;
|
||||
setMode(Mode::Arm); // 覆盖生效,进入洗消状态
|
||||
} else {
|
||||
setMode(m_modeBeforeWash); // 作业结束,还原作业前的模式
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== 遥控器(24 字节二进制帧) =====================
|
||||
void AppContext::onRcFrame(const RcFrame& f)
|
||||
{
|
||||
@@ -236,7 +254,7 @@ void AppContext::applyRcArm(const RcFrame& f)
|
||||
const int d = allowed ? axisDir(vals[i]) : 0;
|
||||
if (d == m_rcAxisDir[i]) continue; // 方向未变,不重复发包
|
||||
m_rcAxisDir[i] = d;
|
||||
m_comm->sendArmMove(QString::fromLatin1(kArmAxes[i]), d);
|
||||
m_comm->sendArmMoveRc(QString::fromLatin1(kArmAxes[i]), d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,11 +271,11 @@ void AppContext::sendChassisCommand()
|
||||
else if (m_rcSteerDir < 0) turn = "left";
|
||||
|
||||
if (dir == "stop" && turn.isEmpty()) {
|
||||
m_comm->sendChassisMove("stop", 0);
|
||||
m_comm->sendChassisMoveRc("stop", 0);
|
||||
return;
|
||||
}
|
||||
const double spd = (dir == "stop") ? 0.0 : getDouble(keySpeed(), 4.5);
|
||||
m_comm->sendChassisMove(dir, spd, turn);
|
||||
m_comm->sendChassisMoveRc(dir, spd, turn);
|
||||
}
|
||||
|
||||
void AppContext::updateRcDriving()
|
||||
@@ -270,6 +288,9 @@ void AppContext::updateRcDriving()
|
||||
|
||||
if (driving == m_rcDriving) return;
|
||||
m_rcDriving = driving;
|
||||
// 先告诉通信层再发信号:页面收到 rcDrivingChanged(false) 会重发按住的方向,
|
||||
// 那一下必须畅通(让位标志得已经落下)
|
||||
if (m_comm) m_comm->setRcActive(driving);
|
||||
emit rcDrivingChanged(driving);
|
||||
}
|
||||
|
||||
@@ -280,15 +301,16 @@ void AppContext::onRcLinkChanged(bool ok)
|
||||
if (!ok) {
|
||||
// 链路中断:撤销所有遥控器动作,否则最后一条指令会被一直挂住。
|
||||
// 不动急停状态——丢包导致的 bit4 读为 0 不应被当成遥控器下发的复位。
|
||||
// 这里必须走 Rc 入口:此刻 rcActive 还是真,走面板入口会被让位挡掉。
|
||||
if (m_rcGearDir != 0 || m_rcSteerDir != 0) {
|
||||
m_rcGearDir = 0;
|
||||
m_rcSteerDir = 0;
|
||||
m_comm->sendChassisMove("stop", 0);
|
||||
m_comm->sendChassisMoveRc("stop", 0);
|
||||
}
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (m_rcAxisDir[i] == 0) continue;
|
||||
m_rcAxisDir[i] = 0;
|
||||
m_comm->sendArmMove(QString::fromLatin1(kArmAxes[i]), 0);
|
||||
m_comm->sendArmMoveRc(QString::fromLatin1(kArmAxes[i]), 0);
|
||||
}
|
||||
}
|
||||
updateRcDriving();
|
||||
|
||||
Reference in New Issue
Block a user