|
@@ -88,7 +88,6 @@ namespace DiffIKDemo
|
|
|
|
|
|
private StopWatchTimer _timer = new StopWatchTimer(); //new PerformanceCounterTimer()
|
|
|
private int _updateCount = 0;
|
|
|
- private bool _isBeginRealTimeControl;
|
|
|
|
|
|
private static readonly object _lock = new object();
|
|
|
private volatile bool _isOfflineRunning = false;
|
|
@@ -205,8 +204,6 @@ namespace DiffIKDemo
|
|
|
|
|
|
_robotModule.NotifyRobotStateUpdate += OnRobotStateUpdate;
|
|
|
_robotModule.NotifyCommandSuccessStateUpdate += OnCommandSuccessState;
|
|
|
- _robotModule.NotifyRealTimeControlStepUpdate += OnRealTimeControlStepUpdate;
|
|
|
- _robotModule.NotifyIsRealTimeControlUpdate += OnIsRealTimeControlUpdate;
|
|
|
_robotModule.NotifyMotionFinish += OnUpdateMotionExecutionStatus;
|
|
|
|
|
|
_robotModule.NotifyLogWrite += OnLogWrite;
|
|
@@ -214,13 +211,9 @@ namespace DiffIKDemo
|
|
|
|
|
|
_robotModule.StartGetCurrentRobotState();
|
|
|
_robotModule.StartGetCommandSuccessState();
|
|
|
- _robotModule.StartGetRealTimeControlStep();
|
|
|
- _robotModule.StartGetIsRealTimeControl();
|
|
|
-
|
|
|
- //SetRobotControlInfo();
|
|
|
|
|
|
DHxMatePro3 = new double[,]
|
|
|
- {
|
|
|
+ {
|
|
|
{0, -Math.PI / 2 , 0.3426048, 0},
|
|
|
{0, Math.PI / 2 , 0, 0},
|
|
|
{0, -Math.PI / 2 , 0.3929383, 0},
|
|
@@ -228,7 +221,7 @@ namespace DiffIKDemo
|
|
|
{0, -Math.PI / 2 , 0.3655720, 0},
|
|
|
{0, Math.PI / 2 , 0, 0},
|
|
|
{0, 0 , 0.2509087, 0}
|
|
|
- };
|
|
|
+ };
|
|
|
_Kinematics.SetDHParameter(DHxMatePro3);
|
|
|
}
|
|
|
|
|
@@ -239,8 +232,6 @@ namespace DiffIKDemo
|
|
|
/// <param name="e"></param>
|
|
|
private void OnBtnDisConnectRobotClick(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- _robotModule.StopGetIsRealTimeControl();
|
|
|
- _robotModule.StopGetRealTimeControlStep();
|
|
|
_robotModule.StopGetCurrentRobotState();
|
|
|
_robotModule.StopGetCommandSuccessState();
|
|
|
|
|
@@ -249,8 +240,6 @@ namespace DiffIKDemo
|
|
|
|
|
|
_robotModule.NotifyRobotStateUpdate -= OnRobotStateUpdate;
|
|
|
_robotModule.NotifyCommandSuccessStateUpdate -= OnCommandSuccessState;
|
|
|
- _robotModule.NotifyRealTimeControlStepUpdate -= OnRealTimeControlStepUpdate;
|
|
|
- _robotModule.NotifyIsRealTimeControlUpdate -= OnIsRealTimeControlUpdate;
|
|
|
_robotModule.NotifyMotionFinish -= OnUpdateMotionExecutionStatus;
|
|
|
_robotModule.NotifyLogWrite -= OnLogWrite;
|
|
|
_robotModule.NotifyError -= OnErrorOccur;
|
|
@@ -654,8 +643,7 @@ namespace DiffIKDemo
|
|
|
{
|
|
|
_robotModule.StartDragControl(EnumDragSpace.JOINT_DRAG, EnumDragType.FREELY);
|
|
|
}
|
|
|
- else if (_motionType == EnumRobotMotionType.CallBackJointPosition
|
|
|
- || _motionType == EnumRobotMotionType.CallBackCartPosition) // 实时运动
|
|
|
+ else if (_motionType == EnumRobotMotionType.CallBackJointPosition || _motionType == EnumRobotMotionType.CallBackCartPosition) // 实时运动
|
|
|
{
|
|
|
if (_motionType == EnumRobotMotionType.CallBackJointPosition)
|
|
|
{
|
|
@@ -669,6 +657,7 @@ namespace DiffIKDemo
|
|
|
|
|
|
// 笛卡尔实时运动时,用MoveJ先走到第一个点
|
|
|
_robotModule.RunOfflineWayPoints(EnumRobotMotionType.MoveJ, _firstWayPt, _speed);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 等待信号被设置
|
|
@@ -678,9 +667,7 @@ namespace DiffIKDemo
|
|
|
await Task.Delay(1);
|
|
|
// 离线运动走完了
|
|
|
// 重设运动,启动回调,可以开始塞数据了
|
|
|
- _robotModule.SetRobotRealTimeMotionType(_motionType);
|
|
|
- _robotModule.SetTrajectoryLength(_trajLen);
|
|
|
- _robotModule.StartRealTimeControl();
|
|
|
+ _robotModule.CreateRealTimeControl(_motionType);
|
|
|
//开个线程,每个一毫秒,更新一个数据
|
|
|
if (_realTimeUpdateDataThread == null || !_realTimeUpdateDataThread.IsAlive)
|
|
|
{
|
|
@@ -759,7 +746,7 @@ namespace DiffIKDemo
|
|
|
if (_robotModule != null)
|
|
|
{
|
|
|
_robotModule.StopDragControl();
|
|
|
- _robotModule.StopRealTimeControl();
|
|
|
+ _robotModule.DestroyRealTimeControl();
|
|
|
}
|
|
|
|
|
|
//关闭实时更新路点的线程
|
|
@@ -877,25 +864,6 @@ namespace DiffIKDemo
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void OnRealTimeControlStepUpdate(object sender, int e)
|
|
|
- {
|
|
|
- string str = e.ToString();
|
|
|
- str += "/";
|
|
|
- str += _updateCount.ToString();
|
|
|
- str += "/";
|
|
|
- str += _trajLen.ToString();
|
|
|
- // 更新界面上显示的数据
|
|
|
- Dispatcher.InvokeAsync(() =>
|
|
|
- {
|
|
|
- TextRealTimeControlStep.Text = str;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void OnIsRealTimeControlUpdate(object sender, bool e)
|
|
|
- {
|
|
|
- _isBeginRealTimeControl = e;
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 有错误
|
|
|
/// </summary>
|
|
@@ -945,17 +913,20 @@ namespace DiffIKDemo
|
|
|
_timer.Start();
|
|
|
while (true)
|
|
|
{
|
|
|
- if (_isBeginRealTimeControl && _timer.Duration >= 1000)
|
|
|
+ if (_timer.Duration >= 1000)
|
|
|
{
|
|
|
//因为达到了1毫秒的时刻,所以要重新记录开始的时间点
|
|
|
_timer.Stop();
|
|
|
_timer.Start();
|
|
|
RobotWayPointData wayPt = _wayPtsList[_updateCount];
|
|
|
+ _robotModule.EnableRunRealTimeControl = true;
|
|
|
_robotModule.UpdateRealTimeWayPt(wayPt);
|
|
|
_updateCount++;
|
|
|
|
|
|
+ // 数据全部用完,可以停止回调线程了
|
|
|
if (_updateCount >= _trajLen)
|
|
|
{
|
|
|
+ _robotModule.EnableRunRealTimeControl = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1150,29 +1121,29 @@ namespace DiffIKDemo
|
|
|
private void SelectJointAngle(int index, ref RobotWayPointData wayPt)
|
|
|
{
|
|
|
JointPos jointPos = new JointPos();
|
|
|
- CartesianPos cartPosSelectJointAngle = new CartesianPos();
|
|
|
+ CartesianPos cartPos = new CartesianPos();
|
|
|
switch (index)
|
|
|
{
|
|
|
case 0:
|
|
|
jointPos.JointAngle = _qHome;
|
|
|
- _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPosSelectJointAngle.Position);
|
|
|
+ _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPos.Position);
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
jointPos.JointAngle = _qDrag;
|
|
|
- _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPosSelectJointAngle.Position);
|
|
|
+ _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPos.Position);
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
jointPos.JointAngle = _qEnd;
|
|
|
- _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPosSelectJointAngle.Position);
|
|
|
+ _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPos.Position);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
wayPt.JointPos = jointPos;
|
|
|
- wayPt.CartPos = cartPosSelectJointAngle;
|
|
|
+ wayPt.CartPos = cartPos;
|
|
|
}
|
|
|
|
|
|
#endregion private funcs
|
|
@@ -1243,11 +1214,11 @@ namespace DiffIKDemo
|
|
|
}
|
|
|
|
|
|
JointPos jointPos = new JointPos();
|
|
|
- CartesianPos cartPosTextBoxRobotJointAngleKeyUp = new CartesianPos();
|
|
|
+ CartesianPos cartPos = new CartesianPos();
|
|
|
jointPos.JointAngle = jointAngle;
|
|
|
- _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPosTextBoxRobotJointAngleKeyUp.Position);
|
|
|
+ _robotModule.GetCartPose(jointPos.JointAngle, RokaeSegmentFrame.kEndEffector, ref cartPos.Position);
|
|
|
_moveJTargetWayPt.JointPos = jointPos;
|
|
|
- _moveJTargetWayPt.CartPos = cartPosTextBoxRobotJointAngleKeyUp;
|
|
|
+ _moveJTargetWayPt.CartPos = cartPos;
|
|
|
}
|
|
|
}
|
|
|
}
|