From 05647d081cfe42230350e4d080a226f00bf9cade Mon Sep 17 00:00:00 2001
From: applelon <380149513@qq.com>
Date: Mon, 18 Apr 2022 17:41:46 +0800
Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BPASmartClient.Business.csproj | 9 +
BPASmartClient.Business/Class1.cs | 7 +
BPASmartClient.Device/DeviceStatus.cs | 17 +
BPASmartClient.Device/IDevice.cs | 16 +
.../BPASmartClient.DeviceProxy.csproj | 4 +
BPASmartClient.DeviceProxy/DeviceMgr.cs | 26 +
.../BPASmartClient.Lebai.csproj | 9 +
BPASmartClient.Lebai/Class1.cs | 8 -
BPASmartClient.Lebai/ELebaiRModel.cs | 26 +
BPASmartClient.Lebai/LebaiRobot.cs | 244 +++
.../{ModbusTcpHelper.cs => ModbusTcp.cs} | 8 +-
.../BPASmartClient.MorkIC.csproj | 9 +
BPASmartClient.MorkIC/Device_MorkIC.cs | 7 +
.../Device_MorkT.cs | 4 +-
.../BPASmartClient.OrderProxy.csproj | 9 +
BPASmartClient.OrderProxy/Class1.cs | 7 +
.../BPASmartClient.Peripheral.csproj | 9 +
BPASmartClient.Peripheral/BasePeripheral.cs | 46 +
BPASmartClient.Peripheral/DRIVER_CMD.cs | 16 +
BPASmartClient.Peripheral/IBasePeripheral.cs | 29 +
BPASmartClient/DeviceInfo.xml | 26 +
Lebai.SDK/Dtos/GetTasksInput.cs | 15 +
Lebai.SDK/Dtos/LebaiHttpResult.cs | 15 +
Lebai.SDK/Dtos/RobotStatus.cs | 85 +
Lebai.SDK/Dtos/TaskExecuteResult.cs | 16 +
Lebai.SDK/Dtos/TaskInfo.cs | 127 ++
Lebai.SDK/Dtos/TaskStatus.cs | 43 +
Lebai.SDK/Dtos/TasksResult.cs | 49 +
Lebai.SDK/Exceptions/RobotException.cs | 14 +
Lebai.SDK/Exceptions/RobotStatusException.cs | 14 +
Lebai.SDK/Exceptions/RobotTaskException.cs | 14 +
Lebai.SDK/FodyWeavers.xml | 4 +
Lebai.SDK/Lebai.SDK.csproj | 47 +
Lebai.SDK/LebaiRobotClient.cs | 1844 +++++++++++++++++
Lebai.SDK/LeibaiRobotClient_HttpPart.cs | 275 +++
Lebai.SDK/Protos/os_server.proto | 56 +
Lebai.SDK/Protos/private_controller.proto | 606 ++++++
Lebai.SDK/Protos/robot_controller.proto | 735 +++++++
Lebai.SDK/Protos/robot_test.proto | 193 ++
Lebai.SDK/Protos/simulation.proto | 46 +
Lebai.SDK/messages.proto | 126 ++
SmartClient.sln | 99 +-
42 files changed, 4913 insertions(+), 46 deletions(-)
create mode 100644 BPASmartClient.Business/BPASmartClient.Business.csproj
create mode 100644 BPASmartClient.Business/Class1.cs
create mode 100644 BPASmartClient.Device/DeviceStatus.cs
create mode 100644 BPASmartClient.DeviceProxy/DeviceMgr.cs
delete mode 100644 BPASmartClient.Lebai/Class1.cs
create mode 100644 BPASmartClient.Lebai/ELebaiRModel.cs
create mode 100644 BPASmartClient.Lebai/LebaiRobot.cs
rename BPASmartClient.Modbus/{ModbusTcpHelper.cs => ModbusTcp.cs} (98%)
create mode 100644 BPASmartClient.MorkIC/BPASmartClient.MorkIC.csproj
create mode 100644 BPASmartClient.MorkIC/Device_MorkIC.cs
rename BPASmartClient.Device/IDeviceStatus.cs => BPASmartClient.MorkT/Device_MorkT.cs (67%)
create mode 100644 BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj
create mode 100644 BPASmartClient.OrderProxy/Class1.cs
create mode 100644 BPASmartClient.Peripheral/BPASmartClient.Peripheral.csproj
create mode 100644 BPASmartClient.Peripheral/BasePeripheral.cs
create mode 100644 BPASmartClient.Peripheral/DRIVER_CMD.cs
create mode 100644 BPASmartClient.Peripheral/IBasePeripheral.cs
create mode 100644 BPASmartClient/DeviceInfo.xml
create mode 100644 Lebai.SDK/Dtos/GetTasksInput.cs
create mode 100644 Lebai.SDK/Dtos/LebaiHttpResult.cs
create mode 100644 Lebai.SDK/Dtos/RobotStatus.cs
create mode 100644 Lebai.SDK/Dtos/TaskExecuteResult.cs
create mode 100644 Lebai.SDK/Dtos/TaskInfo.cs
create mode 100644 Lebai.SDK/Dtos/TaskStatus.cs
create mode 100644 Lebai.SDK/Dtos/TasksResult.cs
create mode 100644 Lebai.SDK/Exceptions/RobotException.cs
create mode 100644 Lebai.SDK/Exceptions/RobotStatusException.cs
create mode 100644 Lebai.SDK/Exceptions/RobotTaskException.cs
create mode 100644 Lebai.SDK/FodyWeavers.xml
create mode 100644 Lebai.SDK/Lebai.SDK.csproj
create mode 100644 Lebai.SDK/LebaiRobotClient.cs
create mode 100644 Lebai.SDK/LeibaiRobotClient_HttpPart.cs
create mode 100644 Lebai.SDK/Protos/os_server.proto
create mode 100644 Lebai.SDK/Protos/private_controller.proto
create mode 100644 Lebai.SDK/Protos/robot_controller.proto
create mode 100644 Lebai.SDK/Protos/robot_test.proto
create mode 100644 Lebai.SDK/Protos/simulation.proto
create mode 100644 Lebai.SDK/messages.proto
diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj
new file mode 100644
index 00000000..132c02c5
--- /dev/null
+++ b/BPASmartClient.Business/BPASmartClient.Business.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BPASmartClient.Business/Class1.cs b/BPASmartClient.Business/Class1.cs
new file mode 100644
index 00000000..4c571328
--- /dev/null
+++ b/BPASmartClient.Business/Class1.cs
@@ -0,0 +1,7 @@
+namespace BPASmartClient.Business
+{
+ public class Class1
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/BPASmartClient.Device/DeviceStatus.cs b/BPASmartClient.Device/DeviceStatus.cs
new file mode 100644
index 00000000..5676a27e
--- /dev/null
+++ b/BPASmartClient.Device/DeviceStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Device
+{
+ public class DeviceStatus
+ {
+ public Dictionary status=new Dictionary();
+
+ public void Update(string key, object value) {
+ status[key] = value;
+ }
+ }
+}
diff --git a/BPASmartClient.Device/IDevice.cs b/BPASmartClient.Device/IDevice.cs
index 620bdfe4..dbb851b7 100644
--- a/BPASmartClient.Device/IDevice.cs
+++ b/BPASmartClient.Device/IDevice.cs
@@ -6,8 +6,24 @@ using System.Threading.Tasks;
namespace BPASmartClient.Device
{
+ ///
+ /// 设备接口
+ ///
public interface IDevice
{
+ DeviceStatus Status { get; set; }
+ ///
+ /// 初始化设备加载
+ ///
+ void Initliaze();
+ ///
+ /// 开启设备主任务
+ ///
+ void StartMain();
+ ///
+ /// 设备停止
+ ///
+ void Stop();
}
}
diff --git a/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj b/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
index dbc15171..06dffd75 100644
--- a/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
+++ b/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
@@ -4,4 +4,8 @@
net6.0
+
+
+
+
diff --git a/BPASmartClient.DeviceProxy/DeviceMgr.cs b/BPASmartClient.DeviceProxy/DeviceMgr.cs
new file mode 100644
index 00000000..93b6bc2f
--- /dev/null
+++ b/BPASmartClient.DeviceProxy/DeviceMgr.cs
@@ -0,0 +1,26 @@
+using BPASmartClient.Device;
+using BPASmartClient.Helper;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.DeviceProxy
+{
+ ///
+ /// 设备管理器,统一管理所有设备资源
+ ///
+ public class DeviceMgr:Singleton
+ {
+ //设备集合
+ private List devices=new List();
+
+ ///
+ /// 设备加载
+ ///
+ public void LoadDevice() {
+
+ }
+ }
+}
diff --git a/BPASmartClient.Lebai/BPASmartClient.Lebai.csproj b/BPASmartClient.Lebai/BPASmartClient.Lebai.csproj
index dbc15171..a335ae33 100644
--- a/BPASmartClient.Lebai/BPASmartClient.Lebai.csproj
+++ b/BPASmartClient.Lebai/BPASmartClient.Lebai.csproj
@@ -2,6 +2,15 @@
net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/BPASmartClient.Lebai/Class1.cs b/BPASmartClient.Lebai/Class1.cs
deleted file mode 100644
index 7960d771..00000000
--- a/BPASmartClient.Lebai/Class1.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using System;
-
-namespace BPASmartClient.Lebai
-{
- public class Class1
- {
- }
-}
diff --git a/BPASmartClient.Lebai/ELebaiRModel.cs b/BPASmartClient.Lebai/ELebaiRModel.cs
new file mode 100644
index 00000000..acec6be9
--- /dev/null
+++ b/BPASmartClient.Lebai/ELebaiRModel.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Lebai
+{
+ public enum ELebaiRModel : int
+ {
+ 硬件通讯故障 = 0,
+ 已急停 = 1,
+ 初始化中 = 2,
+ 已关机 = 3,
+ 已开机 = 4,
+ 空闲状态 = 5,
+ 暂停中 = 6,
+ 运行中 = 7,
+ 固件更新中 = 8,
+ 启动中 = 9,
+ 停止中 = 10,
+ 示教中 = 11,
+ 普通停止 = 12,
+ 微调中 = 13
+ }
+}
diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs
new file mode 100644
index 00000000..be887054
--- /dev/null
+++ b/BPASmartClient.Lebai/LebaiRobot.cs
@@ -0,0 +1,244 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Lebai.SDK;
+using Lebai.SDK.Dtos;
+using Robotc;
+using BPASmartClient.Message;
+using BPASmartClient.Helper;
+using TaskStatus = Lebai.SDK.Dtos.TaskStatus;
+using BPASmartClient.Peripheral;
+
+namespace BPASmartClient.Lebai
+{
+ public class LebaiRobot: BasePeripheral
+ {
+
+ //public const int SENCE_自嗨 = 10008;
+ //public const int SENCE_接冰淇淋1 = 10004;
+ //public const int SENCE_接冰淇淋2 = 10003;
+ //public const int SENCE_接冰淇淋3 = 10005;
+ //public const int SENCE_咖啡 = 10006;
+ //#region 新增场景
+ //public const int SENCE_取咖啡杯 = 10013;
+ //public const int SENCE_咖啡杯检测 = 10014;
+ //public const int SENCE_再次取杯 = 10017;
+ //public const int SENCE_接咖啡 = 10015;
+ //public const int SENCE_送咖啡 = 10016; //无取走咖啡检测配合场景
+ //public const int SENCE_New送咖啡 = 10021;//有取走咖啡检测配合场景
+ //public const int SENCE_有无咖啡检测 = 10019;
+ //public const int SENCE_再送咖啡 = 10020;
+ //public const int SENCE_复位 = 10018;
+ //#endregion
+ //public const int SENCE_欢迎 = 10002;
+
+
+ #region 且时且多设备
+ //取咖啡杯 set:=1 get:=101 10031
+ //取冰淇淋杯 set:=1 get:=101 10032
+ //咖啡杯检测 set:=1 get:=101 10033
+ //冰淇淋杯检测 set:=1 get:=101 10034
+ //二次取咖啡杯 set:=1 get:=101 10035
+ //二次取冰淇淋杯 set:=1 get:=101 10036
+ //接咖啡 set:=1 get:=101 10037
+ //接冰淇淋公共点 set:=1 get:=101 10038
+ //接1号冰淇淋 set:=1 get:=101 10039
+ //接2号冰淇淋 set:=1 get:=101 10040
+ //接3号冰淇淋 set:=1 get:=101 10041
+ //放咖啡位置 set:=1 get:=101 10042
+ //放冰淇淋位置 set:=1 get:=101 10043
+
+ public const int SENCE_取咖啡杯 = 10031;
+ public const int SENCE_取冰淇淋杯 = 10032;
+ public const int SENCE_咖啡杯检测 = 10033;
+ public const int SENCE_冰淇淋杯检测 = 10034;
+ public const int SENCE_二次取咖啡杯 = 10035;
+ public const int SENCE_二次取冰淇淋杯 = 10036;
+ public const int SENCE_接咖啡 = 10037;
+ public const int SENCE_接冰淇淋公共点 = 10038;
+ public const int SENCE_接1号冰淇淋 = 10039;
+ public const int SENCE_接2号冰淇淋 = 10040;
+ public const int SENCE_接3号冰淇淋 = 10041;
+ public const int SENCE_放咖啡位置 = 10042;
+ public const int SENCE_放冰淇淋位置 = 10043;
+ #endregion
+
+ ///
+ /// IP地址
+ ///
+ public string IpAddress { get; set; }
+ ///
+ /// 抓手上传感器输入位索引
+ ///
+ public int HandSensor { get; set; }
+ ///
+ /// 输出信号量索引
+ ///
+ public int OutputSingalValue { get; set; }
+
+ private LebaiRobotClient client;
+ private RobotData robotData;
+ public bool IsIdle { get; set; } = false;
+ public bool IsConnected { get { return null != robotData; } }
+
+ public void Connect(string ip)
+ {
+ bool ErrorFlag = false;
+ while (robotData == null)
+ {
+ try
+ {
+ client = new LebaiRobotClient(ip);
+ robotData = client.GetRobotData().Result;
+ }
+ catch (Exception ex)
+ {
+ if (!ErrorFlag)
+ {
+ MessageLog.GetInstance.ShowEx(ex.ToString());
+ ErrorFlag = true;
+ }
+ Thread.Sleep(3000);
+ }
+ }
+ StartRobot();
+ MessageLog.GetInstance.Show("乐百机器人连接成功!");
+ }
+
+ public void GetRobotModeStatus()
+ {
+
+ if (robotData == null) return;
+ int mode = robotData.RobotMode.Mode;
+ IsIdle = mode == 5;
+ for (int i = 0; i < 14; i++)
+ {
+ if (RTrig.GetInstance(((ELebaiRModel)i).ToString()).Start(mode == i))
+ MessageLog.GetInstance.Show(((ELebaiRModel)i).ToString());
+ }
+ }
+ public void GetSpeed()
+ {
+ //client.StartSys().GetAwaiter();
+ var aa = client.GetActualTcpSpeed().GetAwaiter();
+ //robotData.RobotMode.Mode
+ }
+
+ ///
+ /// 启动机器人
+ ///
+ public async void StartRobot()
+ {
+ if (robotData != null)
+ {
+ await client.StartSys();
+ await client.Sync();
+ MessageLog.GetInstance.Show("机器人启动成功");
+ }
+ }
+
+ ///
+ /// 获取抓手重量
+ ///
+ ///
+ public double GetClawWdight()
+ {
+ if (robotData != null)
+ {
+ return client.GetClawWeight().Result.Weight_;
+ }
+ return 0;
+ }
+
+ ///
+ /// 获取信号量
+ ///
+ ///
+ ///
+ public SignalResult? GetValueAsync(int index = 0)
+ {
+ if (robotData == null) return default(SignalResult);
+ SignalValue signalValue = new SignalValue();
+ signalValue.Index = index;
+ return client?.GetSignal(signalValue).Result;
+ }
+
+ ///
+ /// 设置信号量
+ ///
+ ///
+ ///
+ ///
+ public SignalResult? SetValue(int value, int index = 0)
+ {
+ if (robotData == null) return default;
+ SignalValue signalValue = new SignalValue();
+ signalValue.Index = index;
+ signalValue.Value = value;
+ return client.SetSignal(signalValue).Result;
+ }
+
+ ///
+ /// 获取输入DI状态
+ ///
+ ///
+ ///
+ public bool GetInput(int pin = 0)
+ {
+ if (client == null) return false;
+ var res = client.GetDIO(new IOPin() { Pin = pin }).Result;
+ if (res != null)
+ {
+ return res.Value == 1 ? true : false;
+ }
+ return false;
+ }
+
+ ///
+ /// 运行指定的场景
+ ///
+ ///
+ public async void Scene(int id)
+ {
+ CancellationToken cancellationToken = default(CancellationToken);
+ var result = await client.GetTasks(new GetTasksInput { PageIndex = 1, PageSize = 1 }, cancellationToken);
+ var first = result?.Items?.FirstOrDefault();
+ var r = first == null || first.Status != TaskStatus.Running && first.Status != TaskStatus.Pause;
+ while (!r)
+ {
+ Thread.Sleep(5);
+ result = await client.GetTasks(new GetTasksInput { PageIndex = 1, PageSize = 1 }, cancellationToken);
+ first = result?.Items?.FirstOrDefault();
+ r = first == null || first.Status != TaskStatus.Running && first.Status != TaskStatus.Pause;
+ }
+ while (GetValueAsync().Value != 0)
+ {
+ Thread.Sleep(500);
+ }
+ Thread.Sleep(1000);
+ if (robotData == null || client == null) return;
+ //if (!client.GetIsCanRunTask().Result) return;
+ await client?.RunScene(id);
+ MessageLog.GetInstance.Show($"调用场景:{id}");
+ }
+
+ protected override void InitStatus()
+ {
+ status["Connected"] = false;
+ status["HandSensor"] = 0;
+ status["OutputSingalValue"] = 0;
+ }
+
+ public override void Start()
+ {
+ Connect(IpAddress);
+ }
+
+ public override void Stop()
+ {
+ }
+ }
+}
diff --git a/BPASmartClient.Modbus/ModbusTcpHelper.cs b/BPASmartClient.Modbus/ModbusTcp.cs
similarity index 98%
rename from BPASmartClient.Modbus/ModbusTcpHelper.cs
rename to BPASmartClient.Modbus/ModbusTcp.cs
index 73ed6fb4..c375e191 100644
--- a/BPASmartClient.Modbus/ModbusTcpHelper.cs
+++ b/BPASmartClient.Modbus/ModbusTcp.cs
@@ -9,12 +9,12 @@ using System.Threading;
namespace BPASmartClient.Modbus
{
- public class ModbusTcpHelper
+ public class ModbusTcp
{
- private volatile static ModbusTcpHelper _Instance;
- public static ModbusTcpHelper GetInstance => _Instance ?? (_Instance = new ModbusTcpHelper());
- private ModbusTcpHelper() { }
+ private volatile static ModbusTcp _Instance;
+ public static ModbusTcp GetInstance => _Instance ?? (_Instance = new ModbusTcp());
+ private ModbusTcp() { }
private ModbusFactory modbusFactory;
private IModbusMaster master;
diff --git a/BPASmartClient.MorkIC/BPASmartClient.MorkIC.csproj b/BPASmartClient.MorkIC/BPASmartClient.MorkIC.csproj
new file mode 100644
index 00000000..132c02c5
--- /dev/null
+++ b/BPASmartClient.MorkIC/BPASmartClient.MorkIC.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BPASmartClient.MorkIC/Device_MorkIC.cs b/BPASmartClient.MorkIC/Device_MorkIC.cs
new file mode 100644
index 00000000..5e2c77d8
--- /dev/null
+++ b/BPASmartClient.MorkIC/Device_MorkIC.cs
@@ -0,0 +1,7 @@
+namespace BPASmartClient.MorkIC
+{
+ public class Device_MorkIC
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/BPASmartClient.Device/IDeviceStatus.cs b/BPASmartClient.MorkT/Device_MorkT.cs
similarity index 67%
rename from BPASmartClient.Device/IDeviceStatus.cs
rename to BPASmartClient.MorkT/Device_MorkT.cs
index 6ab5e918..43b7811d 100644
--- a/BPASmartClient.Device/IDeviceStatus.cs
+++ b/BPASmartClient.MorkT/Device_MorkT.cs
@@ -4,9 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace BPASmartClient.Device
+namespace BPASmartClient.MorkT
{
- internal class IDeviceStatus
+ public class Device_MorkT
{
}
}
diff --git a/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj b/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj
new file mode 100644
index 00000000..132c02c5
--- /dev/null
+++ b/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BPASmartClient.OrderProxy/Class1.cs b/BPASmartClient.OrderProxy/Class1.cs
new file mode 100644
index 00000000..a6a848f4
--- /dev/null
+++ b/BPASmartClient.OrderProxy/Class1.cs
@@ -0,0 +1,7 @@
+namespace BPASmartClient.OrderProxy
+{
+ public class Class1
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/BPASmartClient.Peripheral/BPASmartClient.Peripheral.csproj b/BPASmartClient.Peripheral/BPASmartClient.Peripheral.csproj
new file mode 100644
index 00000000..132c02c5
--- /dev/null
+++ b/BPASmartClient.Peripheral/BPASmartClient.Peripheral.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/BPASmartClient.Peripheral/BasePeripheral.cs b/BPASmartClient.Peripheral/BasePeripheral.cs
new file mode 100644
index 00000000..b3dabd27
--- /dev/null
+++ b/BPASmartClient.Peripheral/BasePeripheral.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Peripheral
+{
+ ///
+ /// 外设基类
+ ///
+ public abstract class BasePeripheral : IBasePeripheral
+ {
+ ///
+ /// 是否已连接
+ ///
+ public bool IsConnected { get; protected set; }
+ ///
+ /// 是否工作正常
+ ///
+ public bool IsWork { get; protected set; }
+ ///
+ /// 外设状态集合
+ ///
+ protected Dictionary status = new Dictionary();
+
+ ///
+ /// 初始化外设状态
+ ///
+ protected abstract void InitStatus();
+
+ public object? GetStatus(string statusName)
+ {
+ if (status.ContainsKey(statusName))
+ return status[statusName];
+ return null;
+ }
+
+
+ public abstract void Start();
+
+ public abstract void Stop();
+
+
+ }
+}
diff --git a/BPASmartClient.Peripheral/DRIVER_CMD.cs b/BPASmartClient.Peripheral/DRIVER_CMD.cs
new file mode 100644
index 00000000..a878fd35
--- /dev/null
+++ b/BPASmartClient.Peripheral/DRIVER_CMD.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Peripheral
+{
+ ///
+ /// 驱动执行命令
+ ///
+ public enum DRIVER_CMD
+ {
+ LEBAI_RUN_SENCE,
+ }
+}
diff --git a/BPASmartClient.Peripheral/IBasePeripheral.cs b/BPASmartClient.Peripheral/IBasePeripheral.cs
new file mode 100644
index 00000000..ca5b2a7b
--- /dev/null
+++ b/BPASmartClient.Peripheral/IBasePeripheral.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Peripheral
+{
+ ///
+ /// 外设接口
+ ///
+ public interface IBasePeripheral
+ {
+ ///
+ /// 获取指定状态值
+ ///
+ /// 状态名称
+ /// 状态值
+ object? GetStatus(string statusName);
+ ///
+ /// 驱动开启
+ ///
+ void Start();
+ ///
+ /// 驱动停止
+ ///
+ void Stop();
+ }
+}
diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml
new file mode 100644
index 00000000..e5d6d3d3
--- /dev/null
+++ b/BPASmartClient/DeviceInfo.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ 127.0.0.1
+ 1
+ 0
+
+
+
+
+ COM5
+ 9600
+
+
+
+
+ COM6
+ 115200
+
+
+
+
+
diff --git a/Lebai.SDK/Dtos/GetTasksInput.cs b/Lebai.SDK/Dtos/GetTasksInput.cs
new file mode 100644
index 00000000..94dbbe3c
--- /dev/null
+++ b/Lebai.SDK/Dtos/GetTasksInput.cs
@@ -0,0 +1,15 @@
+namespace Lebai.SDK.Dtos
+{
+ public class GetTasksInput
+ {
+ ///
+ /// 页索引
+ ///
+ public int PageIndex { get; set; } = 1;
+
+ ///
+ /// 页大小
+ ///
+ public int PageSize { get; set; } = 10;
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/LebaiHttpResult.cs b/Lebai.SDK/Dtos/LebaiHttpResult.cs
new file mode 100644
index 00000000..d63c98ba
--- /dev/null
+++ b/Lebai.SDK/Dtos/LebaiHttpResult.cs
@@ -0,0 +1,15 @@
+namespace Lebai.SDK.Dtos
+{
+ public class LebaiHttpResult
+ {
+ ///
+ /// 数据
+ ///
+ public T Data { get; set; }
+
+ ///
+ /// 错误码
+ ///
+ public int Code { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/RobotStatus.cs b/Lebai.SDK/Dtos/RobotStatus.cs
new file mode 100644
index 00000000..5c234aab
--- /dev/null
+++ b/Lebai.SDK/Dtos/RobotStatus.cs
@@ -0,0 +1,85 @@
+using System.ComponentModel;
+
+namespace Lebai.SDK.Dtos
+{
+ public enum RobotStatus
+ {
+
+ ///
+ /// 已断开连接
+ ///
+ [Description("已断开连接")] DISCONNECTED = 0,
+
+
+ ///
+ /// 急停停止状态
+ ///
+ [Description("急停停止状态")] ESTOP = 1,
+
+
+ ///
+ /// 启动中
+ ///
+ [Description("启动中")] BOOTING = 2,
+
+
+ ///
+ /// 电源关闭
+ ///
+ [Description("电源关闭")] ROBOT_OFF = 3,
+
+
+ ///
+ /// 电源开启
+ ///
+ [Description("电源开启")] ROBOT_ON = 4,
+
+
+ ///
+ /// 空闲中
+ ///
+ [Description("空闲中")] IDLE = 5,
+
+
+ ///
+ /// 暂停中
+ ///
+ [Description("暂停中")] PAUSED = 6,
+
+
+ ///
+ /// 机器人运动运行中
+ ///
+ [Description("机器人运动运行中")] RUNNING = 7,
+
+
+ ///
+ /// 更新固件中
+ ///
+ [Description("更新固件中")] UPDATING = 8,
+
+
+ ///
+ /// 启动中
+ ///
+ [Description("启动中")] STARTING = 9,
+
+
+ ///
+ /// 停止中
+ ///
+ [Description("停止中")] STOPPING = 10,
+
+
+ ///
+ /// 示教中
+ ///
+ [Description("示教中")] TEACHING = 11,
+
+
+ ///
+ /// 普通停止
+ ///
+ [Description("普通停止")] STOP = 12,
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/TaskExecuteResult.cs b/Lebai.SDK/Dtos/TaskExecuteResult.cs
new file mode 100644
index 00000000..d4d8e8da
--- /dev/null
+++ b/Lebai.SDK/Dtos/TaskExecuteResult.cs
@@ -0,0 +1,16 @@
+namespace Lebai.SDK.Dtos
+{
+ public class TaskExecuteResult
+ {
+ public int Id { get; set; }
+
+ public TaskExecuteResult()
+ {
+ }
+
+ public void Deconstruct(out int id)
+ {
+ id = Id;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/TaskInfo.cs b/Lebai.SDK/Dtos/TaskInfo.cs
new file mode 100644
index 00000000..f7e19e9d
--- /dev/null
+++ b/Lebai.SDK/Dtos/TaskInfo.cs
@@ -0,0 +1,127 @@
+using System;
+
+
+namespace Lebai.SDK.Dtos
+{
+ public class OriginTaskInfo
+ {
+ public int Id { get; set; }
+
+ public int? scene_id { get; set; }
+
+ public int execute_count { get; set; }
+
+ public int executed_count { get; set; }
+
+ public string Name { get; set; }
+
+ public TaskStatus Status { get; set; }
+
+ public string Comment { get; set; }
+
+ public string start_time { get; set; }
+
+ public string end_time { get; set; }
+
+ public long consume_time { get; set; }
+
+ public int Mode { get; set; }
+
+ public string create_time { get; set; }
+
+ public string update_time { get; set; }
+
+ public int? scene_type { get; set; }
+
+ public object first_pose { get; set; }
+
+ public TaskInfo ToTaskInfo()
+ {
+ return new TaskInfo
+ {
+ Id = Id,
+ Comment = Comment,
+ Mode = Mode,
+ Name = Name,
+ Status = Status,
+ ConsumeTime = consume_time,
+ CreationTime = create_time,
+ EndTime = end_time,
+ ExecuteCount = execute_count,
+ ExecutedCount = executed_count,
+ FirstPose = first_pose,
+ SceneId = scene_id,
+ SceneType = scene_type,
+ StartTime = start_time,
+ UpdateTime = update_time
+ };
+ }
+ }
+
+ public class TaskInfo
+ {
+ public int Id { get; set; }
+
+
+ ///
+ /// 场景Id
+ ///
+ public int? SceneId { get; set; }
+
+ ///
+ /// 执行次数
+ ///
+ public int? ExecuteCount { get; set; }
+
+ ///
+ /// 执行的次数
+ ///
+ public int? ExecutedCount { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 状态
+ ///
+ public TaskStatus? Status { get; set; }
+
+ ///
+ /// 注释
+ ///
+ public string Comment { get; set; }
+
+ ///
+ /// 开始时间
+ ///
+ public string StartTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public string EndTime { get; set; }
+
+ public long? ConsumeTime { get; set; }
+
+ public int? Mode { get; set; }
+
+
+ ///
+ /// 创建时间
+ ///
+ public string CreationTime { get; set; }
+
+ ///
+ /// 更新时间
+ ///
+ public string UpdateTime { get; set; }
+
+
+ public int? SceneType { get; set; }
+
+
+ public object FirstPose { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/TaskStatus.cs b/Lebai.SDK/Dtos/TaskStatus.cs
new file mode 100644
index 00000000..bd6549e4
--- /dev/null
+++ b/Lebai.SDK/Dtos/TaskStatus.cs
@@ -0,0 +1,43 @@
+using System.ComponentModel;
+
+namespace Lebai.SDK.Dtos
+{
+ public enum TaskStatus
+ {
+ ///
+ /// 空闲
+ ///
+ [Description("空闲")]
+ Idea = 0,
+
+ ///
+ /// 运行
+ ///
+ [Description("运行")]
+ Running = 1,
+
+ ///
+ /// 暂停
+ ///
+ [Description("暂停")]
+ Pause = 2,
+
+ ///
+ /// 运行成功
+ ///
+ [Description("运行成功")]
+ RunSuccess = 3,
+
+ ///
+ /// 手动停止
+ ///
+ [Description("手动停止")]
+ ManualStop = 4,
+
+ ///
+ /// 异常停止
+ ///
+ [Description("异常停止")]
+ AbnormalStop = 5
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Dtos/TasksResult.cs b/Lebai.SDK/Dtos/TasksResult.cs
new file mode 100644
index 00000000..718fa2e1
--- /dev/null
+++ b/Lebai.SDK/Dtos/TasksResult.cs
@@ -0,0 +1,49 @@
+using System.Linq;
+
+namespace Lebai.SDK.Dtos
+{
+ public class OriginTasksResult
+ {
+ public int pi { get; set; }
+
+ public int ps { get; set; }
+
+ public int total { get; set; }
+
+ public OriginTaskInfo[] records { get; set; }
+
+ public TasksResult ToResult()
+ {
+ return new TasksResult
+ {
+ Items = records.Select(n=>n.ToTaskInfo()).ToArray(),
+ PageIndex = pi,
+ PageSize = ps,
+ TotalCount = total
+ };
+ }
+ }
+
+ public class TasksResult
+ {
+ ///
+ /// 页索引
+ ///
+ public int PageIndex { get; set; }
+
+ ///
+ /// 页大小
+ ///
+ public int PageSize { get; set; }
+
+ ///
+ /// 总数量
+ ///
+ public int TotalCount { get; set; }
+
+ ///
+ /// 任务列表
+ ///
+ public TaskInfo[] Items { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Exceptions/RobotException.cs b/Lebai.SDK/Exceptions/RobotException.cs
new file mode 100644
index 00000000..50656c21
--- /dev/null
+++ b/Lebai.SDK/Exceptions/RobotException.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace Lebai.SDK.Exceptions
+{
+ public class RobotException : Exception
+ {
+ public bool CanRetry { get; }
+
+ public RobotException(string message, bool canRetry = false) : base(message)
+ {
+ CanRetry = canRetry;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Exceptions/RobotStatusException.cs b/Lebai.SDK/Exceptions/RobotStatusException.cs
new file mode 100644
index 00000000..c9cf9237
--- /dev/null
+++ b/Lebai.SDK/Exceptions/RobotStatusException.cs
@@ -0,0 +1,14 @@
+using Lebai.SDK.Dtos;
+
+namespace Lebai.SDK.Exceptions
+{
+ public class RobotStatusException : RobotException
+ {
+ private RobotStatus RobotStatus { get; }
+
+ public RobotStatusException(RobotStatus robotStatus) : base(EnumExtension.GetEnumDescription(robotStatus))
+ {
+ RobotStatus = robotStatus;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Exceptions/RobotTaskException.cs b/Lebai.SDK/Exceptions/RobotTaskException.cs
new file mode 100644
index 00000000..b0b8a949
--- /dev/null
+++ b/Lebai.SDK/Exceptions/RobotTaskException.cs
@@ -0,0 +1,14 @@
+using Lebai.SDK.Dtos;
+
+namespace Lebai.SDK.Exceptions
+{
+ public class RobotTaskException : RobotException
+ {
+ public TaskStatus? TaskStatus { get; }
+
+ public RobotTaskException(TaskStatus? taskStatus) : base(EnumExtension.GetEnumDescription(taskStatus))
+ {
+ TaskStatus = taskStatus;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/FodyWeavers.xml b/Lebai.SDK/FodyWeavers.xml
new file mode 100644
index 00000000..b74c9268
--- /dev/null
+++ b/Lebai.SDK/FodyWeavers.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Lebai.SDK/Lebai.SDK.csproj b/Lebai.SDK/Lebai.SDK.csproj
new file mode 100644
index 00000000..097bb863
--- /dev/null
+++ b/Lebai.SDK/Lebai.SDK.csproj
@@ -0,0 +1,47 @@
+
+
+
+ 0.3.13
+ true
+ net5.0
+ https://github.com/lebai-robotics/lebai-dotnet-sdk
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+ Client
+ Public
+ True
+ True
+ MSBuild:Compile
+
+
+ Client
+ MSBuild:Compile
+
+
+ Client
+ MSBuild:Compile
+
+
+ Client
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Client
+
+
+ MSBuild:Compile
+ Client
+
+
+
+
diff --git a/Lebai.SDK/LebaiRobotClient.cs b/Lebai.SDK/LebaiRobotClient.cs
new file mode 100644
index 00000000..9d1ef074
--- /dev/null
+++ b/Lebai.SDK/LebaiRobotClient.cs
@@ -0,0 +1,1844 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Grpc.Net.Client;
+using Robotc;
+using Empty = Google.Protobuf.WellKnownTypes.Empty;
+
+namespace Lebai.SDK
+{
+ public partial class LebaiRobotClient
+ {
+ public static readonly Dictionary LebaiRobotClients = new();
+
+ private readonly HttpClient _httpClient;
+
+ private RobotController.RobotControllerClient _robotControllerClient;
+ private RobotPrivateController.RobotPrivateControllerClient _robotPrivateControllerClient;
+
+ public LebaiRobotClient(string ip, int robotControllerClientPort = 5181, int robotPrivateControllerPort = 5182,
+ GrpcChannelOptions grpcChannelOptions = null)
+ {
+ IP = ip;
+ RobotControllerClientPort = robotControllerClientPort;
+ RobotPrivateControllerPort = robotPrivateControllerPort;
+ GrpcChannelOptions = grpcChannelOptions;
+ _httpClient = new HttpClient {BaseAddress = new Uri($"http://{ip}")};
+ }
+
+ private string IP { get; }
+ private int RobotControllerClientPort { get; }
+ private int RobotPrivateControllerPort { get; }
+ private GrpcChannelOptions GrpcChannelOptions { get; }
+
+ public Action OnRpcException { get; set; }
+
+ private RobotController.RobotControllerClient RobotControllerClient =>
+ LazyInitializer.EnsureInitialized(ref _robotControllerClient,
+ () =>
+ {
+ var r = new RobotController.RobotControllerClient(
+ GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotControllerClientPort}"),
+ GrpcChannelOptions ??
+ new GrpcChannelOptions
+ {
+ MaxRetryAttempts = 5
+ })
+ );
+ return r;
+ });
+
+ private RobotPrivateController.RobotPrivateControllerClient RobotPrivateControllerClient =>
+ LazyInitializer.EnsureInitialized(ref _robotPrivateControllerClient,
+ () => new RobotPrivateController.RobotPrivateControllerClient(
+ GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotPrivateControllerPort}"), GrpcChannelOptions ??
+ new GrpcChannelOptions
+ {
+ MaxRetryAttempts = 5
+ })));
+
+ public static LebaiRobotClient Get(string ip, int robotControllerClientPort = 5181,
+ int robotPrivateControllerPort = 5182)
+ {
+ if (LebaiRobotClients.ContainsKey(ip)) return LebaiRobotClients[ip];
+
+ LebaiRobotClients[ip] = new LebaiRobotClient(ip);
+ return LebaiRobotClients[ip];
+ }
+
+ ///
+ /// 启用/禁用 设备
+ ///
+ ///
+ ///
+ public virtual async Task ConnectExternalIO(ExternalIOState externalIoState,
+ CancellationToken cancellationToken = default)
+ {
+ await RobotPrivateControllerClient.ConnectExternalIOAsync(externalIoState,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 关闭电源
+ ///
+ public virtual async Task PowerDown(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.PowerDownAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 等待,单位毫秒
+ ///
+ ///
+ ///
+ public virtual async Task Sleep(SleepRequest sleepRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SleepAsync(sleepRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 同步,等待命令执行完成
+ ///
+ public virtual async Task Sync(CancellationToken cancellationToken = default)
+ {
+ try
+ {
+ await RobotControllerClient.SyncAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+ catch (RpcException e)
+ {
+ OnRpcException?.Invoke(e);
+ }
+ }
+
+ public virtual async Task SyncFor(SyncRequest syncRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SyncForAsync(syncRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 开启示教模式
+ ///
+ public virtual async Task TeachMode(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.TeachModeAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 关闭示教模式
+ ///
+ public virtual async Task EndTeachMode(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.EndTeachModeAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置速度因子(0-100)
+ ///
+ ///
+ ///
+ public virtual async Task SetVelocityFactor(Factor factor, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetVelocityFactorAsync(factor, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取速度因子(0-100)
+ ///
+ ///
+ public virtual async Task GetVelocityFactor(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetVelocityFactorAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置重力方向
+ ///
+ ///
+ ///
+ public virtual async Task SetGravity(Coordinate coordinate, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetGravityAsync(coordinate, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取重力方向
+ ///
+ ///
+ public virtual async Task GetGravity(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetGravityAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置负载
+ ///
+ ///
+ ///
+ public virtual async Task SetPayload(Payload payload, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetPayloadAsync(payload, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取负载
+ ///
+ ///
+ public virtual async Task GetPayload(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetPayloadAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置负责质量
+ ///
+ ///
+ ///
+ public virtual async Task SetPayloadMass(PayloadMass payloadMass,
+ CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetPayloadMassAsync(payloadMass, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取负责质量
+ ///
+ ///
+ public virtual async Task GetPayloadMass(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetPayloadMassAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置负载质心
+ ///
+ ///
+ ///
+ public virtual async Task SetPayloadCog(PayloadCog payloadCog, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetPayloadCogAsync(payloadCog, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取负责质心
+ ///
+ ///
+ public virtual async Task GetPayloadCog(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetPayloadCogAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置TCP
+ ///
+ ///
+ ///
+ public virtual async Task SetTcp(PR pR, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetTcpAsync(pR, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取TCP
+ ///
+ ///
+ public virtual async Task GetTcp(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTcpAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置手爪幅度:0-100 double
+ ///
+ ///
+ ///
+ public virtual async Task SetClawAmplitude(Amplitude amplitude,
+ CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetClawAmplitudeAsync(amplitude, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得手爪幅度:0-100 double
+ ///
+ ///
+ public virtual async Task GetClawAmplitude(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetClawAmplitudeAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得手爪目前是否夹紧物体状态1表示夹紧,0为松开
+ ///
+ ///
+ public virtual async Task GetClawHoldOn(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetClawHoldOnAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置手爪力度:0-100 double
+ ///
+ ///
+ ///
+ public virtual async Task SetClawForce(Force force, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetClawForceAsync(force, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得手爪称重结果
+ ///
+ ///
+ public virtual async Task GetClawWeight(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetClawWeightAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ public virtual async Task GetTcpForce(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTcpForceAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置手爪
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetClaw(ClawInfo clawInfo, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetClawAsync(clawInfo, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取手爪
+ ///
+ ///
+ public virtual async Task GetClaw(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetClawAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置位置
+ ///
+ ///
+ ///
+ public virtual async Task SetPos(JPose jPose, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetPosAsync(jPose, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task SpeedJ(SpeedJRequest speedJRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SpeedJAsync(speedJRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task SpeedL(SpeedLRequest speedLRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SpeedLAsync(speedLRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task StopJ(StopJRequest stopJRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopJAsync(stopJRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task StopL(StopLRequest stopLRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopLAsync(stopLRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 停止当前移动
+ ///
+ public virtual async Task StopMove(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopMoveAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 圆弧移动
+ ///
+ ///
+ ///
+ public virtual async Task MoveC(MoveCRequest moveCRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MoveCAsync(moveCRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 关节空间线性移动
+ ///
+ ///
+ ///
+ public virtual async Task MoveJ(MoveJRequest moveJRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MoveJAsync(moveJRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 笛卡尔空间线性移动
+ ///
+ ///
+ ///
+ public virtual async Task MoveL(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MoveLAsync(moveLRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// DEPRECIATED
+ ///
+ ///
+ ///
+ [Obsolete]
+ public virtual async Task MoveLJ(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MoveLJAsync(moveLRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task MoveP(MovePRequest movePRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MovePAsync(movePRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// pt move
+ ///
+ ///
+ ///
+ public virtual async Task MovePT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MovePTAsync(pVATRequest, cancellationToken: cancellationToken);
+ }
+
+ /*public void MovePTStream(PVATRequest request,CancellationToken cancellationToken=default)
+ {
+
+ }*/
+
+ ///
+ /// pvt move
+ ///
+ ///
+ ///
+ public virtual async Task MovePVT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MovePVTAsync(pVATRequest, cancellationToken: cancellationToken);
+ }
+
+ /*public void MovePVTStream(PVATRequest request,CancellationToken cancellationToken=default)
+ {
+ RobotControllerClient.MovePVTStreamAsync(PVATRequest,cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// pvat move
+ ///
+ ///
+ ///
+ public virtual async Task MovePVAT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MovePVATAsync(pVATRequest, cancellationToken: cancellationToken);
+ }
+
+ /*public void MovePVATStream(stream stream PVATRequest,CancellationToken cancellationToken=default)
+ {
+ RobotControllerClient.MovePVATStreamAsync(PVATRequest,cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task ServoC(ServoCRequest servoCRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.ServoCAsync(servoCRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ ///
+ public virtual async Task ServoJ(ServoJRequest servoJRequest, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.ServoJAsync(servoJRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取机器人所有状态数据
+ ///
+ ///
+ public virtual async Task GetRobotData(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetRobotDataAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取机器人状态
+ ///
+ ///
+ public virtual async Task GetRobotMode(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetRobotModeAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得实际关节位置
+ ///
+ ///
+ public virtual async Task GetActualJointPositions(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetActualJointPositionsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得目标关节位置
+ ///
+ ///
+ public virtual async Task GetTargetJointPositions(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTargetJointPositionsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得实际关节速度
+ ///
+ ///
+ public virtual async Task GetActualJointSpeeds(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetActualJointSpeedsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得目标关节速度
+ ///
+ ///
+ public virtual async Task GetTargetJointSpeeds(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTargetJointSpeedsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得末端在笛卡尔坐标系下的位姿
+ ///
+ ///
+ public virtual async Task GetActualTcpPose(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetActualTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得末端在笛卡尔坐标系下的目标位姿
+ ///
+ ///
+ public virtual async Task GetTargetTcpPose(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTargetTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ public virtual async Task GetActualTcpSpeed(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetActualTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ public virtual async Task GetTargetTcpSpeed(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTargetTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ public virtual async Task GetActualFlangePose(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetActualFlangePoseAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取关节扭矩
+ ///
+ ///
+ public virtual async Task GetJointTorques(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetJointTorquesAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取控制器温度
+ ///
+ ///
+ public virtual async Task GetControllerTemp(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetControllerTempAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取关节内部温度
+ ///
+ ///
+ ///
+ public virtual async Task GetJointTemp(IntRequest intRequest,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetJointTempAsync(intRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// implement later
+ ///
+ ///
+ public virtual async Task GetToolCurrent(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetToolCurrentAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置数字输出端口的值
+ ///
+ ///
+ ///
+ public virtual async Task SetDIO(DIO dIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetDIOAsync(dIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置扩展数字输出端口的值
+ ///
+ ///
+ ///
+ public virtual async Task SetExtraDIO(DIO dIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetExtraDIOAsync(dIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得数字输入端口的值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetDIO(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetDIOAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得扩展数字数如端口的值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExtraDIO(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExtraDIOAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置TCP数字输出端口的值
+ ///
+ ///
+ ///
+ public virtual async Task SetTcpDIO(DIO dIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetTcpDIOAsync(dIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得TCP数字输入端口的值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetTcpDIO(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetTcpDIOAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置模拟输出端口的值
+ ///
+ ///
+ ///
+ public virtual async Task SetAIO(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetAIOAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得模拟输入端口的值
+ ///
+ ///
+ ///
+ public virtual async Task SetExtraAIO(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetExtraAIOAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得模拟输入端口的值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetAIO(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetAIOAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得扩展模拟输入端口的值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExtraAIO(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExtraAIOAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置模拟输入端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ public virtual async Task SetAInMode(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetAInModeAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置扩展模拟输入端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ public virtual async Task SetExtraAInMode(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetExtraAInModeAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得模拟输入端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetAInModeAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得扩展模拟输入端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExtraAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExtraAInModeAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置模拟输出端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ public virtual async Task SetAOutMode(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetAOutModeAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置扩展模拟输出端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ public virtual async Task SetExtraAOutMode(AIO aIO, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetExtraAOutModeAsync(aIO, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得模拟输出端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetAOutModeAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得扩展模拟输出端口工作模式:0:电压,1:电流
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExtraAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExtraAOutModeAsync(iOPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 开启/启动系统
+ ///
+ public virtual async Task StartSys(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StartSysAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 关闭/停止系统
+ ///
+ public virtual async Task StopSys(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopSysAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 程序停止
+ ///
+ public virtual async Task Stop(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 急停
+ ///
+ public virtual async Task EStop(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.EStopAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取kdl参数
+ ///
+ ///
+ public virtual async Task GetKDL(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetKDLAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 查询系统里面的日志信息
+ ///
+ ///
+ public virtual async Task GetLogs(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetLogsAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获得当前正在执行的命令id,如果没有在执行的命令,则返回-1
+ ///
+ public virtual async Task GetCurrentCmd(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.GetCurrentCmdAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ /*
+ // 获得指定命令id的执行结果:-1: 未执行;0: 已执行
+ public CmdStatus GetCmdExecStatus(void cmdId,CancellationToken cancellationToken=default)
+ {
+ return await nt.GetCmdExecStatus(cmdId,cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 开始微调: 如果当前有其他微调再传入新的微调命令会终止当前的微调进行新的微调
+ ///
+ ///
+ public virtual async Task StartFineTuning(FineTuning fineTuning,
+ CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StartFineTuningAsync(fineTuning, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 停止微调
+ ///
+ public virtual async Task StopFineTuning(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.StopFineTuningAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 暂停机器人
+ ///
+ public virtual async Task Pause(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.PauseAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 恢复机器人
+ ///
+ public virtual async Task Resume(CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.ResumeAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 机器人正解
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task KinematicsForward(Joint joint,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.KinematicsForwardAsync(joint, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 机器人反解
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task KinematicsInverse(Vector vector,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.KinematicsInverseAsync(vector, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// TCP示教添加
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task CalcTcpTranslation(CalcTcpParam calcTcpParam,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.CalcTcpTranslationAsync(calcTcpParam, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 测试命令,以给定的RPY数据执行线性移动
+ ///
+ ///
+ ///
+ public virtual async Task MoveLRPY(MoveLRPYRequest moveLRPYRequest,
+ CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.MoveLRPYAsync(moveLRPYRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置LED灯状态
+ ///
+ ///
+ ///
+ public virtual async Task SetLED(LEDStatus lEDStatus, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetLEDAsync(lEDStatus, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置声音
+ ///
+ ///
+ public virtual async Task SetVoice(VoiceStatus voiceStatus, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetVoiceAsync(voiceStatus, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置风扇
+ ///
+ ///
+ ///
+ public virtual async Task SetFan(FanStatus fanStatus, CancellationToken cancellationToken = default)
+ {
+ await RobotControllerClient.SetFanAsync(fanStatus, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取灯板状态
+ ///
+ ///
+ public virtual async Task GetLampStatus(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetLampStatusAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// Lua 状态查询
+ ///
+ ///
+ public virtual async Task GetLuaState(CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetLuaStateAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置外置数字输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetExternalDO(ExternalDigital externalDigital,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetExternalDOAsync(externalDigital, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置数字输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalDO(ExternalPin externalPin,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalDOAsync(externalPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置数字输入
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalDI(ExternalPin externalPin,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalDIAsync(externalPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置外置模拟输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetExternalAO(ExternalAnalog externalAnalog,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetExternalAOAsync(externalAnalog, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置模拟输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalAO(ExternalPin externalPin,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalAOAsync(externalPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置模拟输入
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalAI(ExternalPin externalPin,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalAIAsync(externalPin, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取某个外置io的全部io信息
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalIOs(ExternalDevice externalDevice,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalIOsAsync(externalDevice, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置某个外置io的全部io信息
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetExternalDOs(ExternalDigitals externalDigitals,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetExternalDOsAsync(externalDigitals, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置数字输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalDOs(ExternalPins externalPins,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalDOsAsync(externalPins, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置数字输入
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalDIs(ExternalPins externalPins,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalDIsAsync(externalPins, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置外置模拟输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetExternalAOs(ExternalAnalogs externalAnalogs,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetExternalAOsAsync(externalAnalogs, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置模拟输出
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalAOs(ExternalPins externalPins,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalAOsAsync(externalPins, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取外置模拟输入
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetExternalAIs(ExternalPins externalPins,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetExternalAIsAsync(externalPins, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置信号量
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetSignal(SignalValue signalValue,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.SetSignalAsync(signalValue, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取信号量
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetSignal(SignalValue signalValue,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.GetSignalAsync(signalValue, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 添加信号量
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task AddSignal(SignalValue signalValue,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotControllerClient.AddSignalAsync(signalValue, cancellationToken: cancellationToken);
+ }
+ /*
+
+ public stream RegisterSignals(stream stream SignalList,CancellationToken cancellationToken=default)
+ {
+ return await RobotControllerClient.RegisterSignals().RequestStream.WriteAsync(cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 初始化配置
+ ///
+ ///
+ ///
+ public virtual async void Init(Configuration configuration, CancellationToken cancellationToken = default)
+ {
+ await RobotPrivateControllerClient.InitAsync(configuration, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取机器人基础信息
+ ///
+ ///
+ public virtual async Task GetRobotInfo(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetRobotInfoAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置机器人安装方向
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetInstallDirection(InstallDirection installDirection,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetInstallDirectionAsync(installDirection,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置碰撞检测
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetCollisionDetector(CollisionDetector collisionDetector,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetCollisionDetectorAsync(collisionDetector,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置关节配置
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetJointConfig(JointConfigs jointConfigs,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetJointConfigAsync(jointConfigs,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置笛卡尔空间的配置
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetCartesianConfig(CartesianConfig cartesianConfig,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetCartesianConfigAsync(cartesianConfig,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 开启DDS
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task EnableDDS(TrueOrFalse trueOrFalse,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.EnableDDSAsync(trueOrFalse, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置碰撞检测力矩差阈值
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetCollisionTorqueDiff(CollisionTorqueDiff collisionTorqueDiff,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetCollisionTorqueDiffAsync(collisionTorqueDiff,
+ cancellationToken: cancellationToken);
+ }
+
+ // 注册通知事件
+ /*public virtual async stream Notification RegisterNotification(google.protobuf.Empty){
+ await RobotPrivateControllerClient.RegisterNotification(new Empty(),cancellationToken:cancellationToken);
+ }*/
+ public virtual async Task RobotDriverInfo(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.RobotDriverInfoAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ /*// 机器人OTA单个设备更新接口
+ public virtual async stream OTAResult RobotOTA(OTAData){
+ await RobotPrivateControllerClient.RobotOTAAsync(cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 通知灯板、法兰、关节切换分区
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SwitchOtaPartition(OTACmd otaCmd,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SwitchOtaPartitionAsync(otaCmd,
+ cancellationToken: cancellationToken);
+ }
+
+ /*// 机器人OTA批量更新接口
+ public virtual async stream OTAResults RobotOTABatch(OTADatas){
+ await RobotPrivateControllerClient.RobotOTABatchAsync(cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 重置
+ ///
+ ///
+ public virtual async Task Reset(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ResetAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 以给定角度置零
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task InitZero(Zero zero, CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.InitZeroAsync(zero, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 以零位置零
+ ///
+ ///
+ public virtual async Task SetZero(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetZeroAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取机器人电压V
+ ///
+ ///
+ public virtual async Task GetVoltage(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetVoltageAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置单关节伺服参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetServoParam(JointServoParam jointServoParam,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetServoParamAsync(jointServoParam,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取当前所有关节伺服参数
+ ///
+ ///
+ public virtual async Task GetServoParams(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetServoParamsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 调试设置
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetDebugParams(DebugParams debugParams,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetDebugParamsAsync(debugParams,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 更改DH参数(三轴平行6参数)
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task FixDHParams(FixDHRequest fixDhRequest,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.FixDHParamsAsync(fixDhRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置LED样式
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetLEDStyle(LEDStyle ledStyle,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetLEDStyleAsync(ledStyle, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取LED样式
+ ///
+ ///
+ public virtual async Task GetLEDStyles(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetLEDStylesAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ /*// 注册命令状态事件
+ public virtual async stream LuaEvent RegisterLuaEvent(){
+ await RobotPrivateControllerClient.RegisterLuaEventAsync(new Empty,cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 当推送 ALERT/CONFIRM/INPUT/SELECT,用户在前端确定后调用该接口
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task ConfirmCallback(ConfirmInput confirmInput,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ConfirmCallbackAsync(confirmInput,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 获取 Lua 上次执行到的机器人位置
+ ///
+ ///
+ public virtual async Task GetLastPose(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetLastPoseAsync(new Empty(), cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 配置Modbus外部IO设备
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetModbusExternalIO(ModbusExternalIOs modbusExternalIOs,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetModbusExternalIOAsync(modbusExternalIOs,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 修改按钮配置
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetButtonConfig(ButtonConfig buttonConfig,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetButtonConfigAsync(buttonConfig,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置绑定设备开关, true: 不限制设备绑定; false:限制设备绑定逻辑
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetBreakACup(TrueOrFalse trueOrFalse,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetBreakACupAsync(trueOrFalse, cancellationToken: cancellationToken);
+ }
+
+ /*// PVAT数据记录接口,用户记录pvat数据
+ public virtual async stream RecordPVATResponse RecordPVAT(RecordPVATRequest){
+ await RobotPrivateControllerClient.RecordPVATAsync(cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 停止记录pvat数据
+ ///
+ ///
+ public virtual async Task StopRecordPVAT(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.StopRecordPVATAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ /*// 语音升级
+ public virtual async stream VoiceResult,cancellationToken:cancellationToken);//yvoi UpgradeVoiceFile(VoiceFile){
+ await RobotPrivateControllerClient.UpgradeVoiceFileAsync(cancellationToken:cancellationToken);
+ }*/
+
+ ///
+ /// 获取当前 DH 参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task GetDHParams(DHRequest dhRequest,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.GetDHParamsAsync(dhRequest, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 设置 DH 参数并返回设置后的结果
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SetDHParams(DHParams dhParams,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SetDHParamsAsync(dhParams, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写伺服控制参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteExtraServoParam(ExtraServoParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteExtraServoParamAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读取伺服控制参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task ReadExtraServoParam(ExtraServoParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadExtraServoParamAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写多个伺服控制参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteExtraServoParams(ExtraServoParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteExtraServoParamsAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读取多个伺服控制参数
+ ///
+ ///
+ public virtual async Task ReadExtraServoParams(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadExtraServoParamsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 重置伺服控制参数
+ ///
+ ///
+ public virtual async Task ResetExtraServoParams(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ResetExtraServoParamsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写“主动消回差”参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteJointBacklash(JointBacklash param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteJointBacklashAsync(param, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读取“主动消回差”参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task ReadJointBacklash(JointBacklash param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadJointBacklashAsync(param, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写“主动消回差”参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteJointBacklashes(JointBacklash param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteJointBacklashesAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读取多个“主动消回差”参数
+ ///
+ ///
+ public virtual async Task ReadJointBacklashes(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadJointBacklashesAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 重置“主动消回差”参数
+ ///
+ ///
+ public virtual async Task ResetJointBacklashes(CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ResetJointBacklashesAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 启用主动消回差
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteEnableJointBacklashes(EnableJointBacklash param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteEnableJointBacklashesAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 是否启用主动消回差
+ ///
+ ///
+ public virtual async Task ReadEnableJointBacklashes(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadEnableJointBacklashesAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 重置主动消回差
+ ///
+ ///
+ public virtual async Task ResetEnableJointBacklashes(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ResetEnableJointBacklashesAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写关节回差参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteJointBacklashParam(JointBacklashParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteJointBacklashParamAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读取关节回差参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task ReadJointBacklashParam(JointBacklashParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadJointBacklashParamAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 写多个关节回差参数
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task WriteJointBacklashParams(JointBacklashParam param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.WriteJointBacklashParamsAsync(param,
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 读多个关节回差参数
+ ///
+ ///
+ public virtual async Task ReadJointBacklashParams(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ReadJointBacklashParamsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 重置关节回差参数
+ ///
+ ///
+ public virtual async Task ResetJointBacklashParams(
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.ResetJointBacklashParamsAsync(new Empty(),
+ cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 启用关节限位检测
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task EnableJointLimit(TrueOrFalse param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.EnableJointLimitAsync(param, cancellationToken: cancellationToken);
+ }
+
+ ///
+ /// 切换模拟环境
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task SwitchSimulate(TrueOrFalse param,
+ CancellationToken cancellationToken = default)
+ {
+ return await RobotPrivateControllerClient.SwitchSimulateAsync(param, cancellationToken: cancellationToken);
+ }
+
+#if NET5_0||NET6_0
+ ///
+ /// 获取机器人概要数据流
+ ///
+ ///
+ public IAsyncEnumerable GetRobotBriefDataStream(CancellationToken cancellationToken = default)
+ {
+ return RobotControllerClient.GetRobotBriefData().ResponseStream
+ .ReadAllAsync(cancellationToken);
+ }
+
+ ///
+ /// 获取机器人的IO数据流
+ ///
+ ///
+ public virtual IAsyncEnumerable GetRobotIODataStream(CancellationToken cancellationToken = default)
+ {
+ return RobotControllerClient.GetRobotIOData().ResponseStream
+ .ReadAllAsync(cancellationToken);
+ }
+
+ ///
+ /// 获取机器人的IO数据流
+ ///
+ ///
+ public virtual AsyncDuplexStreamingCall GetRobotIOData(
+ CancellationToken cancellationToken = default)
+ {
+ return RobotControllerClient.GetRobotIOData(cancellationToken: cancellationToken);
+ }
+#endif
+ /*// 连接/断开 MODBUS 设备
+ public virtual async Task ConnectExternalIO(ExternalIOState param){
+ return await RobotPrivateControllerClient.ConnectExternalIOAsync(param,cancellationToken:cancellationToken);
+ }*/
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/LeibaiRobotClient_HttpPart.cs b/Lebai.SDK/LeibaiRobotClient_HttpPart.cs
new file mode 100644
index 00000000..b55e7294
--- /dev/null
+++ b/Lebai.SDK/LeibaiRobotClient_HttpPart.cs
@@ -0,0 +1,275 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+using Lebai.SDK.Dtos;
+using Lebai.SDK.Exceptions;
+using TaskStatus = Lebai.SDK.Dtos.TaskStatus;
+#if NET5_0||NET6_0
+using System.Net.Http.Json;
+
+#endif
+
+namespace Lebai.SDK
+{
+ public class EnumExtension
+ {
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string GetEnumDescription(T tField)
+ {
+ var description = string.Empty; //结果
+ var inputType = tField.GetType(); //输入的类型
+ var descType = typeof(DescriptionAttribute); //目标查找的描述类型
+
+ var fieldStr = tField.ToString(); //输入的字段字符串
+ var field = inputType.GetField(fieldStr); //目标字段
+
+ var isDefined = field.IsDefined(descType, false); //判断描述是否在字段的特性
+ if (isDefined)
+ {
+ var enumAttributes = (DescriptionAttribute[]) field //得到特性信息
+ .GetCustomAttributes(descType, false);
+ description = enumAttributes.FirstOrDefault()?.Description ?? string.Empty;
+ }
+
+ return description;
+ }
+ }
+
+ public partial class LebaiRobotClient
+ {
+ public static Dictionary CodeMessage = new()
+ {
+ [2001] = "系统异常",
+ [2002] = "登录授权码错误",
+ [2003] = "登录授权码已失效",
+ [2004] = "机器人控制系统异常",
+ [2005] = "404",
+ [2006] = "参数错误",
+ [2007] = "数据不存在",
+ [2009] = "请登录",
+ [2010] = "同一时间只能有一个用户登录",
+ [2011] = "队列任务执行报错",
+ [2012] = "机器人任务运行中不能运行其他任务",
+ [2015] = "场景导入失败,导入文件格式错误",
+ [2021] = "数据库异常",
+ [2022] = "签名失败",
+ [2023] = "任务队列恢复失败,手臂当前位置与即将运行轨迹的首个位置数据校验失败",
+ [2024] = "无效机器人操作命令",
+ [2025] = "机器人当前状态没有满足执行当前指令的预期(废弃)",
+ [2026] = "请求超时",
+ [2027] = "网络配置中,不能频繁进行操作",
+ [2028] = "条件任务执行超时",
+
+ [2029] = "机器人控制系统故障,请重启机器人后再试",
+ [2030] = "机器人通信故障,请检查机器人是否已正确连接",
+ [2031] = "机器人初始化中,请稍候再试",
+ [2032] = "机器人更新中,请稍候再试",
+ [2033] = "机器人启动中,请稍候再试",
+ [2034] = "机器人停止中,请稍候再试",
+ [2035] = "请结束示教操作后再试",
+ [2036] = "请先停止任务历史中的当前任务后再执行相应操作",
+ [2037] = "仿真模式暂不支持该功能"
+ };
+
+ ///
+ /// 获取指定任务信息
+ ///
+ ///
+ ///
+ ///
+ public virtual async ValueTask GetTask(int id, CancellationToken cancellationToken = default)
+ {
+ var response = await _httpClient.GetAsync($"/public/task?id={id}", cancellationToken);
+
+ var r = await response.Content.ReadFromJsonAsync>(
+ cancellationToken: cancellationToken);
+ HandleResult(r, $"场景Id:{id}");
+ return r?.Data.ToTaskInfo();
+ }
+
+ ///
+ /// 获取任务信息
+ ///
+ ///
+ ///
+ ///
+ public virtual async ValueTask GetTasks(GetTasksInput input,
+ CancellationToken cancellationToken = default)
+ {
+ var response = _httpClient
+ .GetAsync($"/public/tasks?pi={input.PageIndex}&ps={input.PageSize}", cancellationToken).Result;
+ var r = await response.Content.ReadFromJsonAsync>(
+ cancellationToken: cancellationToken);
+
+ HandleResult(r);
+ return r?.Data?.ToResult();
+ }
+
+ ///
+ /// 检测是否能运行任务(机器人是否正在运行其他任务)
+ ///
+ ///
+ public virtual async ValueTask GetIsCanRunTask(CancellationToken cancellationToken = default)
+ {
+ var result = await GetTasks(new GetTasksInput {PageIndex = 1, PageSize = 1}, cancellationToken);
+ var first = result?.Items?.FirstOrDefault();
+ return first == null || first.Status != TaskStatus.Running && first.Status != TaskStatus.Pause;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual async ValueTask CheckRobotStatus(CancellationToken cancellationToken = default)
+ {
+ var result = await GetTasks(new GetTasksInput {PageIndex = 1, PageSize = 1}, cancellationToken);
+ var first = result?.Items?.FirstOrDefault();
+ var r= first == null || first.Status != TaskStatus.Running && first.Status != TaskStatus.Pause;
+
+ if (!r) throw new Exception($"机器人正在执行其他任务!,任务数量:{result?.Items} 真正运行的其他任务: {first.Status}");
+ }
+
+ ///
+ /// 运行任务
+ ///
+ /// 任务Id
+ /// 执行次数
+ /// 是否强制停止正在运行的任务
+ ///
+ ///
+ public virtual async Task RunTask(int id, int executeCount = 1,
+ bool clear = true, CancellationToken cancellationToken = default)
+ {
+ await CheckRobotStatus(cancellationToken);
+ var response = _httpClient.PostAsJsonAsync("/public/task", new
+ {
+ execute_count = executeCount,
+ clear = clear ? 1 : 0,
+ task_id = id
+ }, cancellationToken).Result;
+ var r = await response.Content.ReadFromJsonAsync>(
+ cancellationToken: cancellationToken);
+ HandleResult(r);
+ return r?.Data;
+ }
+
+ ///
+ /// 运行场景
+ ///
+ /// 场景Id
+ /// 运行次数
+ /// 是否强制停止正在运行的场景
+ ///
+ ///
+ public virtual async Task RunScene(int id, int executeCount = 1,
+ bool clear = false, CancellationToken cancellationToken = default)
+ {
+ await CheckRobotStatus(cancellationToken);
+
+ var response = _httpClient.PostAsJsonAsync("/public/task", new
+ {
+ execute_count = executeCount,
+ clear = clear ? 1 : 0,
+ scene_id = id
+ }, cancellationToken).Result;
+ var r = await response.Content.ReadFromJsonAsync>(
+ cancellationToken: cancellationToken);
+ HandleResult(r, $"场景Id:{id}");
+ return r?.Data;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected void HandleResult(LebaiHttpResult result, string message = "")
+ {
+ if (result?.Code != 0)
+ throw new HttpRequestException($"调用失败,{message},Code:{result.Code}" +
+ (CodeMessage.ContainsKey(result.Code)
+ ? $",{CodeMessage[result.Code]}"
+ : ""));
+ }
+
+ ///
+ /// 等待任务运行完成
+ ///
+ /// 任务Id
+ ///
+ ///
+ ///
+ ///
+ public virtual async ValueTask WaitTaskRunCompleted(int id,
+ CancellationToken cancellationToken = default)
+ {
+ TaskInfo taskInfo = await GetTask(id, cancellationToken);
+ while (true)
+ {
+ if (cancellationToken.IsCancellationRequested) throw new OperationCanceledException();
+
+ if (taskInfo?.Status is TaskStatus.Running or TaskStatus.Idea)
+ {
+ await Task.Delay(100, cancellationToken);
+ taskInfo = await GetTask(id, cancellationToken);
+ }
+ else if (taskInfo?.Status is TaskStatus.RunSuccess)
+ {
+ break;
+ }
+ else
+ {
+ throw new RobotTaskException(taskInfo?.Status);
+ }
+ }
+
+ return taskInfo;
+ }
+
+ ///
+ /// 运行场景直到运行完成
+ ///
+ /// 场景Id
+ /// 执行次数
+ /// 是否强制停止正在运行的场景
+ ///
+ ///
+ public virtual async Task RunSceneUntilDone(int id, int executeCount = 1,
+ bool clear = false, CancellationToken cancellationToken = default)
+ {
+ var r = await RunScene(id, executeCount, clear, cancellationToken);
+
+ return await WaitTaskRunCompleted(r.Id, cancellationToken);
+ }
+
+ ///
+ /// 执行Lua 代码
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task ExecuteLua(string luaCode,
+ CancellationToken cancellationToken = default)
+ {
+ var response =
+ await _httpClient.PostAsync("/public/executor/lua", new StringContent(luaCode), cancellationToken);
+ var r = await response.Content.ReadFromJsonAsync>(
+ cancellationToken: cancellationToken);
+
+ HandleResult(r);
+ return r?.Data;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Lebai.SDK/Protos/os_server.proto b/Lebai.SDK/Protos/os_server.proto
new file mode 100644
index 00000000..b60d82b8
--- /dev/null
+++ b/Lebai.SDK/Protos/os_server.proto
@@ -0,0 +1,56 @@
+syntax = "proto3";
+// compile method:
+// 1. cpp:
+// protoc --grpc_out=./ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` *.proto
+// protoc --cpp_out=. *.proto
+// 2. python:
+// protoc --python_out=. *.proto
+//import "google/protobuf/empty.proto";
+// build for web
+// protoc -I=./ *.proto --js_out=import_style=commonjs:./ --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./
+
+package osserver;
+
+service OsServer {
+ rpc getRingData(Req) returns (stream RingData);
+}
+
+message Req {
+ int32 req = 1;
+}
+
+message PR {
+ double x = 1;
+ double y = 2;
+ double z = 3;
+ double rr = 4;
+ double rp = 5;
+ double ry = 6;
+}
+
+message Joint {
+ double targetPose = 1;
+ double targetV = 2;
+ double targetA = 3;
+ double targetTorque = 4;
+ double actualPose = 5;
+ double actualV = 6;
+ double actualA = 7;
+ double actualTorque = 8;
+ double temperature = 9;
+}
+
+message RingData {
+ repeated Joint joints = 1;
+ int32 num = 2;
+ PR targetPose = 3;
+ PR actualPose = 4;
+ CurrentVoltage voltage = 5;
+}
+
+message CurrentVoltage {
+ double power = 1; // 电源电压V/电流mA
+ double flan = 2; // 法兰电压/电流
+ repeated double joint = 3; // 关节电压/电流
+ double io_power = 4; // IO板
+}
diff --git a/Lebai.SDK/Protos/private_controller.proto b/Lebai.SDK/Protos/private_controller.proto
new file mode 100644
index 00000000..87c7d52c
--- /dev/null
+++ b/Lebai.SDK/Protos/private_controller.proto
@@ -0,0 +1,606 @@
+/**
+ * Copyright © 2017-2018 Shanghai Lebai Robotic Co., Ltd. All rights reserved.
+ *
+ * FileName: robot_controller.proto
+ *
+ * Author: Yonnie Lu
+ * Email: zhangyong.lu@lebai.ltd
+ * Date: 2019-10-31 10:20:01
+ * Description:
+ * History:
+ *