|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844 |
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using System.Threading;
- using System.Threading.Tasks;
- using Grpc.Core;
- using Grpc.Net.Client;
- using Robotc;
- using Empty = Google.Protobuf.WellKnownTypes.Empty;
-
- namespace Lebai.SDK
- {
- public partial class LebaiRobotClient
- {
- public static readonly Dictionary<string, LebaiRobotClient> LebaiRobotClients = new();
-
- private readonly HttpClient _httpClient;
-
- private RobotController.RobotControllerClient _robotControllerClient;
- private RobotPrivateController.RobotPrivateControllerClient _robotPrivateControllerClient;
-
- public LebaiRobotClient(string ip, int robotControllerClientPort = 5181, int robotPrivateControllerPort = 5182,
- GrpcChannelOptions grpcChannelOptions = null)
- {
- IP = ip;
- RobotControllerClientPort = robotControllerClientPort;
- RobotPrivateControllerPort = robotPrivateControllerPort;
- GrpcChannelOptions = grpcChannelOptions;
- _httpClient = new HttpClient {BaseAddress = new Uri($"http://{ip}")};
- }
-
- private string IP { get; }
- private int RobotControllerClientPort { get; }
- private int RobotPrivateControllerPort { get; }
- private GrpcChannelOptions GrpcChannelOptions { get; }
-
- public Action<RpcException> OnRpcException { get; set; }
-
- private RobotController.RobotControllerClient RobotControllerClient =>
- LazyInitializer.EnsureInitialized(ref _robotControllerClient,
- () =>
- {
- var r = new RobotController.RobotControllerClient(
- GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotControllerClientPort}"),
- GrpcChannelOptions ??
- new GrpcChannelOptions
- {
- MaxRetryAttempts = 5
- })
- );
- return r;
- });
-
- private RobotPrivateController.RobotPrivateControllerClient RobotPrivateControllerClient =>
- LazyInitializer.EnsureInitialized(ref _robotPrivateControllerClient,
- () => new RobotPrivateController.RobotPrivateControllerClient(
- GrpcChannel.ForAddress(new Uri($"http://{IP}:{RobotPrivateControllerPort}"), GrpcChannelOptions ??
- new GrpcChannelOptions
- {
- MaxRetryAttempts = 5
- })));
-
- public static LebaiRobotClient Get(string ip, int robotControllerClientPort = 5181,
- int robotPrivateControllerPort = 5182)
- {
- if (LebaiRobotClients.ContainsKey(ip)) return LebaiRobotClients[ip];
-
- LebaiRobotClients[ip] = new LebaiRobotClient(ip);
- return LebaiRobotClients[ip];
- }
-
- /// <summary>
- /// 启用/禁用 设备
- /// </summary>
- /// <param name="externalIoState"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task ConnectExternalIO(ExternalIOState externalIoState,
- CancellationToken cancellationToken = default)
- {
- await RobotPrivateControllerClient.ConnectExternalIOAsync(externalIoState,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 关闭电源
- /// </summary>
- public virtual async Task PowerDown(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.PowerDownAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 等待,单位毫秒
- /// </summary>
- /// <param name="sleepRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task Sleep(SleepRequest sleepRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SleepAsync(sleepRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 同步,等待命令执行完成
- /// </summary>
- public virtual async Task Sync(CancellationToken cancellationToken = default)
- {
- try
- {
- await RobotControllerClient.SyncAsync(new Empty(), cancellationToken: cancellationToken);
- }
- catch (RpcException e)
- {
- OnRpcException?.Invoke(e);
- }
- }
-
- public virtual async Task SyncFor(SyncRequest syncRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SyncForAsync(syncRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 开启示教模式
- /// </summary>
- public virtual async Task TeachMode(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.TeachModeAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 关闭示教模式
- /// </summary>
- public virtual async Task EndTeachMode(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.EndTeachModeAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置速度因子(0-100)
- /// </summary>
- /// <param name="factor"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetVelocityFactor(Factor factor, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetVelocityFactorAsync(factor, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取速度因子(0-100)
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Factor> GetVelocityFactor(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetVelocityFactorAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置重力方向
- /// </summary>
- /// <param name="coordinate"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetGravity(Coordinate coordinate, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetGravityAsync(coordinate, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取重力方向
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Coordinate> GetGravity(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetGravityAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置负载
- /// </summary>
- /// <param name="payload"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetPayload(Payload payload, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetPayloadAsync(payload, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取负载
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Payload> GetPayload(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetPayloadAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置负责质量
- /// </summary>
- /// <param name="payloadMass"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetPayloadMass(PayloadMass payloadMass,
- CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetPayloadMassAsync(payloadMass, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取负责质量
- /// </summary>
- /// <returns></returns>
- public virtual async Task<PayloadMass> GetPayloadMass(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetPayloadMassAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置负载质心
- /// </summary>
- /// <param name="payloadCog"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetPayloadCog(PayloadCog payloadCog, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetPayloadCogAsync(payloadCog, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取负责质心
- /// </summary>
- /// <returns></returns>
- public virtual async Task<PayloadCog> GetPayloadCog(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetPayloadCogAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置TCP
- /// </summary>
- /// <param name="pR"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetTcp(PR pR, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetTcpAsync(pR, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取TCP
- /// </summary>
- /// <returns></returns>
- public virtual async Task<PR> GetTcp(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTcpAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置手爪幅度:0-100 double
- /// </summary>
- /// <param name="amplitude"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetClawAmplitude(Amplitude amplitude,
- CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetClawAmplitudeAsync(amplitude, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得手爪幅度:0-100 double
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Amplitude> GetClawAmplitude(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetClawAmplitudeAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得手爪目前是否夹紧物体状态1表示夹紧,0为松开
- /// </summary>
- /// <returns></returns>
- public virtual async Task<HoldOn> GetClawHoldOn(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetClawHoldOnAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置手爪力度:0-100 double
- /// </summary>
- /// <param name="force"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetClawForce(Force force, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetClawForceAsync(force, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得手爪称重结果
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Weight> GetClawWeight(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetClawWeightAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <returns></returns>
- public virtual async Task<ForceTorque> GetTcpForce(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTcpForceAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置手爪
- /// </summary>
- /// <param name="clawInfo"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ClawInfo> SetClaw(ClawInfo clawInfo, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetClawAsync(clawInfo, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取手爪
- /// </summary>
- /// <returns></returns>
- public virtual async Task<ClawInfo> GetClaw(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetClawAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置位置
- /// </summary>
- /// <param name="jPose"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetPos(JPose jPose, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetPosAsync(jPose, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="speedJRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SpeedJ(SpeedJRequest speedJRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SpeedJAsync(speedJRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="speedLRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SpeedL(SpeedLRequest speedLRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SpeedLAsync(speedLRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="stopJRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task StopJ(StopJRequest stopJRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopJAsync(stopJRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="stopLRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task StopL(StopLRequest stopLRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopLAsync(stopLRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 停止当前移动
- /// </summary>
- public virtual async Task StopMove(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopMoveAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 圆弧移动
- /// </summary>
- /// <param name="moveCRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MoveC(MoveCRequest moveCRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MoveCAsync(moveCRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 关节空间线性移动
- /// </summary>
- /// <param name="moveJRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MoveJ(MoveJRequest moveJRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MoveJAsync(moveJRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 笛卡尔空间线性移动
- /// </summary>
- /// <param name="moveLRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MoveL(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MoveLAsync(moveLRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// DEPRECIATED
- /// </summary>
- /// <param name="moveLRequest"></param>
- /// <param name="cancellationToken"></param>
- [Obsolete]
- public virtual async Task MoveLJ(MoveLRequest moveLRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MoveLJAsync(moveLRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="movePRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MoveP(MovePRequest movePRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MovePAsync(movePRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// pt move
- /// </summary>
- /// <param name="pVATRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MovePT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MovePTAsync(pVATRequest, cancellationToken: cancellationToken);
- }
-
- /*public void MovePTStream(PVATRequest request,CancellationToken cancellationToken=default)
- {
-
- }*/
-
- /// <summary>
- /// pvt move
- /// </summary>
- /// <param name="pVATRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MovePVT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MovePVTAsync(pVATRequest, cancellationToken: cancellationToken);
- }
-
- /*public void MovePVTStream(PVATRequest request,CancellationToken cancellationToken=default)
- {
- RobotControllerClient.MovePVTStreamAsync(PVATRequest,cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// pvat move
- /// </summary>
- /// <param name="pVATRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MovePVAT(PVATRequest pVATRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MovePVATAsync(pVATRequest, cancellationToken: cancellationToken);
- }
-
- /*public void MovePVATStream(stream stream PVATRequest,CancellationToken cancellationToken=default)
- {
- RobotControllerClient.MovePVATStreamAsync(PVATRequest,cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="servoCRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task ServoC(ServoCRequest servoCRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.ServoCAsync(servoCRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <param name="servoJRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task ServoJ(ServoJRequest servoJRequest, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.ServoJAsync(servoJRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人所有状态数据
- /// </summary>
- /// <returns></returns>
- public virtual async Task<RobotData> GetRobotData(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetRobotDataAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人状态
- /// </summary>
- /// <returns></returns>
- public virtual async Task<RobotMode> GetRobotMode(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetRobotModeAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得实际关节位置
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Joint> GetActualJointPositions(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetActualJointPositionsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得目标关节位置
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Joint> GetTargetJointPositions(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTargetJointPositionsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得实际关节速度
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Joint> GetActualJointSpeeds(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetActualJointSpeedsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得目标关节速度
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Joint> GetTargetJointSpeeds(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTargetJointSpeedsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得末端在笛卡尔坐标系下的位姿
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Vector> GetActualTcpPose(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetActualTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得末端在笛卡尔坐标系下的目标位姿
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Vector> GetTargetTcpPose(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTargetTcpPoseAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Vector> GetActualTcpSpeed(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetActualTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Vector> GetTargetTcpSpeed(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTargetTcpSpeedAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Vector> GetActualFlangePose(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetActualFlangePoseAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取关节扭矩
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Joint> GetJointTorques(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetJointTorquesAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取控制器温度
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Temperature> GetControllerTemp(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetControllerTempAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取关节内部温度
- /// </summary>
- /// <param name="intRequest"></param>
- /// <returns></returns>
- public virtual async Task<Temperature> GetJointTemp(IntRequest intRequest,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetJointTempAsync(intRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// implement later
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Current> GetToolCurrent(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetToolCurrentAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置数字输出端口的值
- /// </summary>
- /// <param name="dIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetDIO(DIO dIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetDIOAsync(dIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置扩展数字输出端口的值
- /// </summary>
- /// <param name="dIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetExtraDIO(DIO dIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetExtraDIOAsync(dIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得数字输入端口的值
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DIO> GetDIO(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetDIOAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得扩展数字数如端口的值
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DIO> GetExtraDIO(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExtraDIOAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置TCP数字输出端口的值
- /// </summary>
- /// <param name="dIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetTcpDIO(DIO dIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetTcpDIOAsync(dIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得TCP数字输入端口的值
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DIO> GetTcpDIO(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetTcpDIOAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置模拟输出端口的值
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetAIO(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetAIOAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得模拟输入端口的值
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetExtraAIO(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetExtraAIOAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得模拟输入端口的值
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetAIO(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetAIOAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得扩展模拟输入端口的值
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetExtraAIO(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExtraAIOAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置模拟输入端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetAInMode(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetAInModeAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置扩展模拟输入端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetExtraAInMode(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetExtraAInModeAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得模拟输入端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetAInModeAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得扩展模拟输入端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetExtraAInMode(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExtraAInModeAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置模拟输出端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetAOutMode(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetAOutModeAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置扩展模拟输出端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="aIO"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetExtraAOutMode(AIO aIO, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetExtraAOutModeAsync(aIO, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得模拟输出端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetAOutModeAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得扩展模拟输出端口工作模式:0:电压,1:电流
- /// </summary>
- /// <param name="iOPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<AIO> GetExtraAOutMode(IOPin iOPin, CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExtraAOutModeAsync(iOPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 开启/启动系统
- /// </summary>
- public virtual async Task StartSys(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StartSysAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 关闭/停止系统
- /// </summary>
- public virtual async Task StopSys(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopSysAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 程序停止
- /// </summary>
- public virtual async Task Stop(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 急停
- /// </summary>
- public virtual async Task EStop(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.EStopAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取kdl参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<KDParam> GetKDL(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetKDLAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 查询系统里面的日志信息
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Logs> GetLogs(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetLogsAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获得当前正在执行的命令id,如果没有在执行的命令,则返回-1
- /// </summary>
- public virtual async Task GetCurrentCmd(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.GetCurrentCmdAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /*
- // 获得指定命令id的执行结果:-1: 未执行;0: 已执行
- public CmdStatus GetCmdExecStatus(void cmdId,CancellationToken cancellationToken=default)
- {
- return await nt.GetCmdExecStatus(cmdId,cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 开始微调: 如果当前有其他微调再传入新的微调命令会终止当前的微调进行新的微调
- /// </summary>
- /// <param name="fineTuning"></param>
- public virtual async Task StartFineTuning(FineTuning fineTuning,
- CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StartFineTuningAsync(fineTuning, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 停止微调
- /// </summary>
- public virtual async Task StopFineTuning(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.StopFineTuningAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 暂停机器人
- /// </summary>
- public virtual async Task Pause(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.PauseAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 恢复机器人
- /// </summary>
- public virtual async Task Resume(CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.ResumeAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 机器人正解
- /// </summary>
- /// <param name="joint"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Vector> KinematicsForward(Joint joint,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.KinematicsForwardAsync(joint, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 机器人反解
- /// </summary>
- /// <param name="vector"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Joint> KinematicsInverse(Vector vector,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.KinematicsInverseAsync(vector, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// TCP示教添加
- /// </summary>
- /// <param name="calcTcpParam"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Vector> CalcTcpTranslation(CalcTcpParam calcTcpParam,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.CalcTcpTranslationAsync(calcTcpParam, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 测试命令,以给定的RPY数据执行线性移动
- /// </summary>
- /// <param name="moveLRPYRequest"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task MoveLRPY(MoveLRPYRequest moveLRPYRequest,
- CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.MoveLRPYAsync(moveLRPYRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置LED灯状态
- /// </summary>
- /// <param name="lEDStatus"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetLED(LEDStatus lEDStatus, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetLEDAsync(lEDStatus, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置声音
- /// </summary>
- /// <param name="voiceStatus"></param>
- public virtual async Task SetVoice(VoiceStatus voiceStatus, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetVoiceAsync(voiceStatus, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置风扇
- /// </summary>
- /// <param name="fanStatus"></param>
- /// <param name="cancellationToken"></param>
- public virtual async Task SetFan(FanStatus fanStatus, CancellationToken cancellationToken = default)
- {
- await RobotControllerClient.SetFanAsync(fanStatus, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取灯板状态
- /// </summary>
- /// <returns></returns>
- public virtual async Task<LampStatus> GetLampStatus(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetLampStatusAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// Lua 状态查询
- /// </summary>
- /// <returns></returns>
- public virtual async Task<LuaStatus> GetLuaState(CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetLuaStateAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置外置数字输出
- /// </summary>
- /// <param name="externalDigital"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetExternalDO(ExternalDigital externalDigital,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetExternalDOAsync(externalDigital, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置数字输出
- /// </summary>
- /// <param name="externalPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalDigital> GetExternalDO(ExternalPin externalPin,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalDOAsync(externalPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置数字输入
- /// </summary>
- /// <param name="externalPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalDigital> GetExternalDI(ExternalPin externalPin,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalDIAsync(externalPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置外置模拟输出
- /// </summary>
- /// <param name="externalAnalog"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetExternalAO(ExternalAnalog externalAnalog,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetExternalAOAsync(externalAnalog, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置模拟输出
- /// </summary>
- /// <param name="externalPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalAnalog> GetExternalAO(ExternalPin externalPin,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalAOAsync(externalPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置模拟输入
- /// </summary>
- /// <param name="externalPin"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalAnalog> GetExternalAI(ExternalPin externalPin,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalAIAsync(externalPin, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取某个外置io的全部io信息
- /// </summary>
- /// <param name="externalDevice"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalIOs> GetExternalIOs(ExternalDevice externalDevice,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalIOsAsync(externalDevice, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置某个外置io的全部io信息
- /// </summary>
- /// <param name="externalDigitals"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetExternalDOs(ExternalDigitals externalDigitals,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetExternalDOsAsync(externalDigitals, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置数字输出
- /// </summary>
- /// <param name="externalPins"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalDigitals> GetExternalDOs(ExternalPins externalPins,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalDOsAsync(externalPins, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置数字输入
- /// </summary>
- /// <param name="externalPins"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalDigitals> GetExternalDIs(ExternalPins externalPins,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalDIsAsync(externalPins, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置外置模拟输出
- /// </summary>
- /// <param name="externalAnalogs"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetExternalAOs(ExternalAnalogs externalAnalogs,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetExternalAOsAsync(externalAnalogs, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置模拟输出
- /// </summary>
- /// <param name="externalPins"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalAnalogs> GetExternalAOs(ExternalPins externalPins,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalAOsAsync(externalPins, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取外置模拟输入
- /// </summary>
- /// <param name="externalPins"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExternalAnalogs> GetExternalAIs(ExternalPins externalPins,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetExternalAIsAsync(externalPins, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置信号量
- /// </summary>
- /// <param name="signalValue"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<SignalResult> SetSignal(SignalValue signalValue,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.SetSignalAsync(signalValue, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取信号量
- /// </summary>
- /// <param name="signalValue"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<SignalResult> GetSignal(SignalValue signalValue,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.GetSignalAsync(signalValue, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 添加信号量
- /// </summary>
- /// <param name="signalValue"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<SignalResult> AddSignal(SignalValue signalValue,
- CancellationToken cancellationToken = default)
- {
- return await RobotControllerClient.AddSignalAsync(signalValue, cancellationToken: cancellationToken);
- }
- /*
-
- public stream RegisterSignals(stream stream SignalList,CancellationToken cancellationToken=default)
- {
- return await RobotControllerClient.RegisterSignals().RequestStream.WriteAsync(cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 初始化配置
- /// </summary>
- /// <param name="configuration"></param>
- /// <param name="cancellationToken"></param>
- public virtual async void Init(Configuration configuration, CancellationToken cancellationToken = default)
- {
- await RobotPrivateControllerClient.InitAsync(configuration, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人基础信息
- /// </summary>
- /// <returns></returns>
- public virtual async Task<RobotInfo> GetRobotInfo(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetRobotInfoAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置机器人安装方向
- /// </summary>
- /// <param name="installDirection"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetInstallDirection(InstallDirection installDirection,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetInstallDirectionAsync(installDirection,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置碰撞检测
- /// </summary>
- /// <param name="collisionDetector"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetCollisionDetector(CollisionDetector collisionDetector,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetCollisionDetectorAsync(collisionDetector,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置关节配置
- /// </summary>
- /// <param name="jointConfigs"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetJointConfig(JointConfigs jointConfigs,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetJointConfigAsync(jointConfigs,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置笛卡尔空间的配置
- /// </summary>
- /// <param name="cartesianConfig"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetCartesianConfig(CartesianConfig cartesianConfig,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetCartesianConfigAsync(cartesianConfig,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 开启DDS
- /// </summary>
- /// <param name="trueOrFalse"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> EnableDDS(TrueOrFalse trueOrFalse,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.EnableDDSAsync(trueOrFalse, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置碰撞检测力矩差阈值
- /// </summary>
- /// <param name="collisionTorqueDiff"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetCollisionTorqueDiff(CollisionTorqueDiff collisionTorqueDiff,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetCollisionTorqueDiffAsync(collisionTorqueDiff,
- cancellationToken: cancellationToken);
- }
-
- // 注册通知事件
- /*public virtual async stream Notification RegisterNotification(google.protobuf.Empty){
- await RobotPrivateControllerClient.RegisterNotification(new Empty(),cancellationToken:cancellationToken);
- }*/
- public virtual async Task<DriverInfo> RobotDriverInfo(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.RobotDriverInfoAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /*// 机器人OTA单个设备更新接口
- public virtual async stream OTAResult RobotOTA(OTAData){
- await RobotPrivateControllerClient.RobotOTAAsync(cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 通知灯板、法兰、关节切换分区
- /// </summary>
- /// <param name="otaCmd"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SwitchOtaPartition(OTACmd otaCmd,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SwitchOtaPartitionAsync(otaCmd,
- cancellationToken: cancellationToken);
- }
-
- /*// 机器人OTA批量更新接口
- public virtual async stream OTAResults RobotOTABatch(OTADatas){
- await RobotPrivateControllerClient.RobotOTABatchAsync(cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 重置
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Response> Reset(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ResetAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 以给定角度置零
- /// </summary>
- /// <param name="zero"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> InitZero(Zero zero, CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.InitZeroAsync(zero, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 以零位置零
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Response> SetZero(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetZeroAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人电压V
- /// </summary>
- /// <returns></returns>
- public virtual async Task<CurrentVoltage> GetVoltage(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetVoltageAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置单关节伺服参数
- /// </summary>
- /// <param name="jointServoParam"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointServoParams> SetServoParam(JointServoParam jointServoParam,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetServoParamAsync(jointServoParam,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取当前所有关节伺服参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<JointServoParams> GetServoParams(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetServoParamsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 调试设置
- /// </summary>
- /// <param name="debugParams"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DebugParams> SetDebugParams(DebugParams debugParams,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetDebugParamsAsync(debugParams,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 更改DH参数(三轴平行6参数)
- /// </summary>
- /// <param name="fixDhRequest"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<FixDHResult> FixDHParams(FixDHRequest fixDhRequest,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.FixDHParamsAsync(fixDhRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置LED样式
- /// </summary>
- /// <param name="ledStyle"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<LEDStyles> SetLEDStyle(LEDStyle ledStyle,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetLEDStyleAsync(ledStyle, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取LED样式
- /// </summary>
- /// <returns></returns>
- public virtual async Task<LEDStyles> GetLEDStyles(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetLEDStylesAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /*// 注册命令状态事件
- public virtual async stream LuaEvent RegisterLuaEvent(){
- await RobotPrivateControllerClient.RegisterLuaEventAsync(new Empty,cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 当推送 ALERT/CONFIRM/INPUT/SELECT,用户在前端确定后调用该接口
- /// </summary>
- /// <param name="confirmInput"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> ConfirmCallback(ConfirmInput confirmInput,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ConfirmCallbackAsync(confirmInput,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 获取 Lua 上次执行到的机器人位置
- /// </summary>
- /// <returns></returns>
- public virtual async Task<PoseRes> GetLastPose(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetLastPoseAsync(new Empty(), cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 配置Modbus外部IO设备
- /// </summary>
- /// <param name="modbusExternalIOs"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetModbusExternalIO(ModbusExternalIOs modbusExternalIOs,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetModbusExternalIOAsync(modbusExternalIOs,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 修改按钮配置
- /// </summary>
- /// <param name="buttonConfig"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetButtonConfig(ButtonConfig buttonConfig,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetButtonConfigAsync(buttonConfig,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置绑定设备开关, true: 不限制设备绑定; false:限制设备绑定逻辑
- /// </summary>
- /// <param name="trueOrFalse"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SetBreakACup(TrueOrFalse trueOrFalse,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetBreakACupAsync(trueOrFalse, cancellationToken: cancellationToken);
- }
-
- /*// PVAT数据记录接口,用户记录pvat数据
- public virtual async stream RecordPVATResponse RecordPVAT(RecordPVATRequest){
- await RobotPrivateControllerClient.RecordPVATAsync(cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 停止记录pvat数据
- /// </summary>
- /// <returns></returns>
- public virtual async Task<Response> StopRecordPVAT(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.StopRecordPVATAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /*// 语音升级
- public virtual async stream VoiceResult,cancellationToken:cancellationToken);//yvoi UpgradeVoiceFile(VoiceFile){
- await RobotPrivateControllerClient.UpgradeVoiceFileAsync(cancellationToken:cancellationToken);
- }*/
-
- /// <summary>
- /// 获取当前 DH 参数
- /// </summary>
- /// <param name="dhRequest"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DHParams> GetDHParams(DHRequest dhRequest,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.GetDHParamsAsync(dhRequest, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 设置 DH 参数并返回设置后的结果
- /// </summary>
- /// <param name="dhParams"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<DHParams> SetDHParams(DHParams dhParams,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SetDHParamsAsync(dhParams, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写伺服控制参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExtraServoParam> WriteExtraServoParam(ExtraServoParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteExtraServoParamAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读取伺服控制参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExtraServoParam> ReadExtraServoParam(ExtraServoParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadExtraServoParamAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写多个伺服控制参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<ExtraServoParams> WriteExtraServoParams(ExtraServoParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteExtraServoParamsAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读取多个伺服控制参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<ExtraServoParams> ReadExtraServoParams(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadExtraServoParamsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 重置伺服控制参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<ExtraServoParams> ResetExtraServoParams(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ResetExtraServoParamsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写“主动消回差”参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklash> WriteJointBacklash(JointBacklash param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteJointBacklashAsync(param, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读取“主动消回差”参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklash> ReadJointBacklash(JointBacklash param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadJointBacklashAsync(param, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写“主动消回差”参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklashes> WriteJointBacklashes(JointBacklash param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteJointBacklashesAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读取多个“主动消回差”参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<JointBacklashes> ReadJointBacklashes(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadJointBacklashesAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 重置“主动消回差”参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<JointBacklashes> ResetJointBacklashes(CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ResetJointBacklashesAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 启用主动消回差
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<EnableJointBacklashes> WriteEnableJointBacklashes(EnableJointBacklash param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteEnableJointBacklashesAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 是否启用主动消回差
- /// </summary>
- /// <returns></returns>
- public virtual async Task<EnableJointBacklashes> ReadEnableJointBacklashes(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadEnableJointBacklashesAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 重置主动消回差
- /// </summary>
- /// <returns></returns>
- public virtual async Task<EnableJointBacklashes> ResetEnableJointBacklashes(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ResetEnableJointBacklashesAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写关节回差参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklashParam> WriteJointBacklashParam(JointBacklashParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteJointBacklashParamAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读取关节回差参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklashParam> ReadJointBacklashParam(JointBacklashParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadJointBacklashParamAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 写多个关节回差参数
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<JointBacklashParams> WriteJointBacklashParams(JointBacklashParam param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.WriteJointBacklashParamsAsync(param,
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 读多个关节回差参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<JointBacklashParams> ReadJointBacklashParams(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ReadJointBacklashParamsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 重置关节回差参数
- /// </summary>
- /// <returns></returns>
- public virtual async Task<JointBacklashParams> ResetJointBacklashParams(
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.ResetJointBacklashParamsAsync(new Empty(),
- cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 启用关节限位检测
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> EnableJointLimit(TrueOrFalse param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.EnableJointLimitAsync(param, cancellationToken: cancellationToken);
- }
-
- /// <summary>
- /// 切换模拟环境
- /// </summary>
- /// <param name="param"></param>
- /// <param name="cancellationToken"></param>
- /// <returns></returns>
- public virtual async Task<Response> SwitchSimulate(TrueOrFalse param,
- CancellationToken cancellationToken = default)
- {
- return await RobotPrivateControllerClient.SwitchSimulateAsync(param, cancellationToken: cancellationToken);
- }
-
- #if NET5_0||NET6_0
- /// <summary>
- /// 获取机器人概要数据流
- /// </summary>
- /// <returns></returns>
- public IAsyncEnumerable<RobotBriefData> GetRobotBriefDataStream(CancellationToken cancellationToken = default)
- {
- return RobotControllerClient.GetRobotBriefData().ResponseStream
- .ReadAllAsync(cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人的IO数据流
- /// </summary>
- /// <returns></returns>
- public virtual IAsyncEnumerable<IO> GetRobotIODataStream(CancellationToken cancellationToken = default)
- {
- return RobotControllerClient.GetRobotIOData().ResponseStream
- .ReadAllAsync(cancellationToken);
- }
-
- /// <summary>
- /// 获取机器人的IO数据流
- /// </summary>
- /// <returns></returns>
- public virtual AsyncDuplexStreamingCall<RobotDataCmd, IO> GetRobotIOData(
- CancellationToken cancellationToken = default)
- {
- return RobotControllerClient.GetRobotIOData(cancellationToken: cancellationToken);
- }
- #endif
- /*// 连接/断开 MODBUS 设备
- public virtual async Task<Response> ConnectExternalIO(ExternalIOState param){
- return await RobotPrivateControllerClient.ConnectExternalIOAsync(param,cancellationToken:cancellationToken);
- }*/
- }
- }
|