|
|
@@ -47,7 +47,6 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
ICalibrationService _calibrationService;
|
|
|
ICameraService _cameraService;
|
|
|
IProductService _productService;
|
|
|
- CoordinateTransformer local=null;
|
|
|
|
|
|
#region 属性
|
|
|
|
|
|
@@ -301,10 +300,12 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
public CameraInfo SelectedCamera
|
|
|
{
|
|
|
get { return _SelectedCamera; }
|
|
|
- set { SetProperty(ref _SelectedCamera, value);
|
|
|
- if (value!=null)
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _SelectedCamera, value);
|
|
|
+ if (value != null)
|
|
|
{
|
|
|
- if(Camera!=null)
|
|
|
+ if (Camera != null)
|
|
|
{
|
|
|
if (Camera.IsGrabbing)
|
|
|
{
|
|
|
@@ -344,7 +345,9 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
public bool IsLeftDrawerOpen
|
|
|
{
|
|
|
get { return _IsLeftDrawerOpen; }
|
|
|
- set { SetProperty(ref _IsLeftDrawerOpen, value);
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _IsLeftDrawerOpen, value);
|
|
|
if (!value)
|
|
|
{
|
|
|
if (IsGrap)
|
|
|
@@ -355,7 +358,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private int _Inhal=1;
|
|
|
+ private int _Inhal = 1;
|
|
|
public int Inhal
|
|
|
{
|
|
|
get { return _Inhal; }
|
|
|
@@ -429,7 +432,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
private DelegateCommand _StartGrabbingCommand;
|
|
|
public DelegateCommand StartGrabbingCommand =>
|
|
|
- _StartGrabbingCommand ?? (_StartGrabbingCommand = new DelegateCommand(ExecuteStartGrabbingCommand, CanExecuteStartGrabbingCommand).ObservesProperty(() => IsGrap).ObservesProperty(()=> SelectedCamera));
|
|
|
+ _StartGrabbingCommand ?? (_StartGrabbingCommand = new DelegateCommand(ExecuteStartGrabbingCommand, CanExecuteStartGrabbingCommand).ObservesProperty(() => IsGrap).ObservesProperty(() => SelectedCamera));
|
|
|
|
|
|
private DelegateCommand _StopGrabbingCommand;
|
|
|
public DelegateCommand StopGrabbingCommand =>
|
|
|
@@ -455,7 +458,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
private DelegateCommand _GoPickCommand;
|
|
|
public DelegateCommand GoPickCommand =>
|
|
|
- _GoPickCommand ?? (_GoPickCommand = new DelegateCommand(ExecuteGoPickCommand, CanExecuteCommandGoPickCommandName).ObservesProperty(()=>SelectedPoint));
|
|
|
+ _GoPickCommand ?? (_GoPickCommand = new DelegateCommand(ExecuteGoPickCommand, CanExecuteCommandGoPickCommandName).ObservesProperty(() => SelectedPoint));
|
|
|
|
|
|
private DelegateCommand _GoRepositionCommand;
|
|
|
public DelegateCommand GoRepositionCommand =>
|
|
|
@@ -465,7 +468,11 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
public DelegateCommand TakeProductPhotoCommand =>
|
|
|
_TakeProductPhotoCommand ?? (_TakeProductPhotoCommand = new DelegateCommand(ExecuteTakeProductPhotoCommand, CanExecuteCommandGoPickCommandName).ObservesProperty(() => SelectedPoint));
|
|
|
|
|
|
-
|
|
|
+ private DelegateCommand _TakeProductCommand;
|
|
|
+ public DelegateCommand TakeProductCommand =>
|
|
|
+ _TakeProductCommand ?? (_TakeProductCommand = new DelegateCommand(ExecuteTakeProductCommand, CanExecuteCommandGoPickCommandName).ObservesProperty(() => SelectedPoint));
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 事件
|
|
|
@@ -660,9 +667,9 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
if (SelectedIndex == 4)
|
|
|
{
|
|
|
//如果local为空,则必须先通过相机定位产品,否则无法示教锁付点位
|
|
|
- if (local == null)
|
|
|
+ if (toolCoord == null)
|
|
|
{
|
|
|
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "当前模式不允许直接示教锁付点位,请先通过相机定位产品!", Duration = 1 });
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "当前模式不允许直接示教贴敷点位,请先通过相机定位产品和定位辅料!", Duration = 1 });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -674,12 +681,13 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
var curpos1 = await Robot.GetRobotPosAsync();
|
|
|
//将当前点位转换为产品Local坐标系下的点位
|
|
|
- var localPoint = local.ToNewCoord(curpos1.X, curpos1.Y);
|
|
|
- SelectedPoint.X_Position = (float)localPoint[0];
|
|
|
- SelectedPoint.Y_Position = (float)localPoint[1];
|
|
|
+ SelectedPoint.X_Position = (float)curpos1.X;
|
|
|
+ SelectedPoint.Y_Position = (float)curpos1.Y;
|
|
|
SelectedPoint.Z_Position_Start = curpos1.Z;
|
|
|
SelectedPoint.U_Position = curpos1.U;
|
|
|
SelectedPoint.R_Position = curpos1.V;
|
|
|
+ SelectProduct.FixedUpCameraTempletAngle = _FixedUpCameraTempletAngle;
|
|
|
+ SelectProduct.MoveDownCamerTempletAngle = _MoveCameraTempletAngle;
|
|
|
_eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
return;
|
|
|
}
|
|
|
@@ -1041,7 +1049,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
/// </summary>
|
|
|
void ExecuteStopGrabbingCommand()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if (Camera != null)
|
|
|
Camera.StopGrabbing();
|
|
|
IsGrap = false;
|
|
|
@@ -1109,7 +1117,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.WriteLogError("附加轴点动+时出错!", ex);
|
|
|
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg =ex.Message, Duration = 0.4 });
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 0.4 });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1223,11 +1231,11 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
};
|
|
|
await Robot.CalibMotionAsync(rpoint, 0);
|
|
|
|
|
|
- await Robot.CalibParameAsync(new PickInfo() { Inhal= Inhal,Blow=1},20,20,true,200,200);
|
|
|
+ await Robot.CalibParameAsync(new PickInfo() { Inhal = Inhal, Blow = 1 }, 20, 20, true, 200, 200);
|
|
|
//打开吸真空
|
|
|
await Robot.CalibOutIOAsync(true);
|
|
|
|
|
|
- await Task.Delay(500);
|
|
|
+ await Task.Delay(500);
|
|
|
|
|
|
rpoint.Z = 0;
|
|
|
await Robot.CalibMotionAsync(rpoint, 0);
|
|
|
@@ -1254,6 +1262,9 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
|
|
|
|
|
|
ToolCoord toolCoord = null;
|
|
|
+ double _FixedUpCameraTempletAngle = 0;
|
|
|
+ double _MoveCameraTempletAngle = 0;
|
|
|
+ PointF _PutPoint = new PointF();
|
|
|
/// <summary>
|
|
|
/// 去二次定位
|
|
|
/// </summary>
|
|
|
@@ -1322,12 +1333,9 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (visionResults[0].IsSucceed && visionResults[1].IsSucceed)
|
|
|
{
|
|
|
- float tool1X = (float)(visionResults[0].X - visionResults[0].X);
|
|
|
- float tool1Y = (float)(visionResults[0].Y - visionResults[0].Y);
|
|
|
- float tool2X = (float)(visionResults[1].Y - visionResults[1].Y);
|
|
|
- float tool2Y = (float)(visionResults[1].Y - visionResults[1].Y);
|
|
|
- float toolX = (tool1X + tool2X) / 2;
|
|
|
- float toolY = (tool1Y + tool2Y) / 2;
|
|
|
+ float toolX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
|
+ float toolY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
|
+ _FixedUpCameraTempletAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
|
toolCoord = new ToolCoord();
|
|
|
toolCoord.SetTool(toolX, toolY);
|
|
|
_eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "视觉定位成功!", Duration = 0.4 });
|
|
|
@@ -1435,12 +1443,10 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
var visionResults = await Task.WhenAll(task1, task2);
|
|
|
if (visionResults[0].IsSucceed && visionResults[1].IsSucceed)
|
|
|
{
|
|
|
- float tool1X = (float)(visionResults[0].X - visionResults[0].X);
|
|
|
- float tool1Y = (float)(visionResults[0].Y - visionResults[0].Y);
|
|
|
- float tool2X = (float)(visionResults[1].Y - visionResults[1].Y);
|
|
|
- float tool2Y = (float)(visionResults[1].Y - visionResults[1].Y);
|
|
|
- float toolX = (tool1X + tool2X) / 2;
|
|
|
- float toolY = (tool1Y + tool2Y) / 2;
|
|
|
+ float centerX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
|
+ float centerY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
|
+ _MoveCameraTempletAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
|
+ _PutPoint = new PointF(centerX, centerY);
|
|
|
|
|
|
if (DialogHost.IsDialogOpen("RootDialog"))
|
|
|
{
|
|
|
@@ -1471,6 +1477,79 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 执行产品贴敷
|
|
|
+ /// </summary>
|
|
|
+ async void ExecuteTakeProductCommand()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (SelectedPoint == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (Robot == null || !Robot.IsConnected)
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "机器人未连接,无法执行产品贴敷!", Duration = 1 });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (MessageBox.Show("确认要执行产品贴敷吗?", "去产品贴敷", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果二次定位的工具坐标为空,则提示用户先进行二次定位
|
|
|
+ if (toolCoord == null)
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "二次定位的工具坐标为空,无法执行产品拍照!", Duration = 1 });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_PutPoint.X == 0 && _PutPoint.Y == 0)
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "检测到未定位产品", Duration = 1 });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var waiting = new WaitingControl();
|
|
|
+ //show the dialog
|
|
|
+ var task = DialogHost.Show(waiting, "RootDialog", null, null, null);
|
|
|
+
|
|
|
+ var pn = Vector<double>.Build.Dense(new double[] { _PutPoint.X, _PutPoint.Y });
|
|
|
+ //目标角度:
|
|
|
+ double angle = SelectedPoint.U_Position + (_FixedUpCameraTempletAngle - SelectProduct.FixedUpCameraTempletAngle) + (_MoveCameraTempletAngle - SelectProduct.MoveDownCamerTempletAngle);
|
|
|
+ //将_PutPoint转换为Tool0下要走的点
|
|
|
+ var p0 = toolCoord.GetTool0Coord(pn, angle);
|
|
|
+
|
|
|
+ // 1. 控制机器人移动至拍照点位
|
|
|
+ var rpoint = new RPoint()
|
|
|
+ {
|
|
|
+ X = (float)p0[0],
|
|
|
+ Y = (float)p0[1],
|
|
|
+ Z = SelectedPoint.Z_Position_Start,
|
|
|
+ U = (float)angle,
|
|
|
+ V = SelectedPoint.R_Position,
|
|
|
+ };
|
|
|
+ await Robot.CalibMotionAsync(rpoint, 0);
|
|
|
+ if (DialogHost.IsDialogOpen("RootDialog"))
|
|
|
+ {
|
|
|
+ DialogHost.Close("RootDialog");
|
|
|
+ }
|
|
|
+ await task;
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("执行产品贴敷时出错!", ex);
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
|
|
|
+ if (DialogHost.IsDialogOpen("RootDialog"))
|
|
|
+ {
|
|
|
+ DialogHost.Close("RootDialog");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 继承
|
|
|
@@ -1494,7 +1573,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
try
|
|
|
{
|
|
|
toolCoord = null;
|
|
|
- local = null;
|
|
|
+ _PutPoint = new PointF();
|
|
|
SelectProduct = navigationContext.Parameters.GetValue<ProductModel>("SelectProduct");
|
|
|
|
|
|
SelectedIndex = 0;
|
|
|
@@ -1534,7 +1613,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
LockScrewProgramNumber = SelectProduct.ScrewPoints.FirstOrDefault()?.ScrewProNum ?? 1;
|
|
|
|
|
|
CameraList = new ObservableCollection<CameraInfo>(_configService.GetAllCameras());
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -1572,7 +1651,7 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
Camera.StopGrabbing();
|
|
|
}
|
|
|
Camera.ImageCallbackEvent -= Camera_ImageCallbackEvent;
|
|
|
-
|
|
|
+
|
|
|
Camera = null;
|
|
|
}
|
|
|
SelectedCamera = null;
|