B0-based remote API modus operandi

news/2025/3/14 22:37:03/

B0-based remote API modus operandi

基于B0的远程API操作方法


The BØ-based remote API should not be mixed-up with the c remote API (or simply remote API), which is an older version of the remote API that is less flexible, and more difficult to extend.

基于BØ的远程API不应与早期的远程API(或简单的远程API)混淆,后者是远程API的旧版本,灵活性较差,更难扩展。

A B0-based remote API function is called in a similar fashion as a regular API function, however with one major difference:

基于B0的远程API函数的调用方式与常规API函数类似,但有一个主要区别:

Most B0-based remote API functions require one additional argument: the topic or communication channel to use for executing the function call. The topic can be the return value of one of following 5 functions:

大多数基于B0的远程API函数需要一个附加参数:用于执行函数调用的主题或通信通道。主题可以是以下5个函数之一的返回值:

simxServiceCall: this topic allows to execute the function in a blocking mode, i.e. the command will travel to the server (i.e. CoppeliaSim), execute there, and return a response to the client. Use this topic only when fetching command responses from the server as a one-time operation (e.g. simxGetObjectHandle would typically use a service call to execute).

本主题允许在阻塞模式下执行功能,即命令将传输到服务器(即CoppeliaSim),在那里执行,并向客户端返回响应。仅当作为一次性操作从服务器获取命令响应时才使用此主题(例如,simxGetObjectHandle通常使用这个服务去执行)。


simxDefaultPublisher: this topic allows to execute the function in a non-blocking mode, i.e. the function is sent to the server (i.e. CoppeliaSim), and control returns immediately to the client (i.e. the client will not wait for a reply from the server). Use this topic only when sending commands to the server, where you do not expect/need a response from it (e.g. simxSetJointPosition would typically use the default publisher to execute).

本主题允许在非阻塞模式下执行函数,即函数被发送到服务器(即CoppeliaSim),控制立即返回到客户端(即客户端不会等待服务器的回复)。仅当向服务器发送命令时才使用此主题,因为您不希望/不需要服务器的响应(例如,simxSetJointPosition通常使用默认发布服务器来执行)。


simxDefaultSubscriber: this topic informs the server to continuously execute the function, and continuously stream the response to the client. The client will be receiving the response inside of a callback function. Use this topic only when you want to receive the response from the same command continuously executed on the server side. (e.g. simxGetJointForce would typically use the default subscriber to execute). Defined callback functions are called via the simxSpinOnce function (when a response is available in the input buffer).

本主题通知服务器继续执行该函数,并将响应流式传输到客户端。客户端将在回调函数中接收响应。仅当您希望从服务器端连续执行的同一命令接收响应时,才使用此主题。(例如,simxGetJointForce通常使用默认订阅服务器来执行)。定义的回调函数通过simxSpinOnce函数调用(当输入缓冲区中有响应可用时)。


simxCreatePublisher: this is very similar to simxDefaultPublisher, with the difference, that a dedicated publisher topic is created, i.e. a dedicated publishing channel is created. It can be useful to assign specific functions/commands to a dedicated publisher, specially with heavy data (e.g. simxSetVisionSensorImage would typically use a dedicated publisher to execute).

这与simxDefaultPublisher非常相似,不同之处在于创建了一个专用的发布者主题,即创建了一个专用的发布频道。将特定功能/命令分配给专用发布服务器非常有用,特别是在数据量大的情况下(例如,simxSetVisionSensorImage通常会使用专用发布服务器来执行)。


simxCreateSubscriber: this is very similar to simxDefaultSubscriber, with the difference, that a dedicated subscriber topic is created, i.e. a dedicated subscriber channel is created. It can be useful to assign specific functions/commands to a dedicated subscriber, specially with heavy data (e.g. simxGetVisionSensorImage would typically use a dedicated subscriber to execute).

这与simxDefaultSubscriber非常相似,不同之处在于创建了一个专用订户主题,即创建了一个专用订户频道。将特定功能/命令分配给专用订阅者可能很有用,特别是在数据量大的情况下(例如,simxGetVisionSensorImage通常会使用专用订阅者来执行)。

 

默认情况下,基于B0的远程API客户端和服务器(即CoppeliaSim)将异步运行。但是,可以让客户机单独触发每个模拟步骤,以实现同步操作。以下是同步模式的Python示例:

import b0RemoteApi
import timewith b0RemoteApi.RemoteApiClient('b0RemoteApi_pythonClient','b0RemoteApi') as client:    doNextStep=Truedef simulationStepStarted(msg):  #  simxDefaultSubscriber 的回调函数simTime=msg[1][b'simulationTime'];print('Simulation step started. Simulation time: ',simTime)def simulationStepDone(msg):  #  simxDefaultSubscriber 的回调函数simTime=msg[1][b'simulationTime'];print('Simulation step done. Simulation time: ',simTime);global doNextStepdoNextStep=Trueclient.simxSynchronous(True)client.simxGetSimulationStepStarted(client.simxDefaultSubscriber(simulationStepStarted));  # 检查当前模拟步骤是否已完成执行client.simxGetSimulationStepDone(client.simxDefaultSubscriber(simulationStepDone));client.simxStartSimulation(client.simxDefaultPublisher())startTime=time.time()while time.time()<startTime+5: if doNextStep:doNextStep=Falseclient.simxSynchronousTrigger()  # 如果先前启用了CoppeliaSim同步模式,则触发下一个模拟步骤client.simxSpinOnce()  #  调用有消息等待的订阅者的所有回调,然后返回client.simxStopSimulation(client.simxDefaultPublisher())

 


http://www.ppmy.cn/news/588371.html

相关文章

服务器 composer install 报错:proc_open(): fork failed - Cannot allocate memory

运行这几条命令后问题解决 /bin/dd if/dev/zero of/var/swap.1 bs1M count1024 /sbin/mkswap /var/swap.1 /sbin/swapon /var/swap.1总结&#xff1a; 根据问题描述可能是内存原因&#xff0c;maybe是没有给composer配置内存&#xff1f;

没有SLI选择卡的nForce4 SLI主板上市

青云采用nForce4 SLI芯片的主板新品K8SLI日本上市了&#xff0c;该产品和以前的nForce4 SLI主板有所不同&#xff0c;在两个PCI-E扩展槽之间的SLI模式切换开关被取消了&#xff0c;其SLI的模式切换可以在Windows上进行。 作为类似的“nForce4 SLI”主板产品&#xff0c;华硕A8…

Maven 打包的时候提示Some Enforcer rules have failed错误

1. 问题描述 今天在准备打包部署到生产环境时, 发生了下面这个错误: Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.:enforce (enforce-banned-dependencies) on project manager: Some Enforcer rules have failed. Look above for specific…

nForce2芯片组内置网卡、音频驱动安装[转]

nForce2驱动下载&#xff1a; http://www.nvidia.com/object/linux.html 原英文文档 http://download.nvidia.com/XFree86/...leaseNotes.html 序言&#xff1a;nforce芯片组包括一组可以运行在linux下的硬件设备。随同一个显示处理器&#xff0c;芯片中包含一个网络设备&#…

前端---场景题

一个下拉框 200条数据 怎么优化 &#xff08;默认展示10条&#xff09;60个请求&#xff08;限制最多同时请求6个&#xff09;请求并行方案原生拖拽方案及实现细节&#xff08;mouseMove、drag&#xff0c;drop&#xff09; ✅ &#xff08;有待继续完善&#xff09;数组遍历方…

个人用计算机配置清单,电脑配置单这么写?教你写一份合理的电脑配置清单

IT杂志社干货分享 IT杂志社:专注电脑、手机干货分享,欢迎点击右上角关注。 今天聊一下电脑配置单这么写?在开始写配置清单之前,一定要清楚自己的需求和预算。 最简单的决定就是直接选择当下的顶级配置,关于需求和性能之间的关系,请看《漫谈个人电脑的未来》。 写配置清单…

【adb 命令】

1.ADB概念 ADB&#xff0c;全名 Android Debug Bridge&#xff0c;是 Android 提供的一个通用的调试工具&#xff0c;是一个 C/S 架构的命令行工具&#xff0c;通过这个工具&#xff0c;使得我们的 PC 能够和 Android 设备来进行通信。 1.1 ADB的工作原理&#xff1a; adb 主要…

什么是α测试β测试和灰度测试?

吃软件测试这碗饭的&#xff0c;如果基础理论都不懂&#xff0c;谈何长久&#xff1f; 欢迎来学习本系列&#xff0c;基础理论比较枯燥&#xff0c;这也是为什么现在很少人掌握的主要原因。热饭尽量用浅显易懂 生动的例子 来帮助大家学习基础理论&#xff0c;所以请耐心看完此系…