@@ -14,6 +14,7 @@ | |||
<ProjectReference Include="..\HBLConsole.GVL\HBLConsole.GVL.csproj" /> | |||
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" /> | |||
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" /> | |||
<ProjectReference Include="..\Lebai.SDK\Lebai.SDK.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -0,0 +1,49 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Lebai.SDK; | |||
using Robotc; | |||
namespace HBLConsole.Communication | |||
{ | |||
public class LebaiHelper | |||
{ | |||
private volatile static LebaiHelper _Instance; | |||
public static LebaiHelper GetInstance => _Instance ?? (_Instance = new LebaiHelper()); | |||
private LebaiHelper() { } | |||
private LebaiRobotClient client; | |||
public void Connect(string ip) | |||
{ | |||
client = new LebaiRobotClient(ip); | |||
} | |||
/// <summary> | |||
/// 获取信号量 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns></returns> | |||
public SignalResult GetValue(int index) | |||
{ | |||
SignalValue signalValue = new SignalValue(); | |||
signalValue.Index = index; | |||
return client?.GetSignal(signalValue).Result; | |||
} | |||
/// <summary> | |||
/// 设置信号量 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public SignalResult SetValue(int index, int value) | |||
{ | |||
SignalValue signalValue = new SignalValue(); | |||
signalValue.Index = index; | |||
signalValue.Value = value; | |||
return client?.SetSignal(signalValue).Result; | |||
} | |||
} | |||
} |
@@ -72,15 +72,6 @@ namespace HBLConsole.Factory | |||
/// </summary> | |||
public void DeviceInit() | |||
{ | |||
//string NameSpace = "HBLConsole.Business";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
//Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.Devices.{DeviceType}"); | |||
//IControl business = (IControl)type?.GetProperty("GetInstance").GetValue(null); | |||
//GetBatchingInfo(); | |||
//business?.Init(); | |||
//ActionManagerment.GetInstance.Register(new Action<object>((o) => { business?.DataParse(o); }), "DataParse"); | |||
//ActionManagerment.GetInstance.Register(new Action(() => { business?.ConnectOk(); }), "ConnectOk"); | |||
//ConnectHelper.GetInstance.Init(); | |||
string NameSpace = $"HBLConsole.{DeviceType}";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{DeviceType}"); | |||
control = Activator.CreateInstance(type) as IControl; | |||
@@ -33,6 +33,7 @@ namespace HBLConsole.MainConsole | |||
else { GeneralConfig.DeviceType = DeviceClientType.MORKS; } | |||
Json<MorkOrderPushPar>.Read(); | |||
Json<BatchingInfoPar>.Read(); | |||
Json<SimOrderConfig>.Read(); | |||
MessageLog.GetInstance.Show($"启动【{GeneralConfig.DeviceType}】设备"); | |||
} | |||
@@ -42,6 +43,7 @@ namespace HBLConsole.MainConsole | |||
Json<MorkOrderPushPar>.Save(); | |||
Json<BatchingInfoPar>.Save(); | |||
Json<SetPar>.Save(); | |||
Json<SimOrderConfig>.Save(); | |||
TextHelper.GetInstance.SaveLogInfo(MessageLog.GetInstance.LogInfo, "LogInfo"); | |||
} | |||
@@ -0,0 +1,44 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using System.Collections.Concurrent; | |||
namespace HBLConsole.Model | |||
{ | |||
/// <summary> | |||
/// 连接设备类型分类 | |||
/// </summary> | |||
public class DeviceTypeSort | |||
{ | |||
private volatile static DeviceTypeSort _Instance; | |||
public static DeviceTypeSort GetInstance => _Instance ?? (_Instance = new DeviceTypeSort()); | |||
private DeviceTypeSort() | |||
{ | |||
List<string> DeviceName; | |||
DeviceName = new List<string>(); | |||
DeviceName.Add(EDeviceType.Siemens.ToString()); | |||
DevceTypes.TryAdd(EDeviceTypeSort.Siemens.ToString(), DeviceName); | |||
DeviceName = new List<string>(); | |||
DeviceName.Add(EDeviceType.ModbusTcp.ToString()); | |||
DeviceName.Add(EDeviceType.Lebai.ToString()); | |||
DeviceName.Add(EDeviceType.JAKA.ToString()); | |||
DevceTypes.TryAdd(EDeviceTypeSort.TCP.ToString(), DeviceName); | |||
DeviceName = new List<string>(); | |||
DeviceName.Add(EDeviceType.ModbusRtu.ToString()); | |||
DeviceName.Add(EDeviceType.SerialPort.ToString()); | |||
DeviceName.Add(EDeviceType.Coffee.ToString()); | |||
DeviceName.Add(EDeviceType.IceCream.ToString()); | |||
DevceTypes.TryAdd(EDeviceTypeSort.Serial.ToString(), DeviceName); | |||
} | |||
public ConcurrentDictionary<string, List<string>> DevceTypes { get; set; } = new ConcurrentDictionary<string, List<string>>(); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.Model | |||
{ | |||
public enum EDeviceTypeSort | |||
{ | |||
Siemens, | |||
TCP, | |||
Serial | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.Model | |||
{ | |||
public class SimOrderConfig | |||
{ | |||
public List<SimOrderVisibleData> simOrderConfig { get; set; } = new List<SimOrderVisibleData>(); | |||
} | |||
} |
@@ -9,6 +9,10 @@ namespace HBLConsole.Model | |||
{ | |||
public class SimOrderVisibleData : ObservableObject | |||
{ | |||
public string ClientDeviceType { get { return _mClientDeviceType; } set { _mClientDeviceType = value; OnPropertyChanged(); } } | |||
private string _mClientDeviceType; | |||
public ushort Loc { get { return _mLoc; } set { _mLoc = value; OnPropertyChanged(); } } | |||
private ushort _mLoc; | |||
@@ -21,5 +25,13 @@ namespace HBLConsole.Model | |||
public string Text { get { return _mText; } set { _mText = value; OnPropertyChanged(); } } | |||
private string _mText; | |||
public int MinValue { get { return _mMinValue; } set { _mMinValue = value; OnPropertyChanged(); } } | |||
private int _mMinValue; | |||
public int MaxValue { get { return _mMaxValue; } set { _mMaxValue = value; OnPropertyChanged(); } } | |||
private int _mMaxValue; | |||
} | |||
} |
@@ -27,7 +27,7 @@ namespace HBLConsole.Service | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile")); | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DB\\{typeof(T).Name}.db"; | |||
} | |||
} | |||
@@ -27,9 +27,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Factory", "HBLCo | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.Attributes", "HBLConsole.Attribute\HBLConsole.Attributes.csproj", "{9F022DDD-B69C-4AC9-AFB0-0A688EAA1F64}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HBLConsole.MORKS", "HBLConsole.MORKS\HBLConsole.MORKS.csproj", "{B14C829F-CE03-4DBC-93A7-5E3D2787E280}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.MORKS", "HBLConsole.MORKS\HBLConsole.MORKS.csproj", "{B14C829F-CE03-4DBC-93A7-5E3D2787E280}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HBLConsole.MORKD", "HBLConsole.MORKD\HBLConsole.MORKD.csproj", "{FE578C47-A26C-48EF-A06A-EF359B04737F}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HBLConsole.MORKD", "HBLConsole.MORKD\HBLConsole.MORKD.csproj", "{FE578C47-A26C-48EF-A06A-EF359B04737F}" | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lebai.SDK", "Lebai.SDK\Lebai.SDK.csproj", "{EA97657F-5C1A-440F-8F92-ED0DBA6F9ED5}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
@@ -93,6 +95,10 @@ Global | |||
{FE578C47-A26C-48EF-A06A-EF359B04737F}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{FE578C47-A26C-48EF-A06A-EF359B04737F}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{FE578C47-A26C-48EF-A06A-EF359B04737F}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{EA97657F-5C1A-440F-8F92-ED0DBA6F9ED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{EA97657F-5C1A-440F-8F92-ED0DBA6F9ED5}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{EA97657F-5C1A-440F-8F92-ED0DBA6F9ED5}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{EA97657F-5C1A-440F-8F92-ED0DBA6F9ED5}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -6,6 +6,7 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows; | |||
using HBLConsole.Model; | |||
namespace HBLConsole.Converter | |||
{ | |||
@@ -15,10 +16,17 @@ namespace HBLConsole.Converter | |||
{ | |||
if (value != null && parameter != null) | |||
{ | |||
if (value.ToString() == parameter.ToString()) | |||
if (DeviceTypeSort.GetInstance.DevceTypes.ContainsKey(parameter.ToString())) | |||
{ | |||
return Visibility.Visible; | |||
List<string> list = DeviceTypeSort.GetInstance.DevceTypes[parameter.ToString()]; | |||
if (list != null) | |||
{ | |||
var result = list.FirstOrDefault(p => p == value.ToString() && value?.ToString()?.Length > 0); | |||
if (result != null) | |||
{ | |||
return Visibility.Visible; | |||
} | |||
} | |||
} | |||
} | |||
return Visibility.Collapsed; | |||
@@ -0,0 +1,12 @@ | |||
<Window x:Class="HBLConsole.DialogWindow.View.SimOrderConfitView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:local="clr-namespace:HBLConsole.DialogWindow.View" | |||
mc:Ignorable="d" | |||
Title="SimOrderConfitView" Height="450" Width="800"> | |||
<Grid> | |||
</Grid> | |||
</Window> |
@@ -0,0 +1,27 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Shapes; | |||
namespace HBLConsole.DialogWindow.View | |||
{ | |||
/// <summary> | |||
/// SimOrderConfitView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class SimOrderConfitView : Window | |||
{ | |||
public SimOrderConfitView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace HBLConsole.DialogWindow.ViewModel | |||
{ | |||
public class SimOrderConfitViewModel | |||
{ | |||
} | |||
} |
@@ -81,10 +81,10 @@ | |||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="请选择客户端启动设备类型:" /> | |||
<ComboBox | |||
Width="150" | |||
Margin="0,0,20,0" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF23CACA" | |||
Width="150" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
@@ -277,7 +277,7 @@ | |||
<!--#region Modbus Tcp 设备--> | |||
<Grid Grid.Row="2" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert}, ConverterParameter=ModbusTcp}"> | |||
<Grid Grid.Row="2" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert}, ConverterParameter=TCP}"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
@@ -359,7 +359,7 @@ | |||
<!--#region Modbus RTU 设备--> | |||
<Grid Grid.Row="3" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert}, ConverterParameter=ModbusRtu}"> | |||
<Grid Grid.Row="3" Visibility="{Binding Path=deviceType, Converter={StaticResource VisibleConvert}, ConverterParameter=Serial}"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
@@ -30,7 +30,7 @@ namespace HBLConsole.ViewModel | |||
SaveDeviceData(); | |||
VisibleDeviceData(); | |||
ActionOperate.GetInstance.Register(new Func<object, object>((p) => | |||
{ | |||
@@ -43,23 +43,29 @@ namespace HBLConsole.ViewModel | |||
ClientDeviceType = Json<SetPar>.Data.ClientDeviceType; | |||
} | |||
static DeviceManageViewModel() | |||
{ | |||
VisibleDeviceData(); | |||
} | |||
private void SaveDeviceData() | |||
{ | |||
ActionOperate.GetInstance.Register(new Action(() => | |||
{ | |||
var rr = Json<CommunicationPar>.Data.communicationSets.Where(p => p.ClientDeviceType != GVL.GeneralConfig.DeviceType.ToString()).ToList(); | |||
if (rr != null) | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.Clear(); | |||
rr.ForEach((o) => | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.Add(o); | |||
}); | |||
} | |||
foreach (var item in communicationSets) | |||
{ | |||
item.RemoveAction = null; | |||
int index = Array.FindIndex(Json<CommunicationPar>.Data.communicationSets.ToArray(), p => p.DeviceName == item.DeviceName && p.ClientDeviceType == item.ClientDeviceType); | |||
if (index >= 0) | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.RemoveAt(index); | |||
Json<CommunicationPar>.Data.communicationSets.Add(item); | |||
} | |||
else | |||
{ | |||
Json<CommunicationPar>.Data.communicationSets.Add(item); | |||
} | |||
Json<CommunicationPar>.Data.communicationSets.Add(item); | |||
} | |||
Json<CommunicationPar>.Save(); | |||
@@ -67,7 +73,7 @@ namespace HBLConsole.ViewModel | |||
} | |||
private void VisibleDeviceData() | |||
private static void VisibleDeviceData() | |||
{ | |||
if (communicationSets.Count <= 0) | |||
{ | |||
@@ -118,19 +124,43 @@ namespace HBLConsole.ViewModel | |||
{ | |||
CommunicationSet communicationObj = new CommunicationSet(); | |||
EDeviceType eDeviceType = (EDeviceType)Enum.Parse(typeof(EDeviceType), ResultTag.DeviceType); | |||
//if (Enum.TryParse(ResultTag.DeviceType, out EDataType eDeviceType)) | |||
//{ | |||
string? NameSpace = "HBLConsole.Model";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
Type type = Assembly.Load(NameSpace)?.GetType($"{NameSpace}.{ResultTag.DeviceType}"); | |||
if (type != null) | |||
foreach (var item in Enum.GetNames(typeof(EDeviceTypeSort))) | |||
{ | |||
communicationObj.Device = Activator.CreateInstance(type) as IDeviceType; | |||
var res = DeviceTypeSort.GetInstance.DevceTypes[item].FirstOrDefault(p => p == ResultTag.DeviceType); | |||
if (res != null) | |||
{ | |||
string device = string.Empty; | |||
switch ((EDeviceTypeSort)Enum.Parse(typeof(EDeviceTypeSort), item)) | |||
{ | |||
case EDeviceTypeSort.Siemens: | |||
device = EDeviceType.Siemens.ToString(); | |||
break; | |||
case EDeviceTypeSort.TCP: | |||
device = EDeviceType.ModbusTcp.ToString(); | |||
break; | |||
case EDeviceTypeSort.Serial: | |||
device = EDeviceType.ModbusRtu.ToString(); | |||
break; | |||
default: | |||
break; | |||
} | |||
string NameSpace = "HBLConsole.Model";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类 | |||
var type = Assembly.Load(NameSpace)?.GetType($"{NameSpace}.{device}"); | |||
if (type != null) | |||
{ | |||
communicationObj.Device = Activator.CreateInstance(type) as IDeviceType; | |||
} | |||
communicationObj.DeviceName = $"{ResultTag.DeviceName}【{eDeviceType}】"; | |||
communicationObj.deviceType = eDeviceType; | |||
communicationObj.RemoveAction = RemoveDevice; | |||
communicationObj.ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(); | |||
communicationSets.Add(communicationObj); | |||
return; | |||
} | |||
} | |||
communicationObj.DeviceName = $"{ResultTag.DeviceName}【{eDeviceType}】"; | |||
communicationObj.deviceType = eDeviceType; | |||
communicationObj.RemoveAction = RemoveDevice; | |||
communicationObj.ClientDeviceType = GVL.GeneralConfig.DeviceType.ToString(); | |||
communicationSets.Add(communicationObj); | |||
//} | |||
} | |||
@@ -139,13 +169,18 @@ namespace HBLConsole.ViewModel | |||
deviceManagermentSetView = null; | |||
} | |||
private void RemoveDevice(object o) | |||
private static void RemoveDevice(object o) | |||
{ | |||
var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString()); | |||
if (result != null) | |||
int index = Array.FindIndex(communicationSets.ToArray(), p => p.DeviceName == o.ToString()); | |||
if (index >= 0 && index < communicationSets.Count) | |||
{ | |||
communicationSets.Remove(result); | |||
communicationSets.RemoveAt(index); | |||
} | |||
//var result = communicationSets.FirstOrDefault(p => p.DeviceName == o.ToString()); | |||
//if (result != null) | |||
//{ | |||
// communicationSets.Remove(result); | |||
//} | |||
} | |||
@@ -0,0 +1,15 @@ | |||
namespace Lebai.SDK.Dtos | |||
{ | |||
public class GetTasksInput | |||
{ | |||
/// <summary> | |||
/// 页索引 | |||
/// </summary> | |||
public int PageIndex { get; set; } = 1; | |||
/// <summary> | |||
/// 页大小 | |||
/// </summary> | |||
public int PageSize { get; set; } = 10; | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
namespace Lebai.SDK.Dtos | |||
{ | |||
public class LebaiHttpResult<T> | |||
{ | |||
/// <summary> | |||
/// 数据 | |||
/// </summary> | |||
public T Data { get; set; } | |||
/// <summary> | |||
/// 错误码 | |||
/// </summary> | |||
public int Code { get; set; } | |||
} | |||
} |
@@ -0,0 +1,85 @@ | |||
using System.ComponentModel; | |||
namespace Lebai.SDK.Dtos | |||
{ | |||
public enum RobotStatus | |||
{ | |||
/// <summary> | |||
/// 已断开连接 | |||
/// </summary> | |||
[Description("已断开连接")] DISCONNECTED = 0, | |||
/// <summary> | |||
/// 急停停止状态 | |||
/// </summary> | |||
[Description("急停停止状态")] ESTOP = 1, | |||
/// <summary> | |||
/// 启动中 | |||
/// </summary> | |||
[Description("启动中")] BOOTING = 2, | |||
/// <summary> | |||
/// 电源关闭 | |||
/// </summary> | |||
[Description("电源关闭")] ROBOT_OFF = 3, | |||
/// <summary> | |||
/// 电源开启 | |||
/// </summary> | |||
[Description("电源开启")] ROBOT_ON = 4, | |||
/// <summary> | |||
/// 空闲中 | |||
/// </summary> | |||
[Description("空闲中")] IDLE = 5, | |||
/// <summary> | |||
/// 暂停中 | |||
/// </summary> | |||
[Description("暂停中")] PAUSED = 6, | |||
/// <summary> | |||
/// 机器人运动运行中 | |||
/// </summary> | |||
[Description("机器人运动运行中")] RUNNING = 7, | |||
/// <summary> | |||
/// 更新固件中 | |||
/// </summary> | |||
[Description("更新固件中")] UPDATING = 8, | |||
/// <summary> | |||
/// 启动中 | |||
/// </summary> | |||
[Description("启动中")] STARTING = 9, | |||
/// <summary> | |||
/// 停止中 | |||
/// </summary> | |||
[Description("停止中")] STOPPING = 10, | |||
/// <summary> | |||
/// 示教中 | |||
/// </summary> | |||
[Description("示教中")] TEACHING = 11, | |||
/// <summary> | |||
/// 普通停止 | |||
/// </summary> | |||
[Description("普通停止")] STOP = 12, | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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; } | |||
/// <summary> | |||
/// 场景Id | |||
/// </summary> | |||
public int? SceneId { get; set; } | |||
/// <summary> | |||
/// 执行次数 | |||
/// </summary> | |||
public int? ExecuteCount { get; set; } | |||
/// <summary> | |||
/// 执行的次数 | |||
/// </summary> | |||
public int? ExecutedCount { get; set; } | |||
/// <summary> | |||
/// 名称 | |||
/// </summary> | |||
public string Name { get; set; } | |||
/// <summary> | |||
/// 状态 | |||
/// </summary> | |||
public TaskStatus? Status { get; set; } | |||
/// <summary> | |||
/// 注释 | |||
/// </summary> | |||
public string Comment { get; set; } | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public string StartTime { get; set; } | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public string EndTime { get; set; } | |||
public long? ConsumeTime { get; set; } | |||
public int? Mode { get; set; } | |||
/// <summary> | |||
/// 创建时间 | |||
/// </summary> | |||
public string CreationTime { get; set; } | |||
/// <summary> | |||
/// 更新时间 | |||
/// </summary> | |||
public string UpdateTime { get; set; } | |||
public int? SceneType { get; set; } | |||
public object FirstPose { get; set; } | |||
} | |||
} |
@@ -0,0 +1,43 @@ | |||
using System.ComponentModel; | |||
namespace Lebai.SDK.Dtos | |||
{ | |||
public enum TaskStatus | |||
{ | |||
/// <summary> | |||
/// 空闲 | |||
/// </summary> | |||
[Description("空闲")] | |||
Idea = 0, | |||
/// <summary> | |||
/// 运行 | |||
/// </summary> | |||
[Description("运行")] | |||
Running = 1, | |||
/// <summary> | |||
/// 暂停 | |||
/// </summary> | |||
[Description("暂停")] | |||
Pause = 2, | |||
/// <summary> | |||
/// 运行成功 | |||
/// </summary> | |||
[Description("运行成功")] | |||
RunSuccess = 3, | |||
/// <summary> | |||
/// 手动停止 | |||
/// </summary> | |||
[Description("手动停止")] | |||
ManualStop = 4, | |||
/// <summary> | |||
/// 异常停止 | |||
/// </summary> | |||
[Description("异常停止")] | |||
AbnormalStop = 5 | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 页索引 | |||
/// </summary> | |||
public int PageIndex { get; set; } | |||
/// <summary> | |||
/// 页大小 | |||
/// </summary> | |||
public int PageSize { get; set; } | |||
/// <summary> | |||
/// 总数量 | |||
/// </summary> | |||
public int TotalCount { get; set; } | |||
/// <summary> | |||
/// 任务列表 | |||
/// </summary> | |||
public TaskInfo[] Items { get; set; } | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} |
@@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | |||
<ConfigureAwait ContinueOnCapturedContext="false" /> | |||
</Weavers> |
@@ -0,0 +1,47 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<Version>0.3.13</Version> | |||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | |||
<TargetFrameworks>net5.0;net6.0</TargetFrameworks> | |||
<RepositoryUrl>https://github.com/lebai-robotics/lebai-dotnet-sdk</RepositoryUrl> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Google.Protobuf" Version="3.19.1" /> | |||
<PackageReference Include="Grpc.Net.Client" Version="2.40.0" /> | |||
<PackageReference Include="Grpc.Tools" Version="2.42.0"> | |||
<PrivateAssets>all</PrivateAssets> | |||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | |||
</PackageReference> | |||
<Protobuf Include="messages.proto"> | |||
<GrpcServices>Client</GrpcServices> | |||
<Access>Public</Access> | |||
<ProtoCompile>True</ProtoCompile> | |||
<CompileOutputs>True</CompileOutputs> | |||
<Generator>MSBuild:Compile</Generator> | |||
</Protobuf> | |||
<Protobuf Include="Protos\os_server.proto"> | |||
<GrpcServices>Client</GrpcServices> | |||
<Generator>MSBuild:Compile</Generator> | |||
</Protobuf> | |||
<Protobuf Include="Protos\private_controller.proto"> | |||
<GrpcServices>Client</GrpcServices> | |||
<Generator>MSBuild:Compile</Generator> | |||
</Protobuf> | |||
<Protobuf Include="Protos\robot_controller.proto"> | |||
<GrpcServices>Client</GrpcServices> | |||
<Generator>MSBuild:Compile</Generator> | |||
</Protobuf> | |||
<Protobuf Include="Protos\robot_test.proto"> | |||
<Generator>MSBuild:Compile</Generator> | |||
<GrpcServices>Client</GrpcServices> | |||
</Protobuf> | |||
<Protobuf Include="Protos\simulation.proto"> | |||
<Generator>MSBuild:Compile</Generator> | |||
<GrpcServices>Client</GrpcServices> | |||
</Protobuf> | |||
</ItemGroup> | |||
</Project> |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="tField"></param> | |||
/// <typeparam name="T"></typeparam> | |||
/// <returns></returns> | |||
public static string GetEnumDescription<T>(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<int, string> 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] = "仿真模式暂不支持该功能" | |||
}; | |||
/// <summary> | |||
/// 获取指定任务信息 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async ValueTask<TaskInfo> GetTask(int id, CancellationToken cancellationToken = default) | |||
{ | |||
var response = await _httpClient.GetAsync($"/public/task?id={id}", cancellationToken); | |||
var r = await response.Content.ReadFromJsonAsync<LebaiHttpResult<OriginTaskInfo>>( | |||
cancellationToken: cancellationToken); | |||
HandleResult(r, $"场景Id:{id}"); | |||
return r?.Data.ToTaskInfo(); | |||
} | |||
/// <summary> | |||
/// 获取任务信息 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async ValueTask<TasksResult> 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<LebaiHttpResult<OriginTasksResult>>( | |||
cancellationToken: cancellationToken); | |||
HandleResult(r); | |||
return r?.Data?.ToResult(); | |||
} | |||
/// <summary> | |||
/// 检测是否能运行任务(机器人是否正在运行其他任务) | |||
/// </summary> | |||
/// <returns></returns> | |||
public virtual async ValueTask<bool> 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; | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="cancellationToken"></param> | |||
/// <exception cref="Exception"></exception> | |||
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}"); | |||
} | |||
/// <summary> | |||
/// 运行任务 | |||
/// </summary> | |||
/// <param name="id">任务Id</param> | |||
/// <param name="executeCount">执行次数</param> | |||
/// <param name="clear">是否强制停止正在运行的任务</param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async Task<TaskExecuteResult> 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<LebaiHttpResult<TaskExecuteResult>>( | |||
cancellationToken: cancellationToken); | |||
HandleResult(r); | |||
return r?.Data; | |||
} | |||
/// <summary> | |||
/// 运行场景 | |||
/// </summary> | |||
/// <param name="id">场景Id</param> | |||
/// <param name="executeCount">运行次数</param> | |||
/// <param name="clear">是否强制停止正在运行的场景</param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async Task<TaskExecuteResult> 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<LebaiHttpResult<TaskExecuteResult>>( | |||
cancellationToken: cancellationToken); | |||
HandleResult(r, $"场景Id:{id}"); | |||
return r?.Data; | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="result"></param> | |||
/// <param name="message"></param> | |||
/// <typeparam name="T"></typeparam> | |||
/// <exception cref="HttpRequestException"></exception> | |||
protected void HandleResult<T>(LebaiHttpResult<T> result, string message = "") | |||
{ | |||
if (result?.Code != 0) | |||
throw new HttpRequestException($"调用失败,{message},Code:{result.Code}" + | |||
(CodeMessage.ContainsKey(result.Code) | |||
? $",{CodeMessage[result.Code]}" | |||
: "")); | |||
} | |||
/// <summary> | |||
/// 等待任务运行完成 | |||
/// </summary> | |||
/// <param name="id">任务Id</param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
/// <exception cref="OperationCanceledException"></exception> | |||
/// <exception cref="RobotTaskException"></exception> | |||
public virtual async ValueTask<TaskInfo> 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; | |||
} | |||
/// <summary> | |||
/// 运行场景直到运行完成 | |||
/// </summary> | |||
/// <param name="id">场景Id</param> | |||
/// <param name="executeCount">执行次数</param> | |||
/// <param name="clear">是否强制停止正在运行的场景</param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async Task<TaskInfo> 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); | |||
} | |||
/// <summary> | |||
/// 执行Lua 代码 | |||
/// </summary> | |||
/// <param name="luaCode"></param> | |||
/// <param name="cancellationToken"></param> | |||
/// <returns></returns> | |||
public virtual async Task<TaskExecuteResult> ExecuteLua(string luaCode, | |||
CancellationToken cancellationToken = default) | |||
{ | |||
var response = | |||
await _httpClient.PostAsync("/public/executor/lua", new StringContent(luaCode), cancellationToken); | |||
var r = await response.Content.ReadFromJsonAsync<LebaiHttpResult<TaskExecuteResult>>( | |||
cancellationToken: cancellationToken); | |||
HandleResult(r); | |||
return r?.Data; | |||
} | |||
} | |||
} |
@@ -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板 | |||
} |
@@ -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: | |||
* <Author> <Time> <version> <desc> | |||
* YonnieLu 2019-10-31 10:20:01 1.0 Create | |||
* | |||
* compile methods: | |||
* 1. c++ | |||
* protoc --grpc_out=./ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` *.proto | |||
* protoc --cpp_out=. *.proto | |||
* | |||
* 2. golang | |||
* protoc *.proto --go_out=plugins=grpc:../ | |||
* | |||
* 3. python | |||
*/ | |||
syntax = "proto3"; | |||
import "google/protobuf/empty.proto"; | |||
import "messages.proto"; | |||
package robotc; | |||
service RobotPrivateController { | |||
// 初始化配置 | |||
rpc Init(Configuration) returns (Response); | |||
// 获取机器人基础信息 | |||
rpc GetRobotInfo(google.protobuf.Empty) returns (RobotInfo); | |||
// 设置机器人安装方向 | |||
rpc SetInstallDirection(InstallDirection) returns (Response); | |||
// 设置碰撞检测 | |||
rpc SetCollisionDetector(CollisionDetector) returns (Response); | |||
// 设置关节配置 | |||
rpc SetJointConfig(JointConfigs) returns (Response); | |||
// 设置笛卡尔空间的配置 | |||
rpc SetCartesianConfig(CartesianConfig) returns (Response); | |||
// 开启DDS | |||
rpc EnableDDS(TrueOrFalse) returns (Response); | |||
// 设置碰撞检测力矩差阈值 | |||
rpc SetCollisionTorqueDiff(CollisionTorqueDiff) returns(Response); | |||
// 注册通知事件 | |||
rpc RegisterNotification(google.protobuf.Empty) returns (stream Notification); | |||
rpc RobotDriverInfo(google.protobuf.Empty) returns (DriverInfo); | |||
// 机器人OTA单个设备更新接口 | |||
rpc RobotOTA(OTAData) returns (stream OTAResult); | |||
// 通知灯板、法兰、关节切换分区 | |||
rpc SwitchOtaPartition(OTACmd) returns (Response); | |||
// 机器人OTA批量更新接口 | |||
rpc RobotOTABatch(OTADatas) returns (stream OTAResults); | |||
// 重置 | |||
rpc Reset(google.protobuf.Empty) returns(Response); | |||
// 以给定角度置零 | |||
rpc InitZero(Zero) returns (Response); | |||
// 以零位置零 | |||
rpc SetZero(google.protobuf.Empty) returns (Response); | |||
// 获取机器人电压V | |||
rpc GetVoltage(google.protobuf.Empty) returns (CurrentVoltage); | |||
// 设置单关节伺服参数 | |||
rpc SetServoParam(JointServoParam) returns (JointServoParams); | |||
// 获取当前所有关节伺服参数 | |||
rpc GetServoParams(google.protobuf.Empty) returns (JointServoParams); | |||
// 调试设置 | |||
rpc SetDebugParams(DebugParams) returns (DebugParams); | |||
// 更改DH参数(三轴平行6参数) | |||
rpc FixDHParams(FixDHRequest) returns (FixDHResult); | |||
// 设置LED样式 | |||
rpc SetLEDStyle(LEDStyle) returns (LEDStyles); | |||
// 获取LED样式 | |||
rpc GetLEDStyles(google.protobuf.Empty) returns (LEDStyles); | |||
// 注册命令状态事件 | |||
rpc RegisterLuaEvent(google.protobuf.Empty) returns (stream LuaEvent); | |||
// 当推送 ALERT/CONFIRM/INPUT/SELECT,用户在前端确定后调用该接口 | |||
rpc ConfirmCallback(ConfirmInput) returns (Response); | |||
// 获取 Lua 上次执行到的机器人位置 | |||
rpc GetLastPose(google.protobuf.Empty) returns (PoseRes); | |||
//配置Modbus外部IO设备 | |||
rpc SetModbusExternalIO(ModbusExternalIOs) returns (Response); | |||
// 修改按钮配置 | |||
rpc SetButtonConfig(ButtonConfig) returns (Response); | |||
// 设置绑定设备开关, true: 不限制设备绑定; false:限制设备绑定逻辑 | |||
rpc SetBreakACup(TrueOrFalse) returns (Response); | |||
// PVAT数据记录接口,用户记录pvat数据 | |||
rpc RecordPVAT(RecordPVATRequest) returns (stream RecordPVATResponse); | |||
rpc StopRecordPVAT(google.protobuf.Empty) returns (Response); | |||
// 语音升级 | |||
rpc UpgradeVoiceFile(VoiceFile) returns (stream VoiceResult);//yvoice | |||
// 获取当前 DH 参数 | |||
rpc GetDHParams(DHRequest) returns (DHParams); | |||
// 设置 DH 参数并返回设置后的结果 | |||
rpc SetDHParams(DHParams) returns (DHParams); | |||
// 伺服控制参数 | |||
rpc WriteExtraServoParam(ExtraServoParam) returns (ExtraServoParam); | |||
rpc ReadExtraServoParam(ExtraServoParam) returns (ExtraServoParam); | |||
rpc WriteExtraServoParams(ExtraServoParam) returns (ExtraServoParams); | |||
rpc ReadExtraServoParams(google.protobuf.Empty) returns (ExtraServoParams); | |||
rpc ResetExtraServoParams(google.protobuf.Empty) returns (ExtraServoParams); | |||
// “主动消回差”参数 | |||
rpc WriteJointBacklash(JointBacklash) returns (JointBacklash); | |||
rpc ReadJointBacklash(JointBacklash) returns (JointBacklash); | |||
rpc WriteJointBacklashes(JointBacklash) returns (JointBacklashes); | |||
rpc ReadJointBacklashes(google.protobuf.Empty) returns (JointBacklashes); | |||
rpc ResetJointBacklashes(google.protobuf.Empty) returns (JointBacklashes); | |||
// 启用主动消回差 | |||
rpc WriteEnableJointBacklashes(EnableJointBacklash) returns (EnableJointBacklashes); | |||
rpc ReadEnableJointBacklashes(google.protobuf.Empty) returns (EnableJointBacklashes); | |||
rpc ResetEnableJointBacklashes(google.protobuf.Empty) returns (EnableJointBacklashes); | |||
// 关节回差参数 | |||
rpc WriteJointBacklashParam(JointBacklashParam) returns (JointBacklashParam); | |||
rpc ReadJointBacklashParam(JointBacklashParam) returns (JointBacklashParam); | |||
rpc WriteJointBacklashParams(JointBacklashParam) returns (JointBacklashParams); | |||
rpc ReadJointBacklashParams(google.protobuf.Empty) returns (JointBacklashParams); | |||
rpc ResetJointBacklashParams(google.protobuf.Empty) returns (JointBacklashParams); | |||
// 关节限位检测 | |||
rpc EnableJointLimit(TrueOrFalse) returns (Response); | |||
rpc SwitchSimulate(TrueOrFalse) returns (Response); | |||
// 连接/断开 MODBUS 设备 | |||
rpc ConnectExternalIO(ExternalIOState) returns (Response); | |||
} | |||
message EnableJointBacklash { | |||
int32 joint = 1; | |||
bool enable = 2; | |||
} | |||
message EnableJointBacklashes { | |||
repeated EnableJointBacklash joints = 1; | |||
} | |||
message ExtraServoParam { | |||
int32 joint = 1; // 当 Read、Enable/Disable 时仅该值生效, 0 代表关节 1 | |||
double acc_position_kp = 2; | |||
double acc_speed_kp = 3; | |||
double acc_speed_it = 4; | |||
double uni_position_kp = 5; | |||
double uni_speed_kp = 6; | |||
double uni_speed_it = 7; | |||
double dec_position_kp = 8; | |||
double dec_speed_kp = 9; | |||
double dec_speed_it = 10; | |||
} | |||
message ExtraServoParams { | |||
repeated ExtraServoParam joints = 1; | |||
} | |||
message JointBacklash { | |||
int32 joint = 1; | |||
uint32 k = 2; | |||
double iq = 3; | |||
double iq_final = 4; | |||
uint32 iq_count = 5; | |||
} | |||
message JointBacklashes { | |||
repeated JointBacklash joints = 1; | |||
} | |||
message JointBacklashParam { | |||
int32 joint = 1; | |||
int32 encoder_data_offset = 2; | |||
uint32 on = 3; | |||
uint32 over = 4; | |||
uint32 leave = 5; | |||
uint32 max = 6; | |||
} | |||
message JointBacklashParams { | |||
repeated JointBacklashParam joints = 1; | |||
} | |||
message VoiceFile {//yvoice | |||
int32 id = 1; | |||
string file = 2; | |||
string md5 = 3; | |||
} | |||
message VoiceResult {//yvoice | |||
int32 id = 1; | |||
int32 step = 2;// 0: not begin, 1: downloading, 2: flashing, 3: done, 4:fail | |||
int32 stepProgress = 3;// 0-100, currently only downloading step has progress, other steps need show pending progress | |||
} | |||
//0: all joints 1-7:joint1-7 8:flan 9:claw 10:lamp | |||
enum BootloaderId { | |||
ALL_JOINTS = 0; | |||
JOINT_1 = 1; | |||
JOINT_2 = 2; | |||
JOINT_3 = 3; | |||
JOINT_4 = 4; | |||
JOINT_5 = 5; | |||
JOINT_6 = 6; | |||
JOINT_7 = 7; | |||
FLANGE = 8; | |||
CLAW = 9; | |||
LAMP = 10; | |||
COMBOARD = 14; | |||
} | |||
enum BootPartition { | |||
A = 0; | |||
B = 1; | |||
C = 2; | |||
PART_UNKNOWN = 3; | |||
} | |||
// Message definition | |||
message TrueOrFalse { | |||
bool val = 1; | |||
} | |||
message InstallDirection { | |||
int32 direction = 1; // 安装方式: 0: up; 1: down; 2: side, default: UP | |||
} | |||
message JointConfig { | |||
double maxAngle = 1; | |||
double minAngle = 2; | |||
double maxV = 3; // 用户端设定的全局速度拆分到每个关节的maxV上 | |||
double maxAcc = 4; | |||
} | |||
message JointConfigs { | |||
repeated JointConfig configs = 1; | |||
} | |||
message CartesianConfig { | |||
double maxV = 1; | |||
double maxAcc = 2; | |||
} | |||
message SafetyPlat { // 安全平面,点为平面四个角的顶点,非示教的三个点 | |||
repeated Coordinate points = 1; | |||
} | |||
message SafetyPlats { | |||
repeated SafetyPlat plats = 1; // default: empty | |||
} | |||
message CollisionTorqueDiff { // 每个关节碰撞检测的扭矩差值 | |||
repeated double diffs = 1; | |||
} | |||
message CollisionDetector { | |||
bool enable = 1; // 是否启用碰撞检测, default: false | |||
int32 action = 2; // 碰撞检测后动作, 0: estop, 1: pause default: ESTOP | |||
int32 pauseTime = 3; // 碰撞检测暂停时间, default: 0 | |||
int32 sensitivity = 4; // 碰撞检测灵敏度, , default: 50 | |||
} | |||
message LEDStyle { | |||
int32 mode = 3; | |||
int32 speed = 4; | |||
repeated int32 color = 5; | |||
int32 voice = 1; | |||
int32 volume = 2; | |||
int32 robotMode = 6; // robot-mode | |||
} | |||
message LEDStyles { | |||
repeated LEDStyle styles = 16; // 机器人状态对应的LED样式,下标为robot-mode | |||
} | |||
message ButtonConfig { | |||
bool btn_flan_1 = 1; // | |||
bool btn_flan_2 = 2; | |||
bool btn_shoulder_0 = 3; | |||
} | |||
message Configuration { | |||
InstallDirection installDirection = 1; | |||
CollisionDetector collisionDetector = 2; | |||
JointConfigs jointConfigs = 3; // 0-6 关节配置 | |||
SafetyPlats safetyPlats = 4; // 安全平面列表 | |||
PR tcp = 5; // tcp配置 | |||
Payload payload = 6; // 负载 | |||
bool enableDDS = 7; // 是否开启内部数据调试服务(Data Debug Service),默认关闭 | |||
CollisionTorqueDiff collisionTorqueDiff = 8; | |||
int32 robotDIOInNum = 9; | |||
int32 robotDIOOutNum = 10; | |||
repeated AIO robotAIOInConfig = 11; | |||
repeated AIO robotAIOOutConfig = 12; | |||
int32 tcpDIOInNum = 13; | |||
int32 tcpDIOOutNum = 14; | |||
repeated double zeros = 15; // 关节归零角度 (弃用) | |||
repeated LEDStyle styles = 16; // 机器人状态对应的LED样式 | |||
bool break_a_cup = 17; // true: 不校验启动验证绑定设备hash逻辑; false: 默认值,校验 | |||
ButtonConfig button_config = 18; | |||
CartesianConfig cartesianConfig = 19; | |||
int32 extra_robotDIOInNum = 20; | |||
int32 extra_robotDIOOutNum = 21; | |||
repeated AIO extra_robotAIOInConfig = 22; | |||
repeated AIO extra_robotAIOOutConfig = 23; | |||
} | |||
message Zero { | |||
repeated double zeros = 1; | |||
} | |||
message Notice { | |||
// 通知类型 | |||
enum NoticeType { | |||
NOTICE_STATE = 0; // 机器人状态变更;机器人状态和急停状态位等 | |||
NOTICE_ERROR = 1; // 错误:错误类型 | |||
NOTICE_BUTTON = 2; // 按钮事件; | |||
} | |||
// 按钮类型的nId定义 | |||
enum NoticeId { | |||
NOTICE_ID_STATE_ROBOT_STATE = 0; // 机器人状态 | |||
NOTICE_ID_STATE_E_STOP = 1; // 机器人状态 | |||
NOTICE_ID_STATE_DATA_UPDATE = 2; // 机器人数据有更新 | |||
NOTICE_ID_ERROR = 3; // 机器人错误 | |||
NOTICE_ID_BUTTON_SHOULDER = 4; // 肩部按钮 | |||
NOTICE_ID_BUTTON_FLANGE_1 = 5; // 末端按钮1 | |||
NOTICE_ID_BUTTON_FLANGE_2 = 6; // 末端按钮1 | |||
} | |||
NoticeType type = 1; // 通知类型 | |||
/** | |||
* type = 1 按钮事件 | |||
* value: 按钮模式:1: 按钮空闲;2:长按;3:单击;4: 双击 | |||
*/ | |||
NoticeId id = 2; | |||
int32 value = 3; // when there ERROR, value represent the LEVEL | |||
int32 code = 4; | |||
// some fucking boring and important data need return back to front end | |||
repeated double lol = 5; | |||
int32 count = 6; // 肩部按钮按下时,按该按钮的次数 | |||
} | |||
message Notification { | |||
repeated Notice items = 1; | |||
} | |||
message Driver { | |||
// 驱动器基本信息 | |||
Hardware hardware = 1; | |||
// 当前运行分区情况 | |||
BootPartition curPartition = 2; | |||
} | |||
message DriverInfo { | |||
Driver flange = 1; | |||
Driver led = 2; | |||
repeated Driver joints = 3; | |||
Driver comboard = 4; | |||
} | |||
message OTAFile { | |||
string file = 1; // 文件完整路径 | |||
string md5 = 2; // 文件原始md5,前端计算 | |||
// version string: XX.YY.ZZ.20200608 | |||
string version = 3; | |||
} | |||
message OTACmd { | |||
BootloaderId bootloaderId = 1; | |||
// 0: B分区;1: C分区 | |||
BootPartition targetPartition = 2; | |||
} | |||
message OTAData { | |||
OTACmd cmd = 1; | |||
OTAFile file = 2; | |||
} | |||
message OTAJoints { | |||
repeated OTACmd cmds = 1; | |||
OTAFile file = 2; | |||
} | |||
message OTADatas { | |||
// 所有关节更新描述 | |||
OTAJoints joints = 1; | |||
// 非关节更新描述: 灯板,法兰 | |||
repeated OTAData notJoints = 2; | |||
} | |||
message OTAResult { | |||
BootloaderId bootloaderId = 1; | |||
int32 step = 2; // 0: not begin, 1: downloading, 2: flashing, 3: done, 4:fail | |||
int32 stepProgress = 3; // 0-100, currently only downloading step has progress, other steps need show pending progress | |||
string version = 4; | |||
BootPartition partition = 5; | |||
} | |||
message OTAResults { | |||
repeated OTAResult results = 1; | |||
} | |||
message CurrentVoltage { | |||
double power = 1; // 电源电压V/电流mA | |||
double flan = 2; // 法兰电压/电流 | |||
repeated double joint = 3; // 关节电压/电流 | |||
double io_power = 4; // IO板 | |||
} | |||
message JointServoParam { | |||
uint32 index = 1; // 0代表关节一 | |||
double position_kp = 2; | |||
double speed_kp = 3; | |||
double speed_it = 4; | |||
double torque_cmd_filter = 5; | |||
} | |||
message JointServoParams { | |||
repeated JointServoParam joints = 1; | |||
} | |||
message DebugParams { | |||
repeated double d = 1; | |||
} | |||
message FixDHRequest { | |||
repeated double delta_theta = 1; | |||
bool plus_theta = 2; // true则走到theta位再置零,false则走到-theta位再置零 | |||
repeated double delta_l = 3; | |||
bool plus_l = 4; // true则加,false则减 | |||
} | |||
message DHRequest { | |||
bool get_theoretical = 1; // 是否获取理论dh参数 | |||
} | |||
message DHt { | |||
double d = 1; | |||
double a = 2; | |||
double alpha = 3; | |||
double theta = 4; | |||
} | |||
message DHParams { | |||
repeated DHt params = 1; | |||
} | |||
message FixDHResult { | |||
repeated DHt origin = 1; | |||
repeated DHt before = 2; | |||
repeated DHt after = 3; | |||
} | |||
message Option { | |||
string value = 1; | |||
string label = 2; | |||
} | |||
message LuaEvent { | |||
enum Type { | |||
ECHO = 0; | |||
LUA = 1; | |||
SIGNAL = 2; | |||
LOOP = 3; | |||
ALERT = 4; | |||
CONFIRM = 5; | |||
INPUT = 6; | |||
SELECT = 7; | |||
} | |||
enum CmdState { | |||
INIT = 0; | |||
RUNNING = 1; | |||
SUCCESS = 2; | |||
FAILED = 3; | |||
} | |||
Type type = 1; | |||
// type: ECHO | |||
int32 cmd_id = 2; | |||
CmdState cmd_state = 3; | |||
// echo_key | |||
// 当type=Lua时,该字段表示错误消息; | |||
// 当type=LOOP 时表示loopid | |||
// 当type=ALERT/CONFIRM/INPUT/SELECT时,该字段表示提示语 | |||
string echo_key = 4; | |||
// index | |||
// 当type=LOOP时,表示进行到了第几个循环 | |||
// 当type=LUA时,表示对应的任务ID | |||
int32 index = 8; | |||
// type: LUA | |||
LuaState lua_state = 5; | |||
// type: SIGNAL | |||
int32 signal_id = 6; | |||
double signal_value = 7; | |||
// type: SELECT | |||
repeated Option options = 9; | |||
} | |||
message ConfirmInput { | |||
string input = 1; // CONFIRM时为"true"|"false", INPUT为用户输入字符串, SELECT为用户选择的value | |||
} | |||
message PoseRes { | |||
PR cart = 1; // 笛卡尔位置 | |||
JPose joint = 2; // 关节位置 | |||
} | |||
message ModbusDio { | |||
int32 pin = 1; | |||
//对应modbus内部地址 | |||
int32 addr = 2; | |||
} | |||
message ModbusDioGroup { | |||
repeated ModbusDio pins = 1; | |||
int32 addr = 2; | |||
} | |||
message ModbusAio { | |||
int32 pin = 1; | |||
// 0: 电压型 1: 电流型 | |||
int32 mode = 2; | |||
//对应Modbus内部地址 | |||
// 一个addr占用2bytes=16bits | |||
int32 addr = 3; | |||
} | |||
message AIORange { | |||
double min = 1; | |||
double max = 2; | |||
} | |||
message Range { | |||
AIORange V = 1; | |||
AIORange A = 2; | |||
} | |||
message ModbusAioGroup { | |||
repeated ModbusAio pins = 1; | |||
// modbus base address | |||
int32 addr = 2; | |||
//大小端 | |||
int32 isLsb = 3; | |||
Range range = 4; | |||
// number of 16 bit words for one pin | |||
int32 size = 5; | |||
} | |||
message ModbusExternalIOMapping { | |||
// 所有数字量的输入值 | |||
ModbusDioGroup di = 1; | |||
// 所有数字量的输出值 | |||
ModbusDioGroup do = 2; | |||
// 所有模拟量输入值 | |||
ModbusAioGroup ai = 3; | |||
// 所有模拟量输出值 | |||
ModbusAioGroup ao = 4; | |||
} | |||
message ExternalIOState { | |||
int32 id = 1; | |||
bool enable = 2; // true 连接 false 断开 | |||
} | |||
message ModbusExternalIO { | |||
int32 id = 1; | |||
string ip = 2; | |||
int32 port = 3; | |||
int32 timeout = 4; | |||
int32 slaveId = 5; | |||
int32 cmdHoldTime = 6; | |||
int32 version = 7; | |||
ModbusExternalIOMapping ioMap = 8; | |||
} | |||
message ModbusExternalIOs { | |||
repeated ModbusExternalIO ios= 1; | |||
} | |||
message RecordPVATRequest { | |||
enum PVATType { | |||
PT = 0; | |||
PVT = 1; | |||
PVAT = 2; | |||
} | |||
message VZeroGap { | |||
double threshold = 1; // v zero gap threshold should be > 0 and < 0.01 | |||
bool remove_gap = 2; // whether to remove zero gap during teaching | |||
} | |||
PVATType type = 1; | |||
double duration = 2; // duration in microseconds | |||
VZeroGap vZeroGap = 3; | |||
bool use_duration_ts = 4; | |||
bool save_file = 5; | |||
} | |||
message RecordPVATResponse { | |||
repeated double p = 1; | |||
repeated double v = 2; | |||
repeated double acc = 3; | |||
double t = 4; | |||
bool end = 5; // is pvat end | |||
string f = 6; // data save file path, local | |||
} |
@@ -0,0 +1,735 @@ | |||
/** | |||
* Copyright © 2017-2018 Shanghai Lebai Robotic Co., Ltd. All rights reserved. | |||
* | |||
* FileName: robot_controller.proto | |||
* | |||
* Author: Yonnie Lu | |||
* Email: zhangyong.lu@lebai.ltd | |||
* Date: 2018-12-28 17:26 | |||
* Description: | |||
* History: | |||
* <Author> <Time> <version> <desc> | |||
* YonnieLu 2018-12-28 17:26 1.0 Create | |||
* | |||
* compile methods: | |||
* 1. c++ | |||
* protoc --grpc_out=./ --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` *.proto | |||
* protoc --cpp_out=. *.proto | |||
* | |||
* 2. golang | |||
* protoc *.proto --go_out=plugins=grpc:../ | |||
* | |||
* 3. python | |||
*/ | |||
syntax = "proto3"; | |||
import "google/protobuf/empty.proto"; | |||
import "messages.proto"; | |||
package robotc; | |||
// Robot controller gRPC & protobuf idl language definition | |||
service RobotController { | |||
// 1. Basic control commands | |||
// 关闭电源 | |||
rpc PowerDown(google.protobuf.Empty) returns (CmdId); | |||
// 等待,单位毫秒 | |||
rpc Sleep(SleepRequest) returns (CmdId); | |||
// 同步,等待指定命令执行完成,type为0时表示所有(默认) | |||
rpc Sync(google.protobuf.Empty) returns (CmdId); | |||
rpc SyncFor(SyncRequest) returns (CmdId); | |||
// 2. Config commands | |||
// 开启示教模式 | |||
rpc TeachMode(google.protobuf.Empty) returns (CmdId); | |||
// 关闭示教模式 | |||
rpc EndTeachMode(google.protobuf.Empty) returns (CmdId); | |||
// 设置速度因子(0-100) | |||
rpc SetVelocityFactor(Factor) returns (CmdId); | |||
// 获取速度因子(0-100) | |||
rpc GetVelocityFactor(google.protobuf.Empty) returns (Factor); | |||
rpc SetGravity(Coordinate) returns (CmdId); | |||
rpc GetGravity(google.protobuf.Empty) returns (Coordinate); | |||
rpc SetPayload(Payload) returns (CmdId); | |||
rpc GetPayload(google.protobuf.Empty) returns (Payload); | |||
rpc SetPayloadMass(PayloadMass) returns (CmdId); | |||
rpc GetPayloadMass(google.protobuf.Empty) returns (PayloadMass); | |||
rpc SetPayloadCog(PayloadCog) returns (CmdId); | |||
rpc GetPayloadCog(google.protobuf.Empty) returns (PayloadCog); | |||
rpc SetTcp(PR) returns (CmdId); | |||
rpc GetTcp(google.protobuf.Empty) returns (PR); | |||
// 设置手爪幅度:0-100 double | |||
rpc SetClawAmplitude(Amplitude) returns (CmdId); | |||
// 获得手爪幅度:0-100 double | |||
rpc GetClawAmplitude(google.protobuf.Empty) returns (Amplitude); | |||
// 获得手爪目前是否夹紧物体状态1表示夹紧,0为松开 | |||
rpc GetClawHoldOn(google.protobuf.Empty) returns (HoldOn); | |||
// 设置手爪力度:0-100 double | |||
rpc SetClawForce(Force) returns (CmdId); | |||
// 获得手爪称重结果 | |||
rpc GetClawWeight(google.protobuf.Empty) returns (Weight); | |||
// implement later | |||
// rpc Force(google.protobuf.Empty) returns (Force); | |||
// implement later | |||
rpc GetTcpForce(google.protobuf.Empty) returns (ForceTorque); | |||
rpc SetClaw(ClawInfo) returns (ClawInfo); | |||
rpc GetClaw(google.protobuf.Empty) returns (ClawInfo); | |||
// 3. Motion control commands | |||
rpc SetPos(JPose) returns (CmdId); | |||
// implement later | |||
rpc SpeedJ(SpeedJRequest) returns (CmdId); | |||
// implement later | |||
rpc SpeedL(SpeedLRequest) returns (CmdId); | |||
// implement later | |||
rpc StopJ(StopJRequest) returns (CmdId); | |||
// implement later | |||
rpc StopL(StopLRequest) returns (CmdId); | |||
// 停止当前移动 | |||
rpc StopMove(google.protobuf.Empty) returns (CmdId); | |||
// 圆弧移动 | |||
rpc MoveC(MoveCRequest) returns (CmdId); | |||
// 关节空间线性移动 | |||
rpc MoveJ(MoveJRequest) returns (CmdId); | |||
// 笛卡尔空间线性移动 | |||
rpc MoveL(MoveLRequest) returns (CmdId); | |||
// DEPRECIATED | |||
rpc MoveLJ(MoveLRequest) returns (CmdId); | |||
// implement later | |||
rpc MoveP(MovePRequest) returns (CmdId); | |||
// pt move | |||
rpc MovePT(PVATRequest) returns (CmdId); | |||
rpc MovePTStream(stream PVATRequest) returns (CmdId); | |||
// pvt move | |||
rpc MovePVT(PVATRequest) returns (CmdId); | |||
rpc MovePVTStream(stream PVATRequest) returns (CmdId); | |||
// pvat move | |||
rpc MovePVAT(PVATRequest) returns (CmdId); | |||
rpc MovePVATStream(stream PVATRequest) returns (CmdId); | |||
// implement later | |||
rpc ServoC(ServoCRequest) returns (CmdId); | |||
// implement later | |||
rpc ServoJ(ServoJRequest) returns (CmdId); | |||
// 4. Status and data query commands | |||
// 获取机器人所有状态数据 | |||
rpc GetRobotData(google.protobuf.Empty) returns (RobotData); | |||
// 获取机器人概要数据 | |||
rpc GetRobotBriefData(stream RobotDataCmd) returns (stream RobotBriefData); | |||
// 获取机器人的IO数据 | |||
rpc GetRobotIOData(stream RobotDataCmd) returns (stream IO); | |||
// 获取机器人状态 | |||
rpc GetRobotMode(google.protobuf.Empty) returns (RobotMode); | |||
// 获得实际关节位置 | |||
rpc GetActualJointPositions(google.protobuf.Empty) returns (Joint); | |||
// 获得目标关节位置 | |||
rpc GetTargetJointPositions(google.protobuf.Empty) returns (Joint); | |||
// 获得实际关节速度 | |||
rpc GetActualJointSpeeds(google.protobuf.Empty) returns (Joint); | |||
// 获得目标关节速度 | |||
rpc GetTargetJointSpeeds(google.protobuf.Empty) returns (Joint); | |||
// 获得末端在笛卡尔坐标系下的位姿 | |||
rpc GetActualTcpPose(google.protobuf.Empty) returns (Vector); | |||
// 获得末端在笛卡尔坐标系下的目标位姿 | |||
rpc GetTargetTcpPose(google.protobuf.Empty) returns (Vector); | |||
// implement later | |||
rpc GetActualTcpSpeed(google.protobuf.Empty) returns (Vector); | |||
// implement later | |||
rpc GetTargetTcpSpeed(google.protobuf.Empty) returns (Vector); | |||
// implement later | |||
rpc GetActualFlangePose(google.protobuf.Empty) returns (Vector); | |||
// 获取关节扭矩 | |||
rpc GetJointTorques(google.protobuf.Empty) returns (Joint); | |||
// 获取控制器温度 | |||
rpc GetControllerTemp(google.protobuf.Empty) returns (Temperature); | |||
// 获取关节内部温度 | |||
rpc GetJointTemp(IntRequest) returns (Temperature); | |||
// implement later | |||
rpc GetToolCurrent(google.protobuf.Empty) returns (Current); | |||
//xxx | |||
// 5. IO-related cmds | |||
// 设置数字输出端口的值 | |||
rpc SetDIO(DIO) returns (CmdId); | |||
// 设置扩展数字输出端口的值 | |||
rpc SetExtraDIO(DIO) returns (CmdId); | |||
// 获得数字输入端口的值 | |||
rpc GetDIO(IOPin) returns (DIO); | |||
// 获得扩展数字数如端口的值 | |||
rpc GetExtraDIO(IOPin) returns (DIO); | |||
// 设置TCP数字输出端口的值 | |||
rpc SetTcpDIO(DIO) returns (CmdId); | |||
// 获得TCP数字输入端口的值 | |||
rpc GetTcpDIO(IOPin) returns (DIO); | |||
// 设置模拟输出端口的值 | |||
rpc SetAIO(AIO) returns (CmdId); | |||
// 获得模拟输入端口的值 | |||
rpc SetExtraAIO(AIO) returns (CmdId); | |||
// 获得模拟输入端口的值 | |||
rpc GetAIO(IOPin) returns (AIO); | |||
// 获得扩展模拟输入端口的值 | |||
rpc GetExtraAIO(IOPin) returns (AIO); | |||
// 设置模拟输入端口工作模式:0:电压,1:电流 | |||
rpc SetAInMode(AIO) returns (CmdId); | |||
// 设置扩展模拟输入端口工作模式:0:电压,1:电流 | |||
rpc SetExtraAInMode(AIO) returns (CmdId); | |||
// 获得模拟输入端口工作模式:0:电压,1:电流 | |||
rpc GetAInMode(IOPin) returns (AIO); | |||
// 获得扩展模拟输入端口工作模式:0:电压,1:电流 | |||
rpc GetExtraAInMode(IOPin) returns (AIO); | |||
// 设置模拟输出端口工作模式:0:电压,1:电流 | |||
rpc SetAOutMode(AIO) returns (CmdId); | |||
// 设置扩展模拟输出端口工作模式:0:电压,1:电流 | |||
rpc SetExtraAOutMode(AIO) returns (CmdId); | |||
// 获得模拟输出端口工作模式:0:电压,1:电流 | |||
rpc GetAOutMode(IOPin) returns (AIO); | |||
// 获得扩展模拟输出端口工作模式:0:电压,1:电流 | |||
rpc GetExtraAOutMode(IOPin) returns (AIO); | |||
// 6. Control commands | |||
// 开启/启动系统 | |||
rpc StartSys(google.protobuf.Empty) returns (CmdId); | |||
// 关闭/停止系统 | |||
rpc StopSys(google.protobuf.Empty) returns (CmdId); | |||
// 程序停止 | |||
rpc Stop(google.protobuf.Empty) returns (CmdId); | |||
// 急停 | |||
rpc EStop(google.protobuf.Empty) returns (CmdId); | |||
// 7. Internal commands | |||
// 获取kdl参数 | |||
rpc GetKDL(google.protobuf.Empty) returns (KDParam); | |||
// 查询系统里面的日志信息 | |||
rpc GetLogs(google.protobuf.Empty) returns (Logs); | |||
// 获得当前正在执行的命令id,如果没有在执行的命令,则返回-1 | |||
rpc GetCurrentCmd(google.protobuf.Empty) returns (CmdId); // 命令id | |||
// 获得指定命令id的执行结果:-1: 未执行;0: 已执行 | |||
rpc GetCmdExecStatus(CmdId) returns (CmdStatus); | |||
// 开始微调: 如果当前有其他微调再传入新的微调命令会终止当前的微调进行新的微调 | |||
rpc StartFineTuning(FineTuning) returns (CmdId); | |||
// 停止微调 | |||
rpc StopFineTuning(google.protobuf.Empty) returns (CmdId); | |||
// 暂停机器人 | |||
rpc Pause(google.protobuf.Empty) returns (CmdId); | |||
// 恢复机器人 | |||
rpc Resume(google.protobuf.Empty) returns (CmdId); | |||
// 机器人正解 | |||
rpc KinematicsForward(Joint) returns (Vector); | |||
// 机器人反解 | |||
rpc KinematicsInverse(Vector) returns (Joint); | |||
// TCP示教添加 | |||
rpc CalcTcpTranslation(CalcTcpParam) returns (Vector); | |||
// 8. Test command | |||
// 测试命令,以给定的RPY数据执行线性移动 | |||
rpc MoveLRPY(MoveLRPYRequest) returns (CmdId); | |||
// 9. 扬声器和LED灯 | |||
// 设置LED灯状态 | |||
rpc SetLED(LEDStatus) returns (CmdId); | |||
// 设置声音 | |||
rpc SetVoice(VoiceStatus) returns (CmdId); | |||
// 设置风扇 | |||
rpc SetFan(FanStatus) returns (CmdId); | |||
// 获取灯板状态 | |||
rpc GetLampStatus(google.protobuf.Empty) returns (LampStatus); | |||
// Lua 状态查询 | |||
rpc GetLuaState(google.protobuf.Empty) returns (LuaStatus); | |||
// 外置数字输出 | |||
rpc SetExternalDO(ExternalDigital) returns (Response); | |||
rpc GetExternalDO(ExternalPin) returns (ExternalDigital); | |||
// 外置数字输入 | |||
rpc GetExternalDI(ExternalPin) returns (ExternalDigital); | |||
// 外置模拟输出 | |||
rpc SetExternalAO(ExternalAnalog) returns (Response); | |||
rpc GetExternalAO(ExternalPin) returns (ExternalAnalog); | |||
// 外置模拟输入 | |||
rpc GetExternalAI(ExternalPin) returns (ExternalAnalog); | |||
// 获取某个外置io的全部io信息 | |||
rpc GetExternalIOs(ExternalDevice) returns (ExternalIOs); | |||
// 外置IO的复数版本 | |||
// 外置数字输出 | |||
rpc SetExternalDOs(ExternalDigitals) returns (Response); | |||
rpc GetExternalDOs(ExternalPins) returns (ExternalDigitals); | |||
// 外置数字输入 | |||
rpc GetExternalDIs(ExternalPins) returns (ExternalDigitals); | |||
// 外置模拟输出 | |||
rpc SetExternalAOs(ExternalAnalogs) returns (Response); | |||
rpc GetExternalAOs(ExternalPins) returns (ExternalAnalogs); | |||
// 外置模拟输入 | |||
rpc GetExternalAIs(ExternalPins) returns (ExternalAnalogs); | |||
// 信号量 | |||
rpc SetSignal(SignalValue) returns (SignalResult); | |||
rpc GetSignal(SignalValue) returns (SignalResult); | |||
rpc AddSignal(SignalValue) returns (SignalResult); | |||
rpc RegisterSignals(stream SignalList) returns (stream SignalValue); | |||
} | |||
message SignalValue { | |||
int32 index = 1; | |||
int32 value = 2; | |||
} | |||
message SignalResult { | |||
int32 index = 1; | |||
int32 value = 2; | |||
bool ok = 3; | |||
} | |||
message SignalList { | |||
repeated int32 indexes = 1; | |||
} | |||
// 机器人所有状态数据 | |||
message RobotData { | |||
// 机器人模式 | |||
RobotMode robotMode = 1; | |||
// 机器人各个关节模式 | |||
repeated JointMode jointModes = 2; | |||
// 实际关节位置 | |||
Joint actualJoint = 3; | |||
// 实际关节速度 | |||
Joint actualJointSpeed = 4; | |||
// 目标关节位置 | |||
Joint targetJoint = 5; | |||
// 目标关节速度 | |||
Joint targetJointSpeed = 6; | |||
// 实际tcp位置 | |||
Vector actualTcpPose = 7; | |||
// 实际tcp速度 | |||
Vector actualTcpSpeed = 8; | |||
// 目标tcp位置 | |||
Vector targetTcpPose = 9; | |||
// 目标tcp速度 | |||
Vector targetTcpSpeed = 10; | |||
// 当前系统正在执行的命令状态:id + value | |||
CmdStatus currentCmd = 11; | |||
// 所有的io数据 | |||
IO io = 12; | |||
// 速度因子 | |||
double velocityFactor = 13; | |||
// 爪子信息 | |||
ClawInfo clawInfo = 14; | |||
// 关节温度 | |||
Joint jointTemps = 15; | |||
// 理论力矩 | |||
Joint targetTorque = 16; | |||
// 实际力矩 | |||
Joint actualTorque = 17; | |||
// 加速度 | |||
Joint actualJointAcc = 18; | |||
Joint targetJointAcc = 19; | |||
} | |||
// 机器人需要获取数据的请求cmd | |||
message RobotDataCmd { | |||
// empty | |||
} | |||
// 机器人概要状态数据 | |||
message RobotBriefData { | |||
// 机器人模式 | |||
RobotMode robotMode = 1; | |||
// 实际关节位置 | |||
Joint actualJoint = 2; | |||
// 目标关节位置 | |||
Joint targetJoint = 3; | |||
// 实际tcp位置 | |||
Vector actualTcpPose = 4; | |||
// 目标tcp位置 | |||
Vector targetTcpPose = 5; | |||
// 速度因子 | |||
double velocityFactor = 6; | |||
// 关节温度 | |||
Joint jointTemps = 7; | |||
} | |||
// 机器人状态枚举值 | |||
message RobotMode { int32 mode = 1; } | |||
// dh参数 | |||
message DH { | |||
double d = 1; | |||
double a = 2; | |||
double alpha = 3; | |||
double theta = 4; | |||
} | |||
// 运动学动力学参数 | |||
message KDParam { | |||
repeated DH dhParams = 1; | |||
} | |||
// 关节状态枚举值 | |||
message JointMode { int32 mode = 1; } | |||
message Amplitude { double amplitude = 1; } | |||
message HoldOn { int32 hold_on = 1; } | |||
message Force { double force = 1; } | |||
message Weight { double weight = 1; } | |||
// 爪子信息 | |||
message ClawInfo { | |||
double amplitude = 1; | |||
double force = 2; | |||
double weight = 3; | |||
int32 hold_on = 4; | |||
} | |||
message ForceTorque { repeated double forceTorque = 1; } | |||
message Joint { // it can represent joint angles(rad) or joint speed (rad/s) or | |||
// torques (Nm) | |||
repeated double joints = 1; | |||
} | |||
message Vector { // x, y, z, rx, ry, rz | |||
repeated double vector = 1; | |||
} | |||
message Temperature { double degree = 1; } | |||
message Current { double current = 1; } | |||
message Factor { double value = 1; } | |||
message Ret { bool ret = 1; } | |||
message CmdId { int32 id = 1; } | |||
message CmdStatus { | |||
// 命令id | |||
int32 id = 1; | |||
// -1: 未执行;0: 已执行 | |||
int32 value = 2; | |||
} | |||
message IntRequest { int32 index = 1; } | |||
message Logs { | |||
// 如果没有错误,则返回空 | |||
repeated Log log = 1; | |||
} | |||
message Log { | |||
// 1 - Fatal: 严重错误,无法正常运行, 2 - Error:错误,系统可能还能继续运行, 3 | |||
// - Warning: 潜在的警告类错误, 4 - Info, 信息类,5 - Debug:调试类 | |||
int32 level = 1; | |||
int32 code = 2; | |||
string msg = 3; | |||
} | |||
message SleepRequest { int32 time = 1; } | |||
message SyncRequest { int32 type = 1; } | |||
message SpeedJRequest { | |||
// 单位:rad/s{base, shoulder, elbow, wrist1, wrist2, wrist3} | |||
repeated double joint_speed = 1; | |||
// 单位:rad/s^2 | |||
double acceleration = 2; | |||
// 可选参数,单位:秒,设定方法多少秒后返回 | |||
double time = 3; | |||
} | |||
message SpeedLRequest { | |||
// 单位:m/s {base, shoulder, elbow, wrist1, wrist2, wrist3} | |||
repeated double velocity = 1; | |||
// 单位:m/s^2,以移动位置长度为衡量标准的加速度 | |||
double position_acceleration = 2; | |||
// 可选参数,单位:秒,设定方法多少秒后返回 | |||
double time = 3; | |||
// 可选参数,单位:rad/s^2,以转动角度为衡量标准的加速度,如果没给到,则使用第二个参数;如果给到,则使用这个参数 | |||
double acceleration = 4; | |||
} | |||
message StopJRequest { | |||
// deceleration 单位:rad/s^2,减速度 | |||
double deceleration = 1; | |||
} | |||
message StopLRequest { | |||
// 单位:m/s^2,以移动位置长度为衡量标准的减速度 | |||
double position_deceleration = 1; | |||
// 单位:rad/s^2,可选,以转动角度为衡量标准的减速度,如果设定了该值,则使用该值不使用第一个参数?? | |||
double deceleration = 2; | |||
} | |||
message MoveCRequest { | |||
// 若 pose_is_joint_angle 为false,则是{x, y, z, rx, ry, rz};否则为{j0, j1, | |||
// j2, j3, j4, j5}每个关节的关节角度,正向运动学会换算成对应的pose | |||
repeated double pose_via = 1; | |||
// 同上 | |||
repeated double pose_to = 2; | |||
// 设定pose_via和pose_to是用{x, y, z, rx, ry, | |||
// rz}描述末端位置和姿态还是用关节角度 | |||
bool pose_via_is_joint = 3; | |||
bool pose_to_is_joint = 4; | |||
// 单位:m/s^2,工具加速度 | |||
double acceleration = 5; | |||
// 单位:m/s,工具速度 | |||
double velocity = 6; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 7; | |||
// 工作模式:0:无约束模式,Interpolate orientation from current pose to | |||
// target pose (pose_to);1:固定方向模式,使用相对于圆弧切换固定方向的圆弧 | |||
int32 mode = 8; | |||
// 单位:s,运动时间 | |||
double time = 9; | |||
// 相对坐标系,仅pose_is_joint_angle=false时有效。世界坐标系为{0,0,0,0,0,0} | |||
PR pose_base = 10; | |||
// 弧度 (rad) | |||
double rad = 11; | |||
} | |||
message MoveJRequest { | |||
// 如果pose_is_joint_angle 为 false,反向运动学会计算成对应的关节角度; | |||
repeated double joint_pose_to = 1; | |||
// 设定joint_pose_to是用{x, y, z, rx, ry, rz}描述末端位置和姿态还是用关节角度 | |||
bool pose_is_joint_angle = 2; | |||
// 单位:rad/s^2,主轴的关节加速度 | |||
double acceleration = 3; | |||
// 单位:rad/s,主轴的关节速度 | |||
double velocity = 4; | |||
// 单位:s,运动时间 | |||
double time = 5; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 6; | |||
// 相对坐标系,仅pose_is_joint_angle=false时有效。世界坐标系为{0,0,0,0,0,0} | |||
PR pose_base = 7; | |||
} | |||
message MoveLRequest { | |||
// 如果pose_is_joint_angle 为 false,反向运动学会计算成对应的关节角度; | |||
repeated double pose_to = 1; | |||
// 设定joint_pose_to是用{x, y, z, rx, ry, rz}描述末端位置和姿态还是用关节角度 | |||
bool pose_is_joint_angle = 2; | |||
// 单位:rad/s^2,主轴的关节加速度 | |||
double acceleration = 3; | |||
// 单位:rad/s,主轴的关节速度 | |||
double velocity = 4; | |||
// 单位:s,运动时间 | |||
double time = 5; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 6; | |||
// 相对坐标系,仅pose_is_joint_angle=false时有效。世界坐标系为{0,0,0,0,0,0} | |||
PR pose_base = 7; | |||
} | |||
message MoveLRPYRequest { | |||
// 如果pose_is_joint_angle 为 false,反向运动学会计算成对应的关节角度; | |||
repeated double pose_to = 1; | |||
// 单位:rad/s^2,主轴的关节加速度,如果为-1,则表示未设置值 | |||
double acceleration = 2; | |||
// 单位:rad/s,主轴的关节速度,如果为-1,则表示未设置值 | |||
double velocity = 3; | |||
// 单位:s,运动时间,如果为-1,则表示未设置值 | |||
double time = 4; | |||
// 单位:m,下一段的交融半径,如果为-1,则表示未设置值 | |||
double blend_radius = 5; | |||
} | |||
message MovePRequest { | |||
repeated double pose_to = 1; | |||
// 设定pose_to是用{x, y, z, rx, ry, | |||
// rz}描述末端位置和姿态还是用关节角度,如果pose_is_joint_angle是true,正向运动学会计算出对应的{x, | |||
// y, z, rx, ry, rz} | |||
bool pose_is_joint_angle = 2; | |||
// 单位:m/s^2,工具加速度 | |||
double acceleration = 3; | |||
// 单位:m/s,工具速度 | |||
double velocity = 4; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 5; | |||
} | |||
message ServoCRequest { | |||
repeated double pose_to = 1; | |||
// 设定pose_to是用{x, y, z, rx, ry, | |||
// rz}描述末端位置和姿态还是用关节角度,如果pose_is_joint_angle是true,正向运动学会计算出对应的{x, | |||
// y, z, rx, ry, rz} | |||
bool pose_is_joint_angle = 2; | |||
// 单位:m/s^2,工具加速度 | |||
double acceleration = 3; | |||
// 单位:m/s,工具速度 | |||
double velocity = 4; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 5; | |||
} | |||
message ServoJRequest { | |||
// 如果pose_is_joint_angle 为 false,反向运动学会计算成对应的关节角度; | |||
repeated double joint_pose_to = 1; | |||
// 设定joint_pose_to是用{x, y, z, rx, ry, rz}描述末端位置和姿态还是用关节角度 | |||
bool pose_is_joint_angle = 2; | |||
// 单位:rad/s^2,主轴的关节加速度 | |||
double acceleration = 3; | |||
// 单位:rad/s,主轴的关节速度 | |||
double velocity = 4; | |||
// 单位:s,运动时间 | |||
double time = 5; | |||
// 单位:s,取值范围:0.03 ~ 0.2,使用预向前看的时间来让轨迹平滑 | |||
double look_ahead_time = 6; | |||
// 取值范围:100 ~ 2000,proportinal gain for following target position, | |||
int32 gain = 7; | |||
} | |||
// 微调参数 | |||
message FineTuning { | |||
int32 mode = 1; // 1: 坐标系模式;2:关节模式 | |||
int32 base = 2; // 1: world;2: tcp | |||
int32 coordinate = 3; // 1: 直角坐标系;2:圆柱坐标系 | |||
/* | |||
* 需要微调的目标: 轴/关节: | |||
* 1)关节模式下表示关节编号:0-6; | |||
* 2)坐标系模式下 | |||
* a) 直角坐标系:0: x, 1: y, 2: z, 3: r, 4: p, 5: y | |||
* b) 圆柱坐标系:0: ρ,1: φ,2: z, 3: r, 4: p, 5: y | |||
*/ | |||
int32 target = 4; | |||
int32 direction = 5; // 1: +向;-1:负向 | |||
} | |||
message LEDStatus { | |||
int32 mode = 1; | |||
// LED_MODE_OFF 1 // 关闭 | |||
// LED_MODE_CONST 2 // 常亮 | |||
// LED_MODE_BREATHING 3 // 呼吸 | |||
// LED_MODE_4_PIES_ROTATE 4 // 四块旋转 | |||
// LED_MODE_SINGLE_ROTATE 5 // 同色旋转 | |||
// LED_MODE_FLASHING 6 // 闪烁 | |||
int32 speed = 2; | |||
// LED_SPEED_HIGH 1 | |||
// LED_SPEED_NORMAL 2 | |||
// LED_SPEED_SLOW 3 | |||
repeated int32 color = 3; // 最多包含4个 0 ~ 15 之间的整数 | |||
} | |||
message VoiceStatus { | |||
int32 voice = 1; // 声音列表 0~10 | |||
int32 volume = 2; | |||
// VOLUME_MUTE 0 | |||
// VOLUME_LOW 1 | |||
// VOLUME_DEFAULT 2 | |||
// VOLUME_HIGH 3 | |||
} | |||
message FanStatus { | |||
int32 fan = 1; // 1 关闭 2 开启 | |||
} | |||
message CalcTcpParam { | |||
repeated Vector poses = 1; // all the sampled frame, usually use flange frame. | |||
double tol = 2; // tolerance for standard deviation computing, | |||
// * if any deviation exceed tolerance, the function returns error. | |||
} | |||
message LuaStatus { | |||
LuaState state = 1; | |||
PR last_pose = 2; | |||
JPose last_joints = 3; | |||
} | |||
message LampStatus { | |||
LEDStatus led = 1; | |||
VoiceStatus voice = 2; | |||
FanStatus fan = 3; | |||
} | |||
message PVATRequest { | |||
double duration = 1; | |||
repeated double q = 2; | |||
repeated double v = 3; | |||
repeated double acc = 4; | |||
} | |||
message ExternalPin { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// pin索引 | |||
int32 pin = 2; | |||
} | |||
message ExternalPins { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// 起始地址 | |||
int32 pin = 2; | |||
// 长度 | |||
int32 length = 3; | |||
} | |||
message ExternalDigital { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// pin索引 | |||
int32 pin = 2; | |||
// pin索引对应的值 | |||
int32 value = 3; | |||
} | |||
message ExternalDigitals { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// 起始地址 | |||
int32 pin = 2; | |||
// 长度 | |||
int32 length = 3; | |||
// 值数组 | |||
repeated int32 values = 4; | |||
} | |||
message ExternalAnalog { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// pin索引 | |||
int32 pin = 2; | |||
// pin索引对应的值 | |||
double value = 3; | |||
} | |||
message ExternalAnalogs { | |||
// 外置设备的id | |||
int32 id = 1; | |||
// 起始地址 | |||
int32 pin = 2; | |||
// 长度 | |||
int32 length = 3; | |||
// 值数组 | |||
repeated double values = 4; | |||
} | |||
message ExternalDevice { | |||
int32 id = 1; | |||
} | |||
message ExternalIOs { | |||
repeated ExternalDigital dis = 1; | |||
repeated ExternalDigital dos = 2; | |||
repeated ExternalAnalog ais = 3; | |||
repeated ExternalAnalog aos = 4; | |||
} |
@@ -0,0 +1,193 @@ | |||
syntax = "proto3"; | |||
import "messages.proto"; | |||
package robotc; | |||
service RobotTest { | |||
rpc InitReducerTest(Empty) returns (Result); | |||
rpc ReducerTest(ReducerRequest) returns (ReducerResult); | |||
rpc InitJointTest(Empty) returns (Result); | |||
rpc JointStudy(Empty) returns (JointStudyResult); | |||
rpc JointTest(JointRequest) returns (JointResult); | |||
rpc TestCommand(CommandRequest) returns (CommandResult); | |||
/// 磨合测试,返回每个周期的结果,主动断开即停止 | |||
rpc RunInTest(RunInRequest) returns(RunInResult); | |||
/// 绝对精度测试 | |||
rpc MoveDetectTest(MoveDetectRequest) returns(MoveDetectResult); | |||
/// 百分表读取 | |||
rpc GetDialIndicator(DeviceIds) returns(DeviceValues); | |||
/// 量产测试 | |||
rpc StartProductTest(ProductTestRequest) returns(ProductTestResult); | |||
/// 主机箱测试: 1, 正常;其他异常 | |||
rpc BoxTest(Empty) returns(Result); | |||
// 初始化机器人设备信息 | |||
/** | |||
{ | |||
"robot": { | |||
"model": "LM6J", | |||
"sn": "C01905010001XX" | |||
}, | |||
"name": "lebai-Yonnie", | |||
"mac": "B6LLYLUAQG19", | |||
"arm": { | |||
"sn": "R01905010001XX" | |||
} | |||
} | |||
*/ | |||
rpc InitRobot(RobotInfo) returns (InitRobotResult); | |||
rpc WriteSn(DeviceInfo) returns (WriteSnResult); | |||
rpc ReadSn(DeviceTypeRequest) returns (DeviceInfo); | |||
} | |||
message Empty {} | |||
message Result { | |||
int32 ok = 1; // 0 正常 其他异常 | |||
int32 testError = 2; | |||
} | |||
message Joints { | |||
repeated double pose = 1; | |||
} | |||
message ReducerRequest { | |||
double v = 1; // 转速 | |||
} | |||
message ReducerResult { | |||
double voltage = 1; // 电压 V | |||
double v = 2; // 转速 rpm | |||
double torque = 3; // 扭矩 Nm | |||
} | |||
message JointStudyResult { | |||
uint32 motor_encoder = 1; // 电机编码(磁编位置) | |||
} | |||
message JointRequest { | |||
uint32 joint_type = 1; // 0 大关节 1 小关节 | |||
} | |||
message JointResult { | |||
double backlash = 1; // 空程 ° | |||
double pos_stable_time = 2; // 位置稳定时间 s | |||
double pos_overshot = 3; // 位置超调量 rad | |||
double temperature = 4; // 关节内部温度 ℃ | |||
double current = 5; // 电流 A | |||
double voltage = 6; // 电压 V | |||
double v = 7; // 转速 rpm | |||
double torque = 8; // 电机扭矩 Nm | |||
uint32 motor_encoder = 9; // 电机编码(磁编位置) | |||
double joint_torque = 10; // 关节扭矩 | |||
double reducer_eff = 11; // 减速器效率 | |||
double motor_eff = 12; // 电机效率 | |||
} | |||
message CommandRequest { | |||
int32 type = 1; // 类型 | |||
int32 value_i = 2; | |||
double value_f = 3; | |||
} | |||
message CommandResult { | |||
int32 code = 1; // 返回码,默认0即可 | |||
} | |||
message MovePoint { | |||
// 如果pose_is_joint_angle 为 false,反向运动学会计算成对应的关节角度; | |||
repeated double joint_pose_to = 1; | |||
// 设定joint_pose_to是用{x, y, z, rx, ry, rz}描述末端位置和姿态还是用关节角度 | |||
bool pose_is_joint_angle = 2; | |||
// 单位:rad/s^2,主轴的关节加速度 | |||
double acceleration = 3; | |||
// 单位:rad/s,主轴的关节速度 | |||
double velocity = 4; | |||
// 单位:s,运动时间 | |||
double time = 5; | |||
// 单位:m,下一段的交融半径 | |||
double blend_radius = 6; | |||
} | |||
message RunInRequest { | |||
repeated MovePoint path = 1; // 单个磨合测试周期轨迹 | |||
double equivalent_radius = 2; // 等效半径 m | |||
double threshold_distance = 3;// 门限距离 m | |||
double position_stable_time = 4; // 位置稳定时间(最大) s | |||
double position_overshoot = 5; // 位置超调量(最大) m | |||
double pose_stable_time = 6; // 姿态稳定时间(最大) s | |||
double pose_overshoot = 7; // 姿态超调量(最大) m | |||
} | |||
message RunInJointInfo { | |||
double min_velocity = 1; // 反馈速度 m/s | |||
double max_velocity = 2; // 反馈速度 | |||
double min_voltage = 3; // 电压 V | |||
double max_voltage = 4; // 电压 | |||
double min_temperature = 5; // 温度 ℃ | |||
double max_temperature = 6; // 温度 | |||
} | |||
message RunInPathResult { | |||
repeated RunInJointInfo joints = 1; | |||
} | |||
message RunInResult { | |||
bool ok = 1; // 是否符合标准 | |||
repeated RunInPathResult path = 2; // 每条轨迹的抖动值 | |||
double position_stable_time = 4; // 位置稳定时间 s | |||
double position_overshoot = 5; // 位置超调量 m | |||
double pose_stable_time = 6; // 姿态稳定时间 s | |||
double pose_overshoot = 7; // 姿态超调量 m | |||
string filename = 8; // csv文件路径 | |||
} | |||
message DeviceIds { | |||
repeated uint32 id = 1; // 同类型的第几个设备 | |||
} | |||
message DeviceValues { | |||
repeated double value = 1; // 读数结果 | |||
} | |||
message ProductTestRequest { | |||
uint32 cmd = 1; // 测试命令 | |||
} | |||
message ProductTestResult { | |||
uint32 testRes = 1; // 测试结果 | |||
uint32 testError = 2; | |||
} | |||
message InitRobotResult { | |||
int32 ret = 1; // 初始化Robort返回结果 | |||
string cup = 2; // 绑定hash值 | |||
} | |||
message WriteSnResult { | |||
int32 writeSnRes = 1; // 写sn结果 | |||
} | |||
message DeviceTypeRequest { | |||
int32 devType = 1; // 要读sn的设备类型 | |||
} | |||
message DecimalInput { | |||
int32 pin = 1; | |||
int32 value = 2; // 1 或者 0。若为 -1 则表示没有结果(没有运行到此处) | |||
} | |||
message MoveDetectPath { | |||
MovePoint path = 1; // 单个轨迹 | |||
repeated DecimalInput moving = 2; // 移动中的各传感器应有值 | |||
repeated DecimalInput cross = 3; // 移动完成后(交点)时的各传感器应有值 | |||
} | |||
message MoveDetectRequest { | |||
repeated MoveDetectPath req = 1; | |||
} | |||
message MoveDetectResult { | |||
bool ok = 1; // 是否符合标准 | |||
repeated MoveDetectPath res = 2; // 周期内移动中的传感器值,不保证path是对的 | |||
string filename = 3; // csv文件路径 | |||
} |
@@ -0,0 +1,46 @@ | |||
syntax = "proto3"; | |||
import "google/protobuf/empty.proto"; | |||
import "messages.proto"; | |||
package robotc; | |||
// 仿真-离线编程模拟服务 | |||
service SimulationController { | |||
// 设置仿真机器人关节角 | |||
rpc SetPos(JPose) returns (SimRes); | |||
// 硬件急停 | |||
rpc EStop(google.protobuf.Empty) returns (SimRes); | |||
// 释放硬件急停开关 | |||
rpc EStopRelease(google.protobuf.Empty) returns (SimRes); | |||
// 按下按钮 | |||
rpc Button(ButtonReq) returns (SimRes); | |||
// 设置百分表值 | |||
rpc SetDialgage(DialgageReq) returns (SimRes); | |||
// 设置模拟输入 | |||
rpc SetRobotAI(AIO) returns (SimRes); | |||
// 设置数字输入 | |||
rpc SetRobotDI(DIO) returns (SimRes); | |||
// 设置法兰数字输入 | |||
rpc SetFlangeDI(DIO) returns (SimRes); | |||
// 设置仿真机器人运行速度 | |||
rpc ChangeRobotSpeed(RobotSpeed) returns (SimRes); | |||
} | |||
message SimRes { | |||
int32 ret = 1; | |||
} | |||
message ButtonReq { | |||
int32 id = 1; | |||
int32 state = 2; // 1: 按钮空闲;2:长按;3:单击;4: 双击 | |||
} | |||
message DialgageReq { | |||
int32 id = 1; // 0, 1, 2 | |||
double value = 2; | |||
} | |||
message RobotSpeed { | |||
uint32 cycle = 1; // 默认为 9,最小为 3。值越大,速度越慢 | |||
} |
@@ -0,0 +1,126 @@ | |||
syntax = "proto3"; | |||
package robotc; | |||
message Response { | |||
int32 ret = 1; | |||
} | |||
message Coordinate { | |||
double x = 1; | |||
double y = 2; | |||
double z = 3; | |||
} | |||
message Rotation { | |||
double r = 1; | |||
double p = 2; | |||
double y = 3; | |||
} | |||
message PR { | |||
Coordinate position = 1; | |||
Rotation rotation = 2; | |||
} | |||
message JPose { | |||
repeated double joints = 1; | |||
} | |||
message Payload { // 末端负载 | |||
double mass = 1; // 质量, default: 0 | |||
Coordinate cog = 2; // 质心,Center of gravity, default: 0 | |||
} | |||
message PayloadMass { | |||
double mass = 1; | |||
} | |||
message PayloadCog { | |||
Coordinate cog = 1; | |||
} | |||
message IOPin { int32 pin = 1; } | |||
message DIO { | |||
int32 pin = 1; | |||
int32 value = 2; | |||
} | |||
message AIO { | |||
//提供给用户做操作的地址 | |||
int32 pin = 1; | |||
//电流环或电压环 | |||
int32 mode = 2; | |||
double value = 3; | |||
} | |||
message ModbusExternalIOState { | |||
//设备ID | |||
int32 id = 1; | |||
//0表示断开,1表示连接成功 | |||
int32 state = 2; | |||
} | |||
//xxx | |||
message IO { | |||
// 所有数字量的输入值 | |||
repeated DIO robotDIOIn = 1; | |||
// 所有数字量的输出值 | |||
repeated DIO robotDIOOut = 2; | |||
// 所有模拟量输入值 | |||
repeated AIO robotAIOIn = 3; | |||
// 所有模拟量输出值 | |||
repeated AIO robotAIOOut = 4; | |||
// 所有tcp数字量的输入值 | |||
repeated DIO tcpDIOIn = 5; | |||
// 所有tcp数字量的输出值 | |||
repeated DIO tcpDIOOut = 6; | |||
//modbus的状态信息 | |||
repeated ModbusExternalIOState extIODevices = 7; | |||
// 所有扩展数字量的输入值 | |||
repeated DIO extra_robotDIOIn = 8; | |||
// 所有扩展数字量的输出值 | |||
repeated DIO extra_robotDIOOut = 9; | |||
// 所有扩展模拟量输入值 | |||
repeated AIO extra_robotAIOIn = 10; | |||
// 所有扩展模拟量输出值 | |||
repeated AIO extra_robotAIOOut = 11; | |||
} | |||
message Hardware { | |||
string model = 1; | |||
string sn = 2; | |||
string driver_version = 3; // 作为传入参数时无意义 | |||
} | |||
message RobotInfo { | |||
Hardware robot = 1; // 机器人型号在 robot.model 里 | |||
Hardware flange = 2; | |||
Hardware led = 3; | |||
repeated Hardware joints = 4; | |||
string rcVersion = 5; // 作为传入时无意义 | |||
string name = 6; // 机器人默认名称 | |||
Hardware comboard = 7; // 主控板 | |||
string mac = 8; // 机械臂整机ID号 | |||
Hardware arm = 9; // 主机箱 | |||
string appTag = 10; // release cfqmp simulate joint circuit | |||
string typeTag = 11; // debug release | |||
bool extra_io = 12; | |||
//xxx | |||
} | |||
message DeviceInfo { | |||
Hardware devInfo = 1; // 主控板 | |||
//2表示通信板、3表示法兰、4表示灯板、5表示关节板 | |||
int32 dev_type = 2; | |||
} | |||
enum LuaState { | |||
IDLE = 0; | |||
RUNNING = 1; | |||
PAUSED = 2; | |||
ABORTED = 3; // Error | |||
STOPPED = 4; // Stop | |||
BEGIN = 5; | |||
END = 6; | |||
}; |