棒材增加了输出姿态角的限制
This commit is contained in:
parent
818aa764fb
commit
00de98b6be
@ -5,7 +5,11 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QBrush>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QLineF>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPolygonF>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -60,20 +64,6 @@ bool IsAngleInRange(double angle, double rangeMin, double rangeMax)
|
|||||||
return a + kEpsilon >= minAngle || a - kEpsilon <= maxAngle;
|
return a + kEpsilon >= minAngle || a - kEpsilon <= maxAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
double DistanceToAngleRange(double angle, double rangeMin, double rangeMax)
|
|
||||||
{
|
|
||||||
if (IsAngleInRange(angle, rangeMin, rangeMax)) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double a = NormalizeAngleDeg(angle);
|
|
||||||
const double minAngle = NormalizeAngleDeg(rangeMin);
|
|
||||||
const double maxAngle = NormalizeAngleDeg(rangeMax);
|
|
||||||
const double toMin = std::fabs(NormalizeAngleDeg(a - minAngle));
|
|
||||||
const double toMax = std::fabs(NormalizeAngleDeg(a - maxAngle));
|
|
||||||
return toMin < toMax ? toMin : toMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AxialDirectionAdjustment
|
struct AxialDirectionAdjustment
|
||||||
{
|
{
|
||||||
HECPoint3D direction;
|
HECPoint3D direction;
|
||||||
@ -104,12 +94,7 @@ AxialDirectionAdjustment AdjustAxialDirectionByRange(const HECPoint3D& axialDir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const double flippedAngle = NormalizeAngleDeg(result.inputAngle + 180.0);
|
const double flippedAngle = NormalizeAngleDeg(result.inputAngle + 180.0);
|
||||||
const bool flippedInRange = IsAngleInRange(flippedAngle, rangeMin, rangeMax);
|
if (IsAngleInRange(flippedAngle, rangeMin, rangeMax)) {
|
||||||
const bool flippedCloser =
|
|
||||||
DistanceToAngleRange(flippedAngle, rangeMin, rangeMax)
|
|
||||||
< DistanceToAngleRange(result.inputAngle, rangeMin, rangeMax);
|
|
||||||
|
|
||||||
if (flippedInRange || flippedCloser) {
|
|
||||||
result.direction = axialDir * -1.0;
|
result.direction = axialDir * -1.0;
|
||||||
result.outputAngle = flippedAngle;
|
result.outputAngle = flippedAngle;
|
||||||
result.flipped = true;
|
result.flipped = true;
|
||||||
@ -192,6 +177,42 @@ void ApplyToolRotationToEyeAxes(IHandEyeCalib& handEyeCalib,
|
|||||||
+ oldZ * toolRotation.at(2, 2)).normalized();
|
+ oldZ * toolRotation.at(2, 2)).normalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawCanvasArrow(PointCloudCanvas& canvas,
|
||||||
|
double startX,
|
||||||
|
double startY,
|
||||||
|
double endX,
|
||||||
|
double endY,
|
||||||
|
const QColor& color,
|
||||||
|
int penWidth)
|
||||||
|
{
|
||||||
|
if (!canvas.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF line(QPointF(canvas.project(startX, startY)),
|
||||||
|
QPointF(canvas.project(endX, endY)));
|
||||||
|
if (line.length() < 1.0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainter painter(&canvas.image());
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||||
|
painter.setBrush(QBrush(color));
|
||||||
|
painter.drawLine(line);
|
||||||
|
|
||||||
|
const double arrowSize = 14.0;
|
||||||
|
const double angle = std::atan2(line.dy(), line.dx());
|
||||||
|
const QPointF arrowP1 = line.p2() - QPointF(std::cos(angle - M_PI / 6.0) * arrowSize,
|
||||||
|
std::sin(angle - M_PI / 6.0) * arrowSize);
|
||||||
|
const QPointF arrowP2 = line.p2() - QPointF(std::cos(angle + M_PI / 6.0) * arrowSize,
|
||||||
|
std::sin(angle + M_PI / 6.0) * arrowSize);
|
||||||
|
|
||||||
|
QPolygonF arrowHead;
|
||||||
|
arrowHead << line.p2() << arrowP1 << arrowP2;
|
||||||
|
painter.drawPolygon(arrowHead);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DetectPresenter::DetectPresenter(/* args */)
|
DetectPresenter::DetectPresenter(/* args */)
|
||||||
@ -318,13 +339,18 @@ int DetectPresenter::DetectRod(
|
|||||||
// 绘制棒材中心点(红色)
|
// 绘制棒材中心点(红色)
|
||||||
canvas.drawPoint(rod.center.x, rod.center.y, QColor(255, 0, 0), 6);
|
canvas.drawPoint(rod.center.x, rod.center.y, QColor(255, 0, 0), 6);
|
||||||
|
|
||||||
// 绘制轴向方向线(红色)
|
// 绘制轴向箭头(黄色)
|
||||||
double len = 60;
|
const double axialXYNorm = std::hypot(axialDir.x, axialDir.y);
|
||||||
double ax0 = rod.center.x - len * axialDir.x;
|
if (axialXYNorm > 1e-9) {
|
||||||
double ay0 = rod.center.y - len * axialDir.y;
|
const double axisUx = axialDir.x / axialXYNorm;
|
||||||
double ax1 = rod.center.x + len * axialDir.x;
|
const double axisUy = axialDir.y / axialXYNorm;
|
||||||
double ay1 = rod.center.y + len * axialDir.y;
|
const double axisHalfLen = std::max(60.0, algorithmParams.rodParam.rodLen * 0.25);
|
||||||
canvas.drawLine(ax0, ay0, ax1, ay1, QColor(255, 0, 0), 2);
|
const double ax0 = rod.center.x - axisHalfLen * axisUx;
|
||||||
|
const double ay0 = rod.center.y - axisHalfLen * axisUy;
|
||||||
|
const double ax1 = rod.center.x + axisHalfLen * axisUx;
|
||||||
|
const double ay1 = rod.center.y + axisHalfLen * axisUy;
|
||||||
|
DrawCanvasArrow(canvas, ax0, ay0, ax1, ay1, QColor(255, 220, 0), 3);
|
||||||
|
}
|
||||||
|
|
||||||
// 绘制起点到终点线段(绿色)
|
// 绘制起点到终点线段(绿色)
|
||||||
canvas.drawLine(rod.startPt.x, rod.startPt.y, rod.endPt.x, rod.endPt.y, QColor(0, 255, 0), 2);
|
canvas.drawLine(rod.startPt.x, rod.startPt.y, rod.endPt.x, rod.endPt.y, QColor(0, 255, 0), 2);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#define RODANDBARPOSITION_APP_NAME "棒材定位"
|
#define RODANDBARPOSITION_APP_NAME "棒材定位"
|
||||||
|
|
||||||
#define RODANDBARPOSITION_VERSION_STRING "1.1.4"
|
#define RODANDBARPOSITION_VERSION_STRING "1.1.4"
|
||||||
#define RODANDBARPOSITION_BUILD_STRING "3"
|
#define RODANDBARPOSITION_BUILD_STRING "4"
|
||||||
#define RODANDBARPOSITION_FULL_VERSION_STRING "V" RODANDBARPOSITION_VERSION_STRING "_" RODANDBARPOSITION_BUILD_STRING
|
#define RODANDBARPOSITION_FULL_VERSION_STRING "V" RODANDBARPOSITION_VERSION_STRING "_" RODANDBARPOSITION_BUILD_STRING
|
||||||
|
|
||||||
// 获取版本信息的便捷函数
|
// 获取版本信息的便捷函数
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
# 1.1.4 2026-06-26
|
# 1.1.4 2026-06-26
|
||||||
|
## build_4 7-1
|
||||||
|
1. 对输出姿态角做了范围限制
|
||||||
|
|
||||||
|
|
||||||
## build_3
|
## build_3
|
||||||
1. 修复工具的欧拉角顺序与协议的欧拉角顺序复用的问题
|
1. 修复工具的欧拉角顺序与协议的欧拉角顺序复用的问题
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "ToolExtrinsicWidget.h"
|
#include "ToolExtrinsicWidget.h"
|
||||||
#include "PathManager.h"
|
#include "PathManager.h"
|
||||||
#include "VrLog.h"
|
#include "VrLog.h"
|
||||||
|
#include <QAbstractSpinBox>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -50,6 +51,11 @@ DialogAlgoArg::DialogAlgoArg(QWidget *parent)
|
|||||||
, m_toolExtrinsicWidget(nullptr)
|
, m_toolExtrinsicWidget(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
const QList<QAbstractSpinBox*> spinBoxes = findChildren<QAbstractSpinBox*>();
|
||||||
|
for (QAbstractSpinBox* spinBox : spinBoxes) {
|
||||||
|
spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
|
spinBox->setKeyboardTracking(false);
|
||||||
|
}
|
||||||
setWindowTitle("算法参数设置");
|
setWindowTitle("算法参数设置");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user