diff --git a/protos/cmvr/api/arm_command.proto b/protos/cmvr/api/arm_command.proto index d9a32ef..7d29f97 100644 --- a/protos/cmvr/api/arm_command.proto +++ b/protos/cmvr/api/arm_command.proto @@ -176,6 +176,7 @@ message JointState { repeated double velocity = 3; repeated double effort = 4; double timestamp = 5; + repeated double current = 6; // Motor current in mA. } message JointRequest { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4dd1d01..eca100b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1198,7 +1198,7 @@ void MainWindow::rebuildArmJointTables(const QStringList &jointNames) m_jointTable->setRowCount(jointNames.size()); for (int row = 0; row < jointNames.size(); ++row) { m_jointTable->setItem(row, 0, new QTableWidgetItem(jointNames.at(row))); - for (int column = 1; column < 4; ++column) + for (int column = 1; column < 5; ++column) m_jointTable->setItem(row, column, new QTableWidgetItem(QStringLiteral("--"))); } @@ -1463,6 +1463,7 @@ void MainWindow::updateTelemetry(const QString &deviceId, const QVariantList &jo continue; const double position = joint.value(QStringLiteral("position")).toDouble(); const double velocity = joint.value(QStringLiteral("velocity")).toDouble(); + const double current = joint.value(QStringLiteral("current")).toDouble(); const double acceleration = deltaSeconds > 0.0001 && m_previousJointVelocities.contains(nameItem->text()) ? (velocity - m_previousJointVelocities.value(nameItem->text())) / deltaSeconds @@ -1470,6 +1471,7 @@ void MainWindow::updateTelemetry(const QString &deviceId, const QVariantList &jo m_jointTable->item(row, 1)->setText(QString::number(position, 'f', 5)); m_jointTable->item(row, 2)->setText(QString::number(velocity, 'f', 5)); m_jointTable->item(row, 3)->setText(QString::number(acceleration, 'f', 4)); + m_jointTable->item(row, 4)->setText(QString::number(current, 'f', 0)); if (m_motionTable) { for (int targetRow = 0; targetRow < m_motionTable->rowCount(); ++targetRow) { QTableWidgetItem *targetName = m_motionTable->item(targetRow, 0); diff --git a/src/mainwindow_ui.cpp b/src/mainwindow_ui.cpp index 614442b..f884539 100644 --- a/src/mainwindow_ui.cpp +++ b/src/mainwindow_ui.cpp @@ -1404,8 +1404,10 @@ QWidget *MainWindow::createArmPage() connect(m_urdfViewer, &UrdfViewerWidget::logMessage, this, &MainWindow::appendLog); + m_jointTable->setColumnCount(5); m_jointTable->setHorizontalHeaderLabels({QStringLiteral("关节"), QStringLiteral("位置 rad"), - QStringLiteral("速度 rad/s"), QStringLiteral("加速度 rad/s²")}); + QStringLiteral("速度 rad/s"), QStringLiteral("加速度 rad/s²"), + QStringLiteral("电流 mA")}); m_jointTable->setAlternatingRowColors(true); m_jointTable->setEditTriggers(QAbstractItemView::NoEditTriggers); m_jointTable->setSelectionMode(QAbstractItemView::NoSelection); diff --git a/src/robotclient.cpp b/src/robotclient.cpp index 2f80dea..3114c36 100644 --- a/src/robotclient.cpp +++ b/src/robotclient.cpp @@ -2774,6 +2774,7 @@ private: joint.insert(QStringLiteral("position"), position); joint.insert(QStringLiteral("velocity"), 0.22 * qCos(phase)); joint.insert(QStringLiteral("effort"), 0.4 + 0.3 * qAbs(qSin(phase * 0.7))); + joint.insert(QStringLiteral("current"), 320.0 + 180.0 * qAbs(qSin(phase * 0.9))); joints.append(joint); } QVariantMap pose; @@ -3399,6 +3400,7 @@ private: joint.insert(QStringLiteral("position"), i < jointState.position_size() ? jointState.position(i) : 0.0); joint.insert(QStringLiteral("velocity"), i < jointState.velocity_size() ? jointState.velocity(i) : 0.0); joint.insert(QStringLiteral("effort"), i < jointState.effort_size() ? jointState.effort(i) : 0.0); + joint.insert(QStringLiteral("current"), i < jointState.current_size() ? jointState.current(i) : 0.0); joints.append(joint); } const auto &tcp = robotState.actual_tcp_pose();