终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LebaiRobotClient.cs 70 KiB

pirms 2 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net.Http;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Grpc.Core;
  7. using Grpc.Net.Client;
  8. using Robotc;
  9. using Empty = Google.Protobuf.WellKnownTypes.Empty;
  10. namespace Lebai.SDK
  11. {
  12. public partial class LebaiRobotClient
  13. {
  14. public static readonly Dictionary<string, LebaiRobotClient> LebaiRobotClients = new();
  15. private readonly HttpClient _httpClient;
  16. private RobotController.RobotControllerClient _robotControllerClient;
  17. private RobotPrivateController.RobotPrivateControllerClient _robotPrivateControllerClient;
  18. public LebaiRobotClient(string ip, int robotControllerClientPort = 5181, int robotPrivateControllerPort = 5182,
  19. GrpcChannelOptions grpcChannelOptions = null)
  20. {
  21. IP = ip;
  22. RobotControllerClientPort = robotControllerClientPort;
  23. RobotPrivateControllerPort = robotPrivateControllerPort;
  24. GrpcChannelOptions = grpcChannelOptions;
  25. _httpClient = new HttpClient {BaseAddress = new Uri($"http://{ip}")};
  26. }
  27. private string IP { get; }
  28. private int RobotControllerClientPort { get; }
  29. private int RobotPrivateControllerPort { get; }
  30. private GrpcChannelOptions GrpcChannelOptions { get; }
  31. public Action<RpcException> OnRpcException { get; set; }
  32. private RobotController.RobotControllerClient RobotControllerClient =>
  33. LazyInitializer.EnsureInitialized(ref _robotControllerClient,
  34. () =>
  35. {
  36. var r = new RobotController.RobotControllerClient(
  37. GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotControllerClientPort}"),
  38. GrpcChannelOptions ??
  39. new GrpcChannelOptions
  40. {
  41. MaxRetryAttempts = 5
  42. })
  43. );
  44. return r;
  45. });
  46. private RobotPrivateController.RobotPrivateControllerClient RobotPrivateControllerClient =>
  47. LazyInitializer.EnsureInitialized(ref _robotPrivateControllerClient,
  48. () => new RobotPrivateController.RobotPrivateControllerClient(
  49. GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotPrivateControllerPort}"), GrpcChannelOptions ??
  50. new GrpcChannelOptions
  51. {
  52. MaxRetryAttempts = 5
  53. })));
  54. public static LebaiRobotClient Get(string ip, int robotControllerClientPort = 5181,
  55. int robotPrivateControllerPort = 5182)
  56. {
  57. if (LebaiRobotClients.ContainsKey(ip)) return LebaiRobotClients[ip];
  58. LebaiRobotClients[ip] = new LebaiRobotClient(ip);
  59. return LebaiRobotClients[ip];
  60. }
  61. /// <summary>
  62. /// 启用/禁用 设备
  63. /// </summary>
  64. /// <param name="externalIoState"></param>
  65. /// <param name="cancellationToken"></param>
  66. public virtual async Task ConnectExternalIO(ExternalIOState externalIoState,
  67. CancellationToken cancellationToken = default)
  68. {
  69. await RobotPrivateControllerClient.ConnectExternalIOAsync(externalIoState,
  70. cancellationToken: cancellationToken);
  71. }
  72. /// <summary>
  73. /// 关闭电源
  74. /// </summary>
  75. public virtual async Task PowerDown(CancellationToken cancellationToken = default)
  76. {
  77. await RobotControllerClient.PowerDownAsync(new Empty(), cancellationToken: cancellationToken);
  78. }
  79. /// <summary>
  80. /// 等待,单位毫秒
  81. /// </summary>
  82. /// <param name="sleepRequest"></param>
  83. /// <param name="cancellationToken"></param>
  84. public virtual async Task Sleep(SleepRequest sleepRequest, CancellationToken cancellationToken = default)
  85. {
  86. await RobotControllerClient.SleepAsync(sleepRequest, cancellationToken: cancellationToken);
  87. }
  88. /// <summary>
  89. /// 同步,等待命令执行完成
  90. /// </summary>
  91. public virtual async Task Sync(CancellationToken cancellationToken = default)
  92. {
  93. try
  94. {
  95. await RobotControllerClient.SyncAsync(new Empty(), cancellationToken: cancellationToken);
  96. }
  97. catch (RpcException e)
  98. {
  99. OnRpcException?.Invoke(e);
  100. }
  101. }
  102. public virtual async Task SyncFor(SyncRequest syncRequest, CancellationToken cancellationToken = default)
  103. {
  104. await RobotControllerClient.SyncForAsync(syncRequest, cancellationToken: cancellationToken);
  105. }
  106. /// <summary>
  107. /// 开启示教模式
  108. /// </summary>
  109. public virtual async Task TeachMode(CancellationToken cancellationToken = default)
  110. {
  111. await RobotControllerClient.TeachModeAsync(new Empty(), cancellationToken: cancellationToken);
  112. }
  113. /// <summary>
  114. /// 关闭示教模式
  115. /// </summary>
  116. public virtual async Task EndTeachMode(CancellationToken cancellationToken = default)
  117. {
  118. await RobotControllerClient.EndTeachModeAsync(new Empty(), cancellationToken: cancellationToken);
  119. }
  120. /// <summary>
  121. /// 设置速度因子(0-100)
  122. /// </summary>
  123. /// <param name="factor"></param>
  124. /// <param name="cancellationToken"></param>
  125. public virtual async Task SetVelocityFactor(Factor factor, CancellationToken cancellationToken = default)
  126. {
  127. await RobotControllerClient.SetVelocityFactorAsync(factor, cancellationToken: cancellationToken);
  128. }
  129. /// <summary>
  130. /// 获取速度因子(0-100)
  131. /// </summary>
  132. /// <returns></returns>
  133. public virtual async Task<Factor> GetVelocityFactor(CancellationToken cancellationToken = default)
  134. {
  135. return await RobotControllerClient.GetVelocityFactorAsync(new Empty(), cancellationToken: cancellationToken);
  136. }
  137. /// <summary>
  138. /// 设置重力方向
  139. /// </summary>
  140. /// <param name="coordinate"></param>
  141. /// <param name="cancellationToken"></param>
  142. public virtual async Task SetGravity(Coordinate coordinate, CancellationToken cancellationToken = default)
  143. {
  144. await RobotControllerClient.SetGravityAsync(coordinate, cancellationToken: cancellationToken);
  145. }
  146. /// <summary>
  147. /// 获取重力方向
  148. /// </summary>
  149. /// <returns></returns>
  150. public virtual async Task<Coordinate> GetGravity(CancellationToken cancellationToken = default)
  151. {
  152. return await RobotControllerClient.GetGravityAsync(new Empty(), cancellationToken: cancellationToken);
  153. }
  154. /// <summary>
  155. /// 设置负载
  156. /// </summary>
  157. /// <param name="payload"></param>
  158. /// <param name="cancellationToken"></param>
  159. public virtual async Task SetPayload(Payload payload, CancellationToken cancellationToken = default)
  160. {
  161. await RobotControllerClient.SetPayloadAsync(payload, cancellationToken: cancellationToken);
  162. }
  163. /// <summary>
  164. /// 获取负载
  165. /// </summary>
  166. /// <returns></returns>
  167. public virtual async Task<Payload> GetPayload(CancellationToken cancellationToken = default)
  168. {
  169. return await RobotControllerClient.GetPayloadAsync(new Empty(), cancellationToken: cancellationToken);
  170. }
  171. /// <summary>
  172. /// 设置负责质量
  173. /// </summary>
  174. /// <param name="payloadMass"></param>
  175. /// <param name="cancellationToken"></param>
  176. public virtual async Task SetPayloadMass(PayloadMass payloadMass,
  177. CancellationToken cancellationToken = default)
  178. {
  179. await RobotControllerClient.SetPayloadMassAsync(payloadMass, cancellationToken: cancellationToken);
  180. }
  181. /// <summary>
  182. /// 获取负责质量
  183. /// </summary>
  184. /// <returns></returns>
  185. public virtual async Task<PayloadMass> GetPayloadMass(CancellationToken cancellationToken = default)
  186. {
  187. return await RobotControllerClient.GetPayloadMassAsync(new Empty(), cancellationToken: cancellationToken);
  188. }
  189. /// <summary>
  190. /// 设置负载质心
  191. /// </summary>
  192. /// <param name="payloadCog"></param>
  193. /// <param name="cancellationToken"></param>
  194. public virtual async Task SetPayloadCog(PayloadCog payloadCog, CancellationToken cancellationToken = default)
  195. {
  196. await RobotControllerClient.SetPayloadCogAsync(payloadCog, cancellationToken: cancellationToken);
  197. }
  198. /// <summary>
  199. /// 获取负责质心
  200. /// </summary>
  201. /// <returns></returns>
  202. public virtual async Task<PayloadCog> GetPayloadCog(CancellationToken cancellationToken = default)
  203. {
  204. return await RobotControllerClient.GetPayloadCogAsync(new Empty(), cancellationToken: cancellationToken);
  205. }
  206. /// <summary>
  207. /// 设置TCP
  208. /// </summary>
  209. /// <param name="pR"></param>
  210. /// <param name="cancellationToken"></param>
  211. public virtual async Task SetTcp(PR pR, CancellationToken cancellationToken = default)
  212. {
  213. await RobotControllerClient.SetTcpAsync(pR, cancellationToken: cancellationToken);
  214. }
  215. /// <summary>
  216. /// 获取TCP
  217. /// </summary>
  218. /// <returns></returns>
  219. public virtual async Task<PR> GetTcp(CancellationToken cancellationToken = default)
  220. {
  221. return await RobotControllerClient.GetTcpAsync(new Empty(), cancellationToken: cancellationToken);
  222. }
  223. /// <summary>
  224. /// 设置手爪幅度:0-100 double
  225. /// </summary>
  226. /// <param name="amplitude"></param>
  227. /// <param name="cancellationToken"></param>
  228. public virtual async Task SetClawAmplitude(Amplitude amplitude,
  229. CancellationToken cancellationToken = default)
  230. {
  231. await RobotControllerClient.SetClawAmplitudeAsync(amplitude, cancellationToken: cancellationToken);
  232. }
  233. /// <summary>
  234. /// 获得手爪幅度:0-100 double
  235. /// </summary>
  236. /// <returns></returns>
  237. public virtual async Task<Amplitude> GetClawAmplitude(CancellationToken cancellationToken = default)
  238. {
  239. return await RobotControllerClient.GetClawAmplitudeAsync(new Empty(), cancellationToken: cancellationToken);
  240. }
  241. /// <summary>
  242. /// 获得手爪目前是否夹紧物体状态1表示夹紧,0为松开
  243. /// </summary>
  244. /// <returns></returns>
  245. public virtual async Task<HoldOn> GetClawHoldOn(CancellationToken cancellationToken = default)
  246. {
  247. return await RobotControllerClient.GetClawHoldOnAsync(new Empty(), cancellationToken: cancellationToken);
  248. }
  249. /// <summary>
  250. /// 设置手爪力度:0-100 double
  251. /// </summary>
  252. /// <param name="force"></param>
  253. /// <param name="cancellationToken"></param>
  254. public virtual async Task SetClawForce(Force force, CancellationToken cancellationToken = default)
  255. {
  256. await RobotControllerClient.SetClawForceAsync(force, cancellationToken: cancellationToken);
  257. }
  258. /// <summary>
  259. /// 获得手爪称重结果
  260. /// </summary>
  261. /// <returns></returns>
  262. public virtual async Task<Weight> GetClawWeight(CancellationToken cancellationToken = default)
  263. {
  264. return await RobotControllerClient.GetClawWeightAsync(new Empty(), cancellationToken: cancellationToken);
  265. }
  266. /// <summary>
  267. /// implement later
  268. /// </summary>
  269. /// <returns></returns>
  270. public virtual async Task<ForceTorque> GetTcpForce(CancellationToken cancellationToken = default)
  271. {
  272. return await RobotControllerClient.GetTcpForceAsync(new Empty(), cancellationToken: cancellationToken);
  273. }
  274. /// <summary>
  275. /// 设置手爪
  276. /// </summary>
  277. /// <param name="clawInfo"></param>
  278. /// <param name="cancellationToken"></param>
  279. /// <returns></returns>
  280. public virtual async Task<ClawInfo> SetClaw(ClawInfo clawInfo, CancellationToken cancellationToken = default)
  281. {
  282. return await RobotControllerClient.SetClawAsync(clawInfo, cancellationToken: cancellationToken);
  283. }
  284. /// <summary>
  285. /// 获取手爪
  286. /// </summary>
  287. /// <returns></returns>
  288. public virtual async Task<ClawInfo> GetClaw(CancellationToken cancellationToken = default)
  289. {
  290. return await RobotControllerClient.GetClawAsync(new Empty(), cancellationToken: cancellationToken);
  291. }
  292. /// <summary>
  293. /// 设置位置
  294. /// </summary>
  295. /// <param name="jPose"></param>
  296. /// <param name="cancellationToken"></param>
  297. public virtual async Task SetPos(JPose jPose, CancellationToken cancellationToken = default)
  298. {
  299. await RobotControllerClient.SetPosAsync(jPose, cancellationToken: cancellationToken);
  300. }
  301. /// <summary>
  302. /// implement later
  303. /// </summary>
  304. /// <param name="speedJRequest"></param>
  305. /// <param name="cancellationToken"></param>
  306. public virtual async Task SpeedJ(SpeedJRequest speedJRequest, CancellationToken cancellationToken = default)
  307. {
  308. await RobotControllerClient.SpeedJAsync(speedJRequest, cancellationToken: cancellationToken);
  309. }
  310. /// <summary>
  311. /// implement later
  312. /// </summary>
  313. /// <param name="speedLRequest"></param>
  314. /// <param name="cancellationToken"></param>
  315. public virtual async Task SpeedL(SpeedLRequest speedLRequest, CancellationToken cancellationToken = default)
  316. {
  317. await RobotControllerClient.SpeedLAsync(speedLRequest, cancellationToken: cancellationToken);
  318. }
  319. /// <summary>
  320. /// implement later
  321. /// </summary>
  322. /// <param name="stopJRequest"></param>
  323. /// <param name="cancellationToken"></param>
  324. public virtual async Task StopJ(StopJRequest stopJRequest, CancellationToken cancellationToken = default)
  325. {
  326. await RobotControllerClient.StopJAsync(stopJRequest, cancellationToken: cancellationToken);
  327. }
  328. /// <summary>
  329. /// implement later
  330. /// </summary>
  331. /// <param name="stopLRequest"></param>
  332. /// <param name="cancellationToken"></param>
  333. public virtual async Task StopL(StopLRequest stopLRequest, CancellationToken cancellationToken = default)
  334. {
  335. await RobotControllerClient.StopLAsync(stopLRequest, cancellationToken: cancellationToken);
  336. }
  337. /// <summary>
  338. /// 停止当前移动
  339. /// </summary>
  340. public virtual async Task StopMove(CancellationToken cancellationToken = default)
  341. {
  342. await RobotControllerClient.StopMoveAsync(new Empty(), cancellationToken: cancellationToken);
  343. }
  344. /// <summary>
  345. /// 圆弧移动
  346. /// </summary>
  347. /// <param name="moveCRequest"></param>
  348. /// <param name="cancellationToken"></param>
  349. public virtual async Task MoveC(MoveCRequest moveCRequest, CancellationToken cancellationToken = default)
  350. {
  351. await RobotControllerClient.MoveCAsync(moveCRequest, cancellationToken: cancellationToken);
  352. }
  353. /// <summary>
  354. /// 关节空间线性移动
  355. /// </summary>
  356. /// <param name="moveJRequest"></param>
  357. /// <param name="cancellationToken"></param>
  358. public virtual async Task MoveJ(MoveJRequest moveJRequest, CancellationToken cancellationToken = default)
  359. {
  360. await RobotControllerClient.MoveJAsync(moveJRequest, cancellationToken: cancellationToken);
  361. }
  362. /// <summary>
  363. /// 笛卡尔空间线性移动
  364. /// </summary>
  365. /// <param name="moveLRequest"></param>
  366. /// <param name="cancellationToken"></param>
  367. public virtual async Task MoveL(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
  368. {
  369. await RobotControllerClient.MoveLAsync(moveLRequest, cancellationToken: cancellationToken);
  370. }
  371. /// <summary>
  372. /// DEPRECIATED
  373. /// </summary>
  374. /// <param name="moveLRequest"></param>
  375. /// <param name="cancellationToken"></param>
  376. [Obsolete]
  377. public virtual async Task MoveLJ(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
  378. {
  379. await RobotControllerClient.MoveLJAsync(moveLRequest, cancellationToken: cancellationToken);
  380. }
  381. /// <summary>
  382. /// implement later
  383. /// </summary>
  384. /// <param name="movePRequest"></param>
  385. /// <param name="cancellationToken"></param>
  386. public virtual async Task MoveP(MovePRequest movePRequest, CancellationToken cancellationToken = default)
  387. {
  388. await RobotControllerClient.MovePAsync(movePRequest, cancellationToken: cancellationToken);
  389. }
  390. /// <summary>
  391. /// pt move
  392. /// </summary>
  393. /// <param name="pVATRequest"></param>
  394. /// <param name="cancellationToken"></param>
  395. public virtual async Task MovePT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
  396. {
  397. await RobotControllerClient.MovePTAsync(pVATRequest, cancellationToken: cancellationToken);
  398. }
  399. /*public void MovePTStream(PVATRequest request,CancellationToken cancellationToken=default)
  400. {
  401. }*/
  402. /// <summary>
  403. /// pvt move
  404. /// </summary>
  405. /// <param name="pVATRequest"></param>
  406. /// <param name="cancellationToken"></param>
  407. public virtual async Task MovePVT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
  408. {
  409. await RobotControllerClient.MovePVTAsync(pVATRequest, cancellationToken: cancellationToken);
  410. }
  411. /*public void MovePVTStream(PVATRequest request,CancellationToken cancellationToken=default)
  412. {
  413. RobotControllerClient.MovePVTStreamAsync(PVATRequest,cancellationToken:cancellationToken);
  414. }*/
  415. /// <summary>
  416. /// pvat move
  417. /// </summary>
  418. /// <param name="pVATRequest"></param>
  419. /// <param name="cancellationToken"></param>
  420. public virtual async Task MovePVAT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
  421. {
  422. await RobotControllerClient.MovePVATAsync(pVATRequest, cancellationToken: cancellationToken);
  423. }
  424. /*public void MovePVATStream(stream stream PVATRequest,CancellationToken cancellationToken=default)
  425. {
  426. RobotControllerClient.MovePVATStreamAsync(PVATRequest,cancellationToken:cancellationToken);
  427. }*/
  428. /// <summary>
  429. /// implement later
  430. /// </summary>
  431. /// <param name="servoCRequest"></param>
  432. /// <param name="cancellationToken"></param>
  433. public virtual async Task ServoC(ServoCRequest servoCRequest, CancellationToken cancellationToken = default)
  434. {
  435. await RobotControllerClient.ServoCAsync(servoCRequest, cancellationToken: cancellationToken);
  436. }
  437. /// <summary>
  438. /// implement later
  439. /// </summary>
  440. /// <param name="servoJRequest"></param>
  441. /// <param name="cancellationToken"></param>
  442. public virtual async Task ServoJ(ServoJRequest servoJRequest, CancellationToken cancellationToken = default)
  443. {
  444. await RobotControllerClient.ServoJAsync(servoJRequest, cancellationToken: cancellationToken);
  445. }
  446. /// <summary>
  447. /// 获取机器人所有状态数据
  448. /// </summary>
  449. /// <returns></returns>
  450. public virtual async Task<RobotData> GetRobotData(CancellationToken cancellationToken = default)
  451. {
  452. return await RobotControllerClient.GetRobotDataAsync(new Empty(), cancellationToken: cancellationToken);
  453. }
  454. /// <summary>
  455. /// 获取机器人状态
  456. /// </summary>
  457. /// <returns></returns>
  458. public virtual async Task<RobotMode> GetRobotMode(CancellationToken cancellationToken = default)
  459. {
  460. return await RobotControllerClient.GetRobotModeAsync(new Empty(), cancellationToken: cancellationToken);
  461. }
  462. /// <summary>
  463. /// 获得实际关节位置
  464. /// </summary>
  465. /// <returns></returns>
  466. public virtual async Task<Joint> GetActualJointPositions(CancellationToken cancellationToken = default)
  467. {
  468. return await RobotControllerClient.GetActualJointPositionsAsync(new Empty(),
  469. cancellationToken: cancellationToken);
  470. }
  471. /// <summary>
  472. /// 获得目标关节位置
  473. /// </summary>
  474. /// <returns></returns>
  475. public virtual async Task<Joint> GetTargetJointPositions(CancellationToken cancellationToken = default)
  476. {
  477. return await RobotControllerClient.GetTargetJointPositionsAsync(new Empty(),
  478. cancellationToken: cancellationToken);
  479. }
  480. /// <summary>
  481. /// 获得实际关节速度
  482. /// </summary>
  483. /// <returns></returns>
  484. public virtual async Task<Joint> GetActualJointSpeeds(CancellationToken cancellationToken = default)
  485. {
  486. return await RobotControllerClient.GetActualJointSpeedsAsync(new Empty(),
  487. cancellationToken: cancellationToken);
  488. }
  489. /// <summary>
  490. /// 获得目标关节速度
  491. /// </summary>
  492. /// <returns></returns>
  493. public virtual async Task<Joint> GetTargetJointSpeeds(CancellationToken cancellationToken = default)
  494. {
  495. return await RobotControllerClient.GetTargetJointSpeedsAsync(new Empty(),
  496. cancellationToken: cancellationToken);
  497. }
  498. /// <summary>
  499. /// 获得末端在笛卡尔坐标系下的位姿
  500. /// </summary>
  501. /// <returns></returns>
  502. public virtual async Task<Vector> GetActualTcpPose(CancellationToken cancellationToken = default)
  503. {
  504. return await RobotControllerClient.GetActualTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
  505. }
  506. /// <summary>
  507. /// 获得末端在笛卡尔坐标系下的目标位姿
  508. /// </summary>
  509. /// <returns></returns>
  510. public virtual async Task<Vector> GetTargetTcpPose(CancellationToken cancellationToken = default)
  511. {
  512. return await RobotControllerClient.GetTargetTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
  513. }
  514. /// <summary>
  515. /// implement later
  516. /// </summary>
  517. /// <returns></returns>
  518. public virtual async Task<Vector> GetActualTcpSpeed(CancellationToken cancellationToken = default)
  519. {
  520. return await RobotControllerClient.GetActualTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
  521. }
  522. /// <summary>
  523. /// implement later
  524. /// </summary>
  525. /// <returns></returns>
  526. public virtual async Task<Vector> GetTargetTcpSpeed(CancellationToken cancellationToken = default)
  527. {
  528. return await RobotControllerClient.GetTargetTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
  529. }
  530. /// <summary>
  531. /// implement later
  532. /// </summary>
  533. /// <returns></returns>
  534. public virtual async Task<Vector> GetActualFlangePose(CancellationToken cancellationToken = default)
  535. {
  536. return await RobotControllerClient.GetActualFlangePoseAsync(new Empty(), cancellationToken: cancellationToken);
  537. }
  538. /// <summary>
  539. /// 获取关节扭矩
  540. /// </summary>
  541. /// <returns></returns>
  542. public virtual async Task<Joint> GetJointTorques(CancellationToken cancellationToken = default)
  543. {
  544. return await RobotControllerClient.GetJointTorquesAsync(new Empty(), cancellationToken: cancellationToken);
  545. }
  546. /// <summary>
  547. /// 获取控制器温度
  548. /// </summary>
  549. /// <returns></returns>
  550. public virtual async Task<Temperature> GetControllerTemp(CancellationToken cancellationToken = default)
  551. {
  552. return await RobotControllerClient.GetControllerTempAsync(new Empty(), cancellationToken: cancellationToken);
  553. }
  554. /// <summary>
  555. /// 获取关节内部温度
  556. /// </summary>
  557. /// <param name="intRequest"></param>
  558. /// <returns></returns>
  559. public virtual async Task<Temperature> GetJointTemp(IntRequest intRequest,
  560. CancellationToken cancellationToken = default)
  561. {
  562. return await RobotControllerClient.GetJointTempAsync(intRequest, cancellationToken: cancellationToken);
  563. }
  564. /// <summary>
  565. /// implement later
  566. /// </summary>
  567. /// <returns></returns>
  568. public virtual async Task<Current> GetToolCurrent(CancellationToken cancellationToken = default)
  569. {
  570. return await RobotControllerClient.GetToolCurrentAsync(new Empty(), cancellationToken: cancellationToken);
  571. }
  572. /// <summary>
  573. /// 设置数字输出端口的值
  574. /// </summary>
  575. /// <param name="dIO"></param>
  576. /// <param name="cancellationToken"></param>
  577. public virtual async Task SetDIO(DIO dIO, CancellationToken cancellationToken = default)
  578. {
  579. await RobotControllerClient.SetDIOAsync(dIO, cancellationToken: cancellationToken);
  580. }
  581. /// <summary>
  582. /// 设置扩展数字输出端口的值
  583. /// </summary>
  584. /// <param name="dIO"></param>
  585. /// <param name="cancellationToken"></param>
  586. public virtual async Task SetExtraDIO(DIO dIO, CancellationToken cancellationToken = default)
  587. {
  588. await RobotControllerClient.SetExtraDIOAsync(dIO, cancellationToken: cancellationToken);
  589. }
  590. /// <summary>
  591. /// 获得数字输入端口的值
  592. /// </summary>
  593. /// <param name="iOPin"></param>
  594. /// <param name="cancellationToken"></param>
  595. /// <returns></returns>
  596. public virtual async Task<DIO> GetDIO(IOPin iOPin, CancellationToken cancellationToken = default)
  597. {
  598. return await RobotControllerClient.GetDIOAsync(iOPin, cancellationToken: cancellationToken);
  599. }
  600. /// <summary>
  601. /// 获得扩展数字数如端口的值
  602. /// </summary>
  603. /// <param name="iOPin"></param>
  604. /// <param name="cancellationToken"></param>
  605. /// <returns></returns>
  606. public virtual async Task<DIO> GetExtraDIO(IOPin iOPin, CancellationToken cancellationToken = default)
  607. {
  608. return await RobotControllerClient.GetExtraDIOAsync(iOPin, cancellationToken: cancellationToken);
  609. }
  610. /// <summary>
  611. /// 设置TCP数字输出端口的值
  612. /// </summary>
  613. /// <param name="dIO"></param>
  614. /// <param name="cancellationToken"></param>
  615. public virtual async Task SetTcpDIO(DIO dIO, CancellationToken cancellationToken = default)
  616. {
  617. await RobotControllerClient.SetTcpDIOAsync(dIO, cancellationToken: cancellationToken);
  618. }
  619. /// <summary>
  620. /// 获得TCP数字输入端口的值
  621. /// </summary>
  622. /// <param name="iOPin"></param>
  623. /// <param name="cancellationToken"></param>
  624. /// <returns></returns>
  625. public virtual async Task<DIO> GetTcpDIO(IOPin iOPin, CancellationToken cancellationToken = default)
  626. {
  627. return await RobotControllerClient.GetTcpDIOAsync(iOPin, cancellationToken: cancellationToken);
  628. }
  629. /// <summary>
  630. /// 设置模拟输出端口的值
  631. /// </summary>
  632. /// <param name="aIO"></param>
  633. /// <param name="cancellationToken"></param>
  634. public virtual async Task SetAIO(AIO aIO, CancellationToken cancellationToken = default)
  635. {
  636. await RobotControllerClient.SetAIOAsync(aIO, cancellationToken: cancellationToken);
  637. }
  638. /// <summary>
  639. /// 获得模拟输入端口的值
  640. /// </summary>
  641. /// <param name="aIO"></param>
  642. /// <param name="cancellationToken"></param>
  643. public virtual async Task SetExtraAIO(AIO aIO, CancellationToken cancellationToken = default)
  644. {
  645. await RobotControllerClient.SetExtraAIOAsync(aIO, cancellationToken: cancellationToken);
  646. }
  647. /// <summary>
  648. /// 获得模拟输入端口的值
  649. /// </summary>
  650. /// <param name="iOPin"></param>
  651. /// <param name="cancellationToken"></param>
  652. /// <returns></returns>
  653. public virtual async Task<AIO> GetAIO(IOPin iOPin, CancellationToken cancellationToken = default)
  654. {
  655. return await RobotControllerClient.GetAIOAsync(iOPin, cancellationToken: cancellationToken);
  656. }
  657. /// <summary>
  658. /// 获得扩展模拟输入端口的值
  659. /// </summary>
  660. /// <param name="iOPin"></param>
  661. /// <param name="cancellationToken"></param>
  662. /// <returns></returns>
  663. public virtual async Task<AIO> GetExtraAIO(IOPin iOPin, CancellationToken cancellationToken = default)
  664. {
  665. return await RobotControllerClient.GetExtraAIOAsync(iOPin, cancellationToken: cancellationToken);
  666. }
  667. /// <summary>
  668. /// 设置模拟输入端口工作模式:0:电压,1:电流
  669. /// </summary>
  670. /// <param name="aIO"></param>
  671. /// <param name="cancellationToken"></param>
  672. public virtual async Task SetAInMode(AIO aIO, CancellationToken cancellationToken = default)
  673. {
  674. await RobotControllerClient.SetAInModeAsync(aIO, cancellationToken: cancellationToken);
  675. }
  676. /// <summary>
  677. /// 设置扩展模拟输入端口工作模式:0:电压,1:电流
  678. /// </summary>
  679. /// <param name="aIO"></param>
  680. /// <param name="cancellationToken"></param>
  681. public virtual async Task SetExtraAInMode(AIO aIO, CancellationToken cancellationToken = default)
  682. {
  683. await RobotControllerClient.SetExtraAInModeAsync(aIO, cancellationToken: cancellationToken);
  684. }
  685. /// <summary>
  686. /// 获得模拟输入端口工作模式:0:电压,1:电流
  687. /// </summary>
  688. /// <param name="iOPin"></param>
  689. /// <param name="cancellationToken"></param>
  690. /// <returns></returns>
  691. public virtual async Task<AIO> GetAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
  692. {
  693. return await RobotControllerClient.GetAInModeAsync(iOPin, cancellationToken: cancellationToken);
  694. }
  695. /// <summary>
  696. /// 获得扩展模拟输入端口工作模式:0:电压,1:电流
  697. /// </summary>
  698. /// <param name="iOPin"></param>
  699. /// <param name="cancellationToken"></param>
  700. /// <returns></returns>
  701. public virtual async Task<AIO> GetExtraAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
  702. {
  703. return await RobotControllerClient.GetExtraAInModeAsync(iOPin, cancellationToken: cancellationToken);
  704. }
  705. /// <summary>
  706. /// 设置模拟输出端口工作模式:0:电压,1:电流
  707. /// </summary>
  708. /// <param name="aIO"></param>
  709. /// <param name="cancellationToken"></param>
  710. public virtual async Task SetAOutMode(AIO aIO, CancellationToken cancellationToken = default)
  711. {
  712. await RobotControllerClient.SetAOutModeAsync(aIO, cancellationToken: cancellationToken);
  713. }
  714. /// <summary>
  715. /// 设置扩展模拟输出端口工作模式:0:电压,1:电流
  716. /// </summary>
  717. /// <param name="aIO"></param>
  718. /// <param name="cancellationToken"></param>
  719. public virtual async Task SetExtraAOutMode(AIO aIO, CancellationToken cancellationToken = default)
  720. {
  721. await RobotControllerClient.SetExtraAOutModeAsync(aIO, cancellationToken: cancellationToken);
  722. }
  723. /// <summary>
  724. /// 获得模拟输出端口工作模式:0:电压,1:电流
  725. /// </summary>
  726. /// <param name="iOPin"></param>
  727. /// <param name="cancellationToken"></param>
  728. /// <returns></returns>
  729. public virtual async Task<AIO> GetAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
  730. {
  731. return await RobotControllerClient.GetAOutModeAsync(iOPin, cancellationToken: cancellationToken);
  732. }
  733. /// <summary>
  734. /// 获得扩展模拟输出端口工作模式:0:电压,1:电流
  735. /// </summary>
  736. /// <param name="iOPin"></param>
  737. /// <param name="cancellationToken"></param>
  738. /// <returns></returns>
  739. public virtual async Task<AIO> GetExtraAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
  740. {
  741. return await RobotControllerClient.GetExtraAOutModeAsync(iOPin, cancellationToken: cancellationToken);
  742. }
  743. /// <summary>
  744. /// 开启/启动系统
  745. /// </summary>
  746. public virtual async Task StartSys(CancellationToken cancellationToken = default)
  747. {
  748. await RobotControllerClient.StartSysAsync(new Empty(), cancellationToken: cancellationToken);
  749. }
  750. /// <summary>
  751. /// 关闭/停止系统
  752. /// </summary>
  753. public virtual async Task StopSys(CancellationToken cancellationToken = default)
  754. {
  755. await RobotControllerClient.StopSysAsync(new Empty(), cancellationToken: cancellationToken);
  756. }
  757. /// <summary>
  758. /// 程序停止
  759. /// </summary>
  760. public virtual async Task Stop(CancellationToken cancellationToken = default)
  761. {
  762. await RobotControllerClient.StopAsync(new Empty(), cancellationToken: cancellationToken);
  763. }
  764. /// <summary>
  765. /// 急停
  766. /// </summary>
  767. public virtual async Task EStop(CancellationToken cancellationToken = default)
  768. {
  769. await RobotControllerClient.EStopAsync(new Empty(), cancellationToken: cancellationToken);
  770. }
  771. /// <summary>
  772. /// 获取kdl参数
  773. /// </summary>
  774. /// <returns></returns>
  775. public virtual async Task<KDParam> GetKDL(CancellationToken cancellationToken = default)
  776. {
  777. return await RobotControllerClient.GetKDLAsync(new Empty(), cancellationToken: cancellationToken);
  778. }
  779. /// <summary>
  780. /// 查询系统里面的日志信息
  781. /// </summary>
  782. /// <returns></returns>
  783. public virtual async Task<Logs> GetLogs(CancellationToken cancellationToken = default)
  784. {
  785. return await RobotControllerClient.GetLogsAsync(new Empty(), cancellationToken: cancellationToken);
  786. }
  787. /// <summary>
  788. /// 获得当前正在执行的命令id,如果没有在执行的命令,则返回-1
  789. /// </summary>
  790. public virtual async Task GetCurrentCmd(CancellationToken cancellationToken = default)
  791. {
  792. await RobotControllerClient.GetCurrentCmdAsync(new Empty(), cancellationToken: cancellationToken);
  793. }
  794. /*
  795. // 获得指定命令id的执行结果:-1: 未执行;0: 已执行
  796. public CmdStatus GetCmdExecStatus(void cmdId,CancellationToken cancellationToken=default)
  797. {
  798. return await nt.GetCmdExecStatus(cmdId,cancellationToken:cancellationToken);
  799. }*/
  800. /// <summary>
  801. /// 开始微调: 如果当前有其他微调再传入新的微调命令会终止当前的微调进行新的微调
  802. /// </summary>
  803. /// <param name="fineTuning"></param>
  804. public virtual async Task StartFineTuning(FineTuning fineTuning,
  805. CancellationToken cancellationToken = default)
  806. {
  807. await RobotControllerClient.StartFineTuningAsync(fineTuning, cancellationToken: cancellationToken);
  808. }
  809. /// <summary>
  810. /// 停止微调
  811. /// </summary>
  812. public virtual async Task StopFineTuning(CancellationToken cancellationToken = default)
  813. {
  814. await RobotControllerClient.StopFineTuningAsync(new Empty(), cancellationToken: cancellationToken);
  815. }
  816. /// <summary>
  817. /// 暂停机器人
  818. /// </summary>
  819. public virtual async Task Pause(CancellationToken cancellationToken = default)
  820. {
  821. await RobotControllerClient.PauseAsync(new Empty(), cancellationToken: cancellationToken);
  822. }
  823. /// <summary>
  824. /// 恢复机器人
  825. /// </summary>
  826. public virtual async Task Resume(CancellationToken cancellationToken = default)
  827. {
  828. await RobotControllerClient.ResumeAsync(new Empty(), cancellationToken: cancellationToken);
  829. }
  830. /// <summary>
  831. /// 机器人正解
  832. /// </summary>
  833. /// <param name="joint"></param>
  834. /// <param name="cancellationToken"></param>
  835. /// <returns></returns>
  836. public virtual async Task<Vector> KinematicsForward(Joint joint,
  837. CancellationToken cancellationToken = default)
  838. {
  839. return await RobotControllerClient.KinematicsForwardAsync(joint, cancellationToken: cancellationToken);
  840. }
  841. /// <summary>
  842. /// 机器人反解
  843. /// </summary>
  844. /// <param name="vector"></param>
  845. /// <param name="cancellationToken"></param>
  846. /// <returns></returns>
  847. public virtual async Task<Joint> KinematicsInverse(Vector vector,
  848. CancellationToken cancellationToken = default)
  849. {
  850. return await RobotControllerClient.KinematicsInverseAsync(vector, cancellationToken: cancellationToken);
  851. }
  852. /// <summary>
  853. /// TCP示教添加
  854. /// </summary>
  855. /// <param name="calcTcpParam"></param>
  856. /// <param name="cancellationToken"></param>
  857. /// <returns></returns>
  858. public virtual async Task<Vector> CalcTcpTranslation(CalcTcpParam calcTcpParam,
  859. CancellationToken cancellationToken = default)
  860. {
  861. return await RobotControllerClient.CalcTcpTranslationAsync(calcTcpParam, cancellationToken: cancellationToken);
  862. }
  863. /// <summary>
  864. /// 测试命令,以给定的RPY数据执行线性移动
  865. /// </summary>
  866. /// <param name="moveLRPYRequest"></param>
  867. /// <param name="cancellationToken"></param>
  868. public virtual async Task MoveLRPY(MoveLRPYRequest moveLRPYRequest,
  869. CancellationToken cancellationToken = default)
  870. {
  871. await RobotControllerClient.MoveLRPYAsync(moveLRPYRequest, cancellationToken: cancellationToken);
  872. }
  873. /// <summary>
  874. /// 设置LED灯状态
  875. /// </summary>
  876. /// <param name="lEDStatus"></param>
  877. /// <param name="cancellationToken"></param>
  878. public virtual async Task SetLED(LEDStatus lEDStatus, CancellationToken cancellationToken = default)
  879. {
  880. await RobotControllerClient.SetLEDAsync(lEDStatus, cancellationToken: cancellationToken);
  881. }
  882. /// <summary>
  883. /// 设置声音
  884. /// </summary>
  885. /// <param name="voiceStatus"></param>
  886. public virtual async Task SetVoice(VoiceStatus voiceStatus, CancellationToken cancellationToken = default)
  887. {
  888. await RobotControllerClient.SetVoiceAsync(voiceStatus, cancellationToken: cancellationToken);
  889. }
  890. /// <summary>
  891. /// 设置风扇
  892. /// </summary>
  893. /// <param name="fanStatus"></param>
  894. /// <param name="cancellationToken"></param>
  895. public virtual async Task SetFan(FanStatus fanStatus, CancellationToken cancellationToken = default)
  896. {
  897. await RobotControllerClient.SetFanAsync(fanStatus, cancellationToken: cancellationToken);
  898. }
  899. /// <summary>
  900. /// 获取灯板状态
  901. /// </summary>
  902. /// <returns></returns>
  903. public virtual async Task<LampStatus> GetLampStatus(CancellationToken cancellationToken = default)
  904. {
  905. return await RobotControllerClient.GetLampStatusAsync(new Empty(), cancellationToken: cancellationToken);
  906. }
  907. /// <summary>
  908. /// Lua 状态查询
  909. /// </summary>
  910. /// <returns></returns>
  911. public virtual async Task<LuaStatus> GetLuaState(CancellationToken cancellationToken = default)
  912. {
  913. return await RobotControllerClient.GetLuaStateAsync(new Empty(), cancellationToken: cancellationToken);
  914. }
  915. /// <summary>
  916. /// 设置外置数字输出
  917. /// </summary>
  918. /// <param name="externalDigital"></param>
  919. /// <param name="cancellationToken"></param>
  920. /// <returns></returns>
  921. public virtual async Task<Response> SetExternalDO(ExternalDigital externalDigital,
  922. CancellationToken cancellationToken = default)
  923. {
  924. return await RobotControllerClient.SetExternalDOAsync(externalDigital, cancellationToken: cancellationToken);
  925. }
  926. /// <summary>
  927. /// 获取外置数字输出
  928. /// </summary>
  929. /// <param name="externalPin"></param>
  930. /// <param name="cancellationToken"></param>
  931. /// <returns></returns>
  932. public virtual async Task<ExternalDigital> GetExternalDO(ExternalPin externalPin,
  933. CancellationToken cancellationToken = default)
  934. {
  935. return await RobotControllerClient.GetExternalDOAsync(externalPin, cancellationToken: cancellationToken);
  936. }
  937. /// <summary>
  938. /// 获取外置数字输入
  939. /// </summary>
  940. /// <param name="externalPin"></param>
  941. /// <param name="cancellationToken"></param>
  942. /// <returns></returns>
  943. public virtual async Task<ExternalDigital> GetExternalDI(ExternalPin externalPin,
  944. CancellationToken cancellationToken = default)
  945. {
  946. return await RobotControllerClient.GetExternalDIAsync(externalPin, cancellationToken: cancellationToken);
  947. }
  948. /// <summary>
  949. /// 设置外置模拟输出
  950. /// </summary>
  951. /// <param name="externalAnalog"></param>
  952. /// <param name="cancellationToken"></param>
  953. /// <returns></returns>
  954. public virtual async Task<Response> SetExternalAO(ExternalAnalog externalAnalog,
  955. CancellationToken cancellationToken = default)
  956. {
  957. return await RobotControllerClient.SetExternalAOAsync(externalAnalog, cancellationToken: cancellationToken);
  958. }
  959. /// <summary>
  960. /// 获取外置模拟输出
  961. /// </summary>
  962. /// <param name="externalPin"></param>
  963. /// <param name="cancellationToken"></param>
  964. /// <returns></returns>
  965. public virtual async Task<ExternalAnalog> GetExternalAO(ExternalPin externalPin,
  966. CancellationToken cancellationToken = default)
  967. {
  968. return await RobotControllerClient.GetExternalAOAsync(externalPin, cancellationToken: cancellationToken);
  969. }
  970. /// <summary>
  971. /// 获取外置模拟输入
  972. /// </summary>
  973. /// <param name="externalPin"></param>
  974. /// <param name="cancellationToken"></param>
  975. /// <returns></returns>
  976. public virtual async Task<ExternalAnalog> GetExternalAI(ExternalPin externalPin,
  977. CancellationToken cancellationToken = default)
  978. {
  979. return await RobotControllerClient.GetExternalAIAsync(externalPin, cancellationToken: cancellationToken);
  980. }
  981. /// <summary>
  982. /// 获取某个外置io的全部io信息
  983. /// </summary>
  984. /// <param name="externalDevice"></param>
  985. /// <param name="cancellationToken"></param>
  986. /// <returns></returns>
  987. public virtual async Task<ExternalIOs> GetExternalIOs(ExternalDevice externalDevice,
  988. CancellationToken cancellationToken = default)
  989. {
  990. return await RobotControllerClient.GetExternalIOsAsync(externalDevice, cancellationToken: cancellationToken);
  991. }
  992. /// <summary>
  993. /// 设置某个外置io的全部io信息
  994. /// </summary>
  995. /// <param name="externalDigitals"></param>
  996. /// <param name="cancellationToken"></param>
  997. /// <returns></returns>
  998. public virtual async Task<Response> SetExternalDOs(ExternalDigitals externalDigitals,
  999. CancellationToken cancellationToken = default)
  1000. {
  1001. return await RobotControllerClient.SetExternalDOsAsync(externalDigitals, cancellationToken: cancellationToken);
  1002. }
  1003. /// <summary>
  1004. /// 获取外置数字输出
  1005. /// </summary>
  1006. /// <param name="externalPins"></param>
  1007. /// <param name="cancellationToken"></param>
  1008. /// <returns></returns>
  1009. public virtual async Task<ExternalDigitals> GetExternalDOs(ExternalPins externalPins,
  1010. CancellationToken cancellationToken = default)
  1011. {
  1012. return await RobotControllerClient.GetExternalDOsAsync(externalPins, cancellationToken: cancellationToken);
  1013. }
  1014. /// <summary>
  1015. /// 获取外置数字输入
  1016. /// </summary>
  1017. /// <param name="externalPins"></param>
  1018. /// <param name="cancellationToken"></param>
  1019. /// <returns></returns>
  1020. public virtual async Task<ExternalDigitals> GetExternalDIs(ExternalPins externalPins,
  1021. CancellationToken cancellationToken = default)
  1022. {
  1023. return await RobotControllerClient.GetExternalDIsAsync(externalPins, cancellationToken: cancellationToken);
  1024. }
  1025. /// <summary>
  1026. /// 设置外置模拟输出
  1027. /// </summary>
  1028. /// <param name="externalAnalogs"></param>
  1029. /// <param name="cancellationToken"></param>
  1030. /// <returns></returns>
  1031. public virtual async Task<Response> SetExternalAOs(ExternalAnalogs externalAnalogs,
  1032. CancellationToken cancellationToken = default)
  1033. {
  1034. return await RobotControllerClient.SetExternalAOsAsync(externalAnalogs, cancellationToken: cancellationToken);
  1035. }
  1036. /// <summary>
  1037. /// 获取外置模拟输出
  1038. /// </summary>
  1039. /// <param name="externalPins"></param>
  1040. /// <param name="cancellationToken"></param>
  1041. /// <returns></returns>
  1042. public virtual async Task<ExternalAnalogs> GetExternalAOs(ExternalPins externalPins,
  1043. CancellationToken cancellationToken = default)
  1044. {
  1045. return await RobotControllerClient.GetExternalAOsAsync(externalPins, cancellationToken: cancellationToken);
  1046. }
  1047. /// <summary>
  1048. /// 获取外置模拟输入
  1049. /// </summary>
  1050. /// <param name="externalPins"></param>
  1051. /// <param name="cancellationToken"></param>
  1052. /// <returns></returns>
  1053. public virtual async Task<ExternalAnalogs> GetExternalAIs(ExternalPins externalPins,
  1054. CancellationToken cancellationToken = default)
  1055. {
  1056. return await RobotControllerClient.GetExternalAIsAsync(externalPins, cancellationToken: cancellationToken);
  1057. }
  1058. /// <summary>
  1059. /// 设置信号量
  1060. /// </summary>
  1061. /// <param name="signalValue"></param>
  1062. /// <param name="cancellationToken"></param>
  1063. /// <returns></returns>
  1064. public virtual async Task<SignalResult> SetSignal(SignalValue signalValue,
  1065. CancellationToken cancellationToken = default)
  1066. {
  1067. return await RobotControllerClient.SetSignalAsync(signalValue, cancellationToken: cancellationToken);
  1068. }
  1069. /// <summary>
  1070. /// 获取信号量
  1071. /// </summary>
  1072. /// <param name="signalValue"></param>
  1073. /// <param name="cancellationToken"></param>
  1074. /// <returns></returns>
  1075. public virtual async Task<SignalResult> GetSignal(SignalValue signalValue,
  1076. CancellationToken cancellationToken = default)
  1077. {
  1078. return await RobotControllerClient.GetSignalAsync(signalValue, cancellationToken: cancellationToken);
  1079. }
  1080. /// <summary>
  1081. /// 添加信号量
  1082. /// </summary>
  1083. /// <param name="signalValue"></param>
  1084. /// <param name="cancellationToken"></param>
  1085. /// <returns></returns>
  1086. public virtual async Task<SignalResult> AddSignal(SignalValue signalValue,
  1087. CancellationToken cancellationToken = default)
  1088. {
  1089. return await RobotControllerClient.AddSignalAsync(signalValue, cancellationToken: cancellationToken);
  1090. }
  1091. /*
  1092. public stream RegisterSignals(stream stream SignalList,CancellationToken cancellationToken=default)
  1093. {
  1094. return await RobotControllerClient.RegisterSignals().RequestStream.WriteAsync(cancellationToken:cancellationToken);
  1095. }*/
  1096. /// <summary>
  1097. /// 初始化配置
  1098. /// </summary>
  1099. /// <param name="configuration"></param>
  1100. /// <param name="cancellationToken"></param>
  1101. public virtual async void Init(Configuration configuration, CancellationToken cancellationToken = default)
  1102. {
  1103. await RobotPrivateControllerClient.InitAsync(configuration, cancellationToken: cancellationToken);
  1104. }
  1105. /// <summary>
  1106. /// 获取机器人基础信息
  1107. /// </summary>
  1108. /// <returns></returns>
  1109. public virtual async Task<RobotInfo> GetRobotInfo(CancellationToken cancellationToken = default)
  1110. {
  1111. return await RobotPrivateControllerClient.GetRobotInfoAsync(new Empty(), cancellationToken: cancellationToken);
  1112. }
  1113. /// <summary>
  1114. /// 设置机器人安装方向
  1115. /// </summary>
  1116. /// <param name="installDirection"></param>
  1117. /// <param name="cancellationToken"></param>
  1118. /// <returns></returns>
  1119. public virtual async Task<Response> SetInstallDirection(InstallDirection installDirection,
  1120. CancellationToken cancellationToken = default)
  1121. {
  1122. return await RobotPrivateControllerClient.SetInstallDirectionAsync(installDirection,
  1123. cancellationToken: cancellationToken);
  1124. }
  1125. /// <summary>
  1126. /// 设置碰撞检测
  1127. /// </summary>
  1128. /// <param name="collisionDetector"></param>
  1129. /// <param name="cancellationToken"></param>
  1130. /// <returns></returns>
  1131. public virtual async Task<Response> SetCollisionDetector(CollisionDetector collisionDetector,
  1132. CancellationToken cancellationToken = default)
  1133. {
  1134. return await RobotPrivateControllerClient.SetCollisionDetectorAsync(collisionDetector,
  1135. cancellationToken: cancellationToken);
  1136. }
  1137. /// <summary>
  1138. /// 设置关节配置
  1139. /// </summary>
  1140. /// <param name="jointConfigs"></param>
  1141. /// <param name="cancellationToken"></param>
  1142. /// <returns></returns>
  1143. public virtual async Task<Response> SetJointConfig(JointConfigs jointConfigs,
  1144. CancellationToken cancellationToken = default)
  1145. {
  1146. return await RobotPrivateControllerClient.SetJointConfigAsync(jointConfigs,
  1147. cancellationToken: cancellationToken);
  1148. }
  1149. /// <summary>
  1150. /// 设置笛卡尔空间的配置
  1151. /// </summary>
  1152. /// <param name="cartesianConfig"></param>
  1153. /// <param name="cancellationToken"></param>
  1154. /// <returns></returns>
  1155. public virtual async Task<Response> SetCartesianConfig(CartesianConfig cartesianConfig,
  1156. CancellationToken cancellationToken = default)
  1157. {
  1158. return await RobotPrivateControllerClient.SetCartesianConfigAsync(cartesianConfig,
  1159. cancellationToken: cancellationToken);
  1160. }
  1161. /// <summary>
  1162. /// 开启DDS
  1163. /// </summary>
  1164. /// <param name="trueOrFalse"></param>
  1165. /// <param name="cancellationToken"></param>
  1166. /// <returns></returns>
  1167. public virtual async Task<Response> EnableDDS(TrueOrFalse trueOrFalse,
  1168. CancellationToken cancellationToken = default)
  1169. {
  1170. return await RobotPrivateControllerClient.EnableDDSAsync(trueOrFalse, cancellationToken: cancellationToken);
  1171. }
  1172. /// <summary>
  1173. /// 设置碰撞检测力矩差阈值
  1174. /// </summary>
  1175. /// <param name="collisionTorqueDiff"></param>
  1176. /// <param name="cancellationToken"></param>
  1177. /// <returns></returns>
  1178. public virtual async Task<Response> SetCollisionTorqueDiff(CollisionTorqueDiff collisionTorqueDiff,
  1179. CancellationToken cancellationToken = default)
  1180. {
  1181. return await RobotPrivateControllerClient.SetCollisionTorqueDiffAsync(collisionTorqueDiff,
  1182. cancellationToken: cancellationToken);
  1183. }
  1184. // 注册通知事件
  1185. /*public virtual async stream Notification RegisterNotification(google.protobuf.Empty){
  1186. await RobotPrivateControllerClient.RegisterNotification(new Empty(),cancellationToken:cancellationToken);
  1187. }*/
  1188. public virtual async Task<DriverInfo> RobotDriverInfo(CancellationToken cancellationToken = default)
  1189. {
  1190. return await RobotPrivateControllerClient.RobotDriverInfoAsync(new Empty(),
  1191. cancellationToken: cancellationToken);
  1192. }
  1193. /*// 机器人OTA单个设备更新接口
  1194. public virtual async stream OTAResult RobotOTA(OTAData){
  1195. await RobotPrivateControllerClient.RobotOTAAsync(cancellationToken:cancellationToken);
  1196. }*/
  1197. /// <summary>
  1198. /// 通知灯板、法兰、关节切换分区
  1199. /// </summary>
  1200. /// <param name="otaCmd"></param>
  1201. /// <param name="cancellationToken"></param>
  1202. /// <returns></returns>
  1203. public virtual async Task<Response> SwitchOtaPartition(OTACmd otaCmd,
  1204. CancellationToken cancellationToken = default)
  1205. {
  1206. return await RobotPrivateControllerClient.SwitchOtaPartitionAsync(otaCmd,
  1207. cancellationToken: cancellationToken);
  1208. }
  1209. /*// 机器人OTA批量更新接口
  1210. public virtual async stream OTAResults RobotOTABatch(OTADatas){
  1211. await RobotPrivateControllerClient.RobotOTABatchAsync(cancellationToken:cancellationToken);
  1212. }*/
  1213. /// <summary>
  1214. /// 重置
  1215. /// </summary>
  1216. /// <returns></returns>
  1217. public virtual async Task<Response> Reset(CancellationToken cancellationToken = default)
  1218. {
  1219. return await RobotPrivateControllerClient.ResetAsync(new Empty(), cancellationToken: cancellationToken);
  1220. }
  1221. /// <summary>
  1222. /// 以给定角度置零
  1223. /// </summary>
  1224. /// <param name="zero"></param>
  1225. /// <param name="cancellationToken"></param>
  1226. /// <returns></returns>
  1227. public virtual async Task<Response> InitZero(Zero zero, CancellationToken cancellationToken = default)
  1228. {
  1229. return await RobotPrivateControllerClient.InitZeroAsync(zero, cancellationToken: cancellationToken);
  1230. }
  1231. /// <summary>
  1232. /// 以零位置零
  1233. /// </summary>
  1234. /// <returns></returns>
  1235. public virtual async Task<Response> SetZero(CancellationToken cancellationToken = default)
  1236. {
  1237. return await RobotPrivateControllerClient.SetZeroAsync(new Empty(), cancellationToken: cancellationToken);
  1238. }
  1239. /// <summary>
  1240. /// 获取机器人电压V
  1241. /// </summary>
  1242. /// <returns></returns>
  1243. public virtual async Task<CurrentVoltage> GetVoltage(CancellationToken cancellationToken = default)
  1244. {
  1245. return await RobotPrivateControllerClient.GetVoltageAsync(new Empty(), cancellationToken: cancellationToken);
  1246. }
  1247. /// <summary>
  1248. /// 设置单关节伺服参数
  1249. /// </summary>
  1250. /// <param name="jointServoParam"></param>
  1251. /// <param name="cancellationToken"></param>
  1252. /// <returns></returns>
  1253. public virtual async Task<JointServoParams> SetServoParam(JointServoParam jointServoParam,
  1254. CancellationToken cancellationToken = default)
  1255. {
  1256. return await RobotPrivateControllerClient.SetServoParamAsync(jointServoParam,
  1257. cancellationToken: cancellationToken);
  1258. }
  1259. /// <summary>
  1260. /// 获取当前所有关节伺服参数
  1261. /// </summary>
  1262. /// <returns></returns>
  1263. public virtual async Task<JointServoParams> GetServoParams(CancellationToken cancellationToken = default)
  1264. {
  1265. return await RobotPrivateControllerClient.GetServoParamsAsync(new Empty(),
  1266. cancellationToken: cancellationToken);
  1267. }
  1268. /// <summary>
  1269. /// 调试设置
  1270. /// </summary>
  1271. /// <param name="debugParams"></param>
  1272. /// <param name="cancellationToken"></param>
  1273. /// <returns></returns>
  1274. public virtual async Task<DebugParams> SetDebugParams(DebugParams debugParams,
  1275. CancellationToken cancellationToken = default)
  1276. {
  1277. return await RobotPrivateControllerClient.SetDebugParamsAsync(debugParams,
  1278. cancellationToken: cancellationToken);
  1279. }
  1280. /// <summary>
  1281. /// 更改DH参数(三轴平行6参数)
  1282. /// </summary>
  1283. /// <param name="fixDhRequest"></param>
  1284. /// <param name="cancellationToken"></param>
  1285. /// <returns></returns>
  1286. public virtual async Task<FixDHResult> FixDHParams(FixDHRequest fixDhRequest,
  1287. CancellationToken cancellationToken = default)
  1288. {
  1289. return await RobotPrivateControllerClient.FixDHParamsAsync(fixDhRequest, cancellationToken: cancellationToken);
  1290. }
  1291. /// <summary>
  1292. /// 设置LED样式
  1293. /// </summary>
  1294. /// <param name="ledStyle"></param>
  1295. /// <param name="cancellationToken"></param>
  1296. /// <returns></returns>
  1297. public virtual async Task<LEDStyles> SetLEDStyle(LEDStyle ledStyle,
  1298. CancellationToken cancellationToken = default)
  1299. {
  1300. return await RobotPrivateControllerClient.SetLEDStyleAsync(ledStyle, cancellationToken: cancellationToken);
  1301. }
  1302. /// <summary>
  1303. /// 获取LED样式
  1304. /// </summary>
  1305. /// <returns></returns>
  1306. public virtual async Task<LEDStyles> GetLEDStyles(CancellationToken cancellationToken = default)
  1307. {
  1308. return await RobotPrivateControllerClient.GetLEDStylesAsync(new Empty(), cancellationToken: cancellationToken);
  1309. }
  1310. /*// 注册命令状态事件
  1311. public virtual async stream LuaEvent RegisterLuaEvent(){
  1312. await RobotPrivateControllerClient.RegisterLuaEventAsync(new Empty,cancellationToken:cancellationToken);
  1313. }*/
  1314. /// <summary>
  1315. /// 当推送 ALERT/CONFIRM/INPUT/SELECT,用户在前端确定后调用该接口
  1316. /// </summary>
  1317. /// <param name="confirmInput"></param>
  1318. /// <param name="cancellationToken"></param>
  1319. /// <returns></returns>
  1320. public virtual async Task<Response> ConfirmCallback(ConfirmInput confirmInput,
  1321. CancellationToken cancellationToken = default)
  1322. {
  1323. return await RobotPrivateControllerClient.ConfirmCallbackAsync(confirmInput,
  1324. cancellationToken: cancellationToken);
  1325. }
  1326. /// <summary>
  1327. /// 获取 Lua 上次执行到的机器人位置
  1328. /// </summary>
  1329. /// <returns></returns>
  1330. public virtual async Task<PoseRes> GetLastPose(CancellationToken cancellationToken = default)
  1331. {
  1332. return await RobotPrivateControllerClient.GetLastPoseAsync(new Empty(), cancellationToken: cancellationToken);
  1333. }
  1334. /// <summary>
  1335. /// 配置Modbus外部IO设备
  1336. /// </summary>
  1337. /// <param name="modbusExternalIOs"></param>
  1338. /// <param name="cancellationToken"></param>
  1339. /// <returns></returns>
  1340. public virtual async Task<Response> SetModbusExternalIO(ModbusExternalIOs modbusExternalIOs,
  1341. CancellationToken cancellationToken = default)
  1342. {
  1343. return await RobotPrivateControllerClient.SetModbusExternalIOAsync(modbusExternalIOs,
  1344. cancellationToken: cancellationToken);
  1345. }
  1346. /// <summary>
  1347. /// 修改按钮配置
  1348. /// </summary>
  1349. /// <param name="buttonConfig"></param>
  1350. /// <param name="cancellationToken"></param>
  1351. /// <returns></returns>
  1352. public virtual async Task<Response> SetButtonConfig(ButtonConfig buttonConfig,
  1353. CancellationToken cancellationToken = default)
  1354. {
  1355. return await RobotPrivateControllerClient.SetButtonConfigAsync(buttonConfig,
  1356. cancellationToken: cancellationToken);
  1357. }
  1358. /// <summary>
  1359. /// 设置绑定设备开关, true: 不限制设备绑定; false:限制设备绑定逻辑
  1360. /// </summary>
  1361. /// <param name="trueOrFalse"></param>
  1362. /// <param name="cancellationToken"></param>
  1363. /// <returns></returns>
  1364. public virtual async Task<Response> SetBreakACup(TrueOrFalse trueOrFalse,
  1365. CancellationToken cancellationToken = default)
  1366. {
  1367. return await RobotPrivateControllerClient.SetBreakACupAsync(trueOrFalse, cancellationToken: cancellationToken);
  1368. }
  1369. /*// PVAT数据记录接口,用户记录pvat数据
  1370. public virtual async stream RecordPVATResponse RecordPVAT(RecordPVATRequest){
  1371. await RobotPrivateControllerClient.RecordPVATAsync(cancellationToken:cancellationToken);
  1372. }*/
  1373. /// <summary>
  1374. /// 停止记录pvat数据
  1375. /// </summary>
  1376. /// <returns></returns>
  1377. public virtual async Task<Response> StopRecordPVAT(CancellationToken cancellationToken = default)
  1378. {
  1379. return await RobotPrivateControllerClient.StopRecordPVATAsync(new Empty(),
  1380. cancellationToken: cancellationToken);
  1381. }
  1382. /*// 语音升级
  1383. public virtual async stream VoiceResult,cancellationToken:cancellationToken);//yvoi UpgradeVoiceFile(VoiceFile){
  1384. await RobotPrivateControllerClient.UpgradeVoiceFileAsync(cancellationToken:cancellationToken);
  1385. }*/
  1386. /// <summary>
  1387. /// 获取当前 DH 参数
  1388. /// </summary>
  1389. /// <param name="dhRequest"></param>
  1390. /// <param name="cancellationToken"></param>
  1391. /// <returns></returns>
  1392. public virtual async Task<DHParams> GetDHParams(DHRequest dhRequest,
  1393. CancellationToken cancellationToken = default)
  1394. {
  1395. return await RobotPrivateControllerClient.GetDHParamsAsync(dhRequest, cancellationToken: cancellationToken);
  1396. }
  1397. /// <summary>
  1398. /// 设置 DH 参数并返回设置后的结果
  1399. /// </summary>
  1400. /// <param name="dhParams"></param>
  1401. /// <param name="cancellationToken"></param>
  1402. /// <returns></returns>
  1403. public virtual async Task<DHParams> SetDHParams(DHParams dhParams,
  1404. CancellationToken cancellationToken = default)
  1405. {
  1406. return await RobotPrivateControllerClient.SetDHParamsAsync(dhParams, cancellationToken: cancellationToken);
  1407. }
  1408. /// <summary>
  1409. /// 写伺服控制参数
  1410. /// </summary>
  1411. /// <param name="param"></param>
  1412. /// <param name="cancellationToken"></param>
  1413. /// <returns></returns>
  1414. public virtual async Task<ExtraServoParam> WriteExtraServoParam(ExtraServoParam param,
  1415. CancellationToken cancellationToken = default)
  1416. {
  1417. return await RobotPrivateControllerClient.WriteExtraServoParamAsync(param,
  1418. cancellationToken: cancellationToken);
  1419. }
  1420. /// <summary>
  1421. /// 读取伺服控制参数
  1422. /// </summary>
  1423. /// <param name="param"></param>
  1424. /// <param name="cancellationToken"></param>
  1425. /// <returns></returns>
  1426. public virtual async Task<ExtraServoParam> ReadExtraServoParam(ExtraServoParam param,
  1427. CancellationToken cancellationToken = default)
  1428. {
  1429. return await RobotPrivateControllerClient.ReadExtraServoParamAsync(param,
  1430. cancellationToken: cancellationToken);
  1431. }
  1432. /// <summary>
  1433. /// 写多个伺服控制参数
  1434. /// </summary>
  1435. /// <param name="param"></param>
  1436. /// <param name="cancellationToken"></param>
  1437. /// <returns></returns>
  1438. public virtual async Task<ExtraServoParams> WriteExtraServoParams(ExtraServoParam param,
  1439. CancellationToken cancellationToken = default)
  1440. {
  1441. return await RobotPrivateControllerClient.WriteExtraServoParamsAsync(param,
  1442. cancellationToken: cancellationToken);
  1443. }
  1444. /// <summary>
  1445. /// 读取多个伺服控制参数
  1446. /// </summary>
  1447. /// <returns></returns>
  1448. public virtual async Task<ExtraServoParams> ReadExtraServoParams(
  1449. CancellationToken cancellationToken = default)
  1450. {
  1451. return await RobotPrivateControllerClient.ReadExtraServoParamsAsync(new Empty(),
  1452. cancellationToken: cancellationToken);
  1453. }
  1454. /// <summary>
  1455. /// 重置伺服控制参数
  1456. /// </summary>
  1457. /// <returns></returns>
  1458. public virtual async Task<ExtraServoParams> ResetExtraServoParams(
  1459. CancellationToken cancellationToken = default)
  1460. {
  1461. return await RobotPrivateControllerClient.ResetExtraServoParamsAsync(new Empty(),
  1462. cancellationToken: cancellationToken);
  1463. }
  1464. /// <summary>
  1465. /// 写“主动消回差”参数
  1466. /// </summary>
  1467. /// <param name="param"></param>
  1468. /// <param name="cancellationToken"></param>
  1469. /// <returns></returns>
  1470. public virtual async Task<JointBacklash> WriteJointBacklash(JointBacklash param,
  1471. CancellationToken cancellationToken = default)
  1472. {
  1473. return await RobotPrivateControllerClient.WriteJointBacklashAsync(param, cancellationToken: cancellationToken);
  1474. }
  1475. /// <summary>
  1476. /// 读取“主动消回差”参数
  1477. /// </summary>
  1478. /// <param name="param"></param>
  1479. /// <param name="cancellationToken"></param>
  1480. /// <returns></returns>
  1481. public virtual async Task<JointBacklash> ReadJointBacklash(JointBacklash param,
  1482. CancellationToken cancellationToken = default)
  1483. {
  1484. return await RobotPrivateControllerClient.ReadJointBacklashAsync(param, cancellationToken: cancellationToken);
  1485. }
  1486. /// <summary>
  1487. /// 写“主动消回差”参数
  1488. /// </summary>
  1489. /// <param name="param"></param>
  1490. /// <param name="cancellationToken"></param>
  1491. /// <returns></returns>
  1492. public virtual async Task<JointBacklashes> WriteJointBacklashes(JointBacklash param,
  1493. CancellationToken cancellationToken = default)
  1494. {
  1495. return await RobotPrivateControllerClient.WriteJointBacklashesAsync(param,
  1496. cancellationToken: cancellationToken);
  1497. }
  1498. /// <summary>
  1499. /// 读取多个“主动消回差”参数
  1500. /// </summary>
  1501. /// <returns></returns>
  1502. public virtual async Task<JointBacklashes> ReadJointBacklashes(CancellationToken cancellationToken = default)
  1503. {
  1504. return await RobotPrivateControllerClient.ReadJointBacklashesAsync(new Empty(),
  1505. cancellationToken: cancellationToken);
  1506. }
  1507. /// <summary>
  1508. /// 重置“主动消回差”参数
  1509. /// </summary>
  1510. /// <returns></returns>
  1511. public virtual async Task<JointBacklashes> ResetJointBacklashes(CancellationToken cancellationToken = default)
  1512. {
  1513. return await RobotPrivateControllerClient.ResetJointBacklashesAsync(new Empty(),
  1514. cancellationToken: cancellationToken);
  1515. }
  1516. /// <summary>
  1517. /// 启用主动消回差
  1518. /// </summary>
  1519. /// <param name="param"></param>
  1520. /// <param name="cancellationToken"></param>
  1521. /// <returns></returns>
  1522. public virtual async Task<EnableJointBacklashes> WriteEnableJointBacklashes(EnableJointBacklash param,
  1523. CancellationToken cancellationToken = default)
  1524. {
  1525. return await RobotPrivateControllerClient.WriteEnableJointBacklashesAsync(param,
  1526. cancellationToken: cancellationToken);
  1527. }
  1528. /// <summary>
  1529. /// 是否启用主动消回差
  1530. /// </summary>
  1531. /// <returns></returns>
  1532. public virtual async Task<EnableJointBacklashes> ReadEnableJointBacklashes(
  1533. CancellationToken cancellationToken = default)
  1534. {
  1535. return await RobotPrivateControllerClient.ReadEnableJointBacklashesAsync(new Empty(),
  1536. cancellationToken: cancellationToken);
  1537. }
  1538. /// <summary>
  1539. /// 重置主动消回差
  1540. /// </summary>
  1541. /// <returns></returns>
  1542. public virtual async Task<EnableJointBacklashes> ResetEnableJointBacklashes(
  1543. CancellationToken cancellationToken = default)
  1544. {
  1545. return await RobotPrivateControllerClient.ResetEnableJointBacklashesAsync(new Empty(),
  1546. cancellationToken: cancellationToken);
  1547. }
  1548. /// <summary>
  1549. /// 写关节回差参数
  1550. /// </summary>
  1551. /// <param name="param"></param>
  1552. /// <param name="cancellationToken"></param>
  1553. /// <returns></returns>
  1554. public virtual async Task<JointBacklashParam> WriteJointBacklashParam(JointBacklashParam param,
  1555. CancellationToken cancellationToken = default)
  1556. {
  1557. return await RobotPrivateControllerClient.WriteJointBacklashParamAsync(param,
  1558. cancellationToken: cancellationToken);
  1559. }
  1560. /// <summary>
  1561. /// 读取关节回差参数
  1562. /// </summary>
  1563. /// <param name="param"></param>
  1564. /// <param name="cancellationToken"></param>
  1565. /// <returns></returns>
  1566. public virtual async Task<JointBacklashParam> ReadJointBacklashParam(JointBacklashParam param,
  1567. CancellationToken cancellationToken = default)
  1568. {
  1569. return await RobotPrivateControllerClient.ReadJointBacklashParamAsync(param,
  1570. cancellationToken: cancellationToken);
  1571. }
  1572. /// <summary>
  1573. /// 写多个关节回差参数
  1574. /// </summary>
  1575. /// <param name="param"></param>
  1576. /// <param name="cancellationToken"></param>
  1577. /// <returns></returns>
  1578. public virtual async Task<JointBacklashParams> WriteJointBacklashParams(JointBacklashParam param,
  1579. CancellationToken cancellationToken = default)
  1580. {
  1581. return await RobotPrivateControllerClient.WriteJointBacklashParamsAsync(param,
  1582. cancellationToken: cancellationToken);
  1583. }
  1584. /// <summary>
  1585. /// 读多个关节回差参数
  1586. /// </summary>
  1587. /// <returns></returns>
  1588. public virtual async Task<JointBacklashParams> ReadJointBacklashParams(
  1589. CancellationToken cancellationToken = default)
  1590. {
  1591. return await RobotPrivateControllerClient.ReadJointBacklashParamsAsync(new Empty(),
  1592. cancellationToken: cancellationToken);
  1593. }
  1594. /// <summary>
  1595. /// 重置关节回差参数
  1596. /// </summary>
  1597. /// <returns></returns>
  1598. public virtual async Task<JointBacklashParams> ResetJointBacklashParams(
  1599. CancellationToken cancellationToken = default)
  1600. {
  1601. return await RobotPrivateControllerClient.ResetJointBacklashParamsAsync(new Empty(),
  1602. cancellationToken: cancellationToken);
  1603. }
  1604. /// <summary>
  1605. /// 启用关节限位检测
  1606. /// </summary>
  1607. /// <param name="param"></param>
  1608. /// <param name="cancellationToken"></param>
  1609. /// <returns></returns>
  1610. public virtual async Task<Response> EnableJointLimit(TrueOrFalse param,
  1611. CancellationToken cancellationToken = default)
  1612. {
  1613. return await RobotPrivateControllerClient.EnableJointLimitAsync(param, cancellationToken: cancellationToken);
  1614. }
  1615. /// <summary>
  1616. /// 切换模拟环境
  1617. /// </summary>
  1618. /// <param name="param"></param>
  1619. /// <param name="cancellationToken"></param>
  1620. /// <returns></returns>
  1621. public virtual async Task<Response> SwitchSimulate(TrueOrFalse param,
  1622. CancellationToken cancellationToken = default)
  1623. {
  1624. return await RobotPrivateControllerClient.SwitchSimulateAsync(param, cancellationToken: cancellationToken);
  1625. }
  1626. #if NET5_0||NET6_0
  1627. /// <summary>
  1628. /// 获取机器人概要数据流
  1629. /// </summary>
  1630. /// <returns></returns>
  1631. public IAsyncEnumerable<RobotBriefData> GetRobotBriefDataStream(CancellationToken cancellationToken = default)
  1632. {
  1633. return RobotControllerClient.GetRobotBriefData().ResponseStream
  1634. .ReadAllAsync(cancellationToken);
  1635. }
  1636. /// <summary>
  1637. /// 获取机器人的IO数据流
  1638. /// </summary>
  1639. /// <returns></returns>
  1640. public virtual IAsyncEnumerable<IO> GetRobotIODataStream(CancellationToken cancellationToken = default)
  1641. {
  1642. return RobotControllerClient.GetRobotIOData().ResponseStream
  1643. .ReadAllAsync(cancellationToken);
  1644. }
  1645. /// <summary>
  1646. /// 获取机器人的IO数据流
  1647. /// </summary>
  1648. /// <returns></returns>
  1649. public virtual AsyncDuplexStreamingCall<RobotDataCmd, IO> GetRobotIOData(
  1650. CancellationToken cancellationToken = default)
  1651. {
  1652. return RobotControllerClient.GetRobotIOData(cancellationToken: cancellationToken);
  1653. }
  1654. #endif
  1655. /*// 连接/断开 MODBUS 设备
  1656. public virtual async Task<Response> ConnectExternalIO(ExternalIOState param){
  1657. return await RobotPrivateControllerClient.ConnectExternalIOAsync(param,cancellationToken:cancellationToken);
  1658. }*/
  1659. }
  1660. }