您好,欢迎访问代理记账网站
  • 价格透明
  • 信息保密
  • 进度掌控
  • 售后无忧

(一)使用CoppeliaSim内置/其他语言编写代码

Writing code in and around CoppeliaSim

使用CoppeliaSim内置/其他语言编写代码

CoppeliaSim is a highly customizable simulator: every aspect of a simulation can be customized. Moreover, the simulator itself can be customized and tailored so as to behave exactly as desired. This is allowed through an elaborate Application Programming Interface (API). 6+ different programming or coding approaches are supported, each having particular advantages (and obviously also disadvantages) over the others, but all six are mutually compatible (i.e. can be used at the same time, or even hand-in-hand). The control entity of a model, scene, or the simulator itself can be located inside:

CoppeliaSim是一个高度可定制的模拟器:模拟器的每个方面都可以定制。而且,模拟器本身可以改制和定制,以便完全按照所需的方式工作。这是通过精心设计的 应用程序接口 (API)。支持6+种不同的编程或编码方法,每种方法相对于其他方法都有特定的优点(显然也有缺点),但所有六种方法都是相互兼容的(即可以同时使用,甚至可以手拉手使用)。模型, 场景或模拟器本身的控制实体可以位于:

  • an embedded script (i.e. customizing a simulation (i.e. a scene or models) via scripting): this method, which consists in writing Lua scripts, is very easy and flexible, with guaranteed compatibility with every other default CoppeliaSim installations (as long as customized Lua-commands are not used, or are used with distributed plugins). This method allows customizing a particular simulation, a simulation scene, and to a certain extent the simulator itself. This is the easiest and most used programming approach.
  • 一个嵌入式脚本 (即:通过脚本自定义仿真(即 场景 或 模型):此方法包括lua 脚本,非常简单和灵活,与其他默认的Copperiasim安装都有一定的兼容性(只要不使用自定义Lua命令,或与分布式一起使用 插件)。该方法允许自定义特定的模拟、模拟场景,以及在一定程度上模拟器本身。这是最简单、最常用的编程方法。
  • an add-on or the sandbox script: this method, which consists in writing Lua scripts, allows to quickly customize the simulator itself. Add-ons (or the sandbox script) can start automatically and run in the background, or they can be called as functions (e.g. convenient when writing importers/exporters). Add-ons should not be specific to a certain simulation or model, they should rather offer a more generic, simulator-bound functionality.
  • 一个附加组件 或 沙盒脚本:这种方法,由Lua 脚本组成,允许快速定制模拟器本身。加载项(或沙盒脚本)可以自动启动并在后台运行,也可以作为函数调用(例如,在编写导入程序/导出程序时很方便)。附加组件不应该特定于某个仿真或模型,它们应该提供更通用的、受模拟器约束的功能。
  • a plugin (i.e. customizing the simulator and/or a simulation via a plugin): this method basically consists in writing a plugin for CoppeliaSim. Oftentimes, plugins are only used to provide a simulation with customized Lua commands, and so are used in conjunction with the first method. Other times, plugins are used to provide CoppeliaSim with a special functionality requiring either fast calculation capability (scripts are most of the time slower than compiled languages), a specific interface to a hardware device (e.g. a real robot), or a special communication interface with the outside world.
  • 一个插件 (即:定制模拟器和/或通过插件进行模拟):这种方法基本上包括为CoppeliaSim编写插件。通常,插件通常用于和第一种方法联合,只使用自定义的Lua命令来提供仿真。其他时候,插件被用来为CoppeliaSim提供一种特殊的功能,这种功能要么需要快速的计算能力(脚本在大多数情况下比编译语言慢),要么作为硬件设备(如真正的机器人)的特定接口,要么作为与外界的特殊通信接口。
  • a remote API client (i.e. customizing the simulator and/or a simulation via a remote API client application): this method allows an external application (e.g. located on a robot, another machine, etc.) to connect to CoppeliaSim in a very easy way, using remote API commands.
  • 一个远程API 客户端(即通过远程API客户端应用程序自定义模拟器和/或模拟):此方法允许外部应用程序(例如位于机器人、另一台机器等上)使用远程API命令以非常简单的方式连接到CoppeliaSim。
  • a ROS node (i.e. customizing the simulator and/or a simulation via a ROS node): this method allows an external application (e.g. located on a robot, another machine, etc.) to connect to CoppeliaSim via ROS, the Robot Operating System.
  • 一个ROS节点 (即通过ROS节点定制模拟器和/或模拟:此方法允许外部应用程序(例如位于机器人、另一台机器等上)通过ROS机器人操作系统链接CoppeliaSim。
  • a node talking TCP/IP, ZeroMQ, etc.: this method allows an external application (e.g. located on a robot, another machine, etc.) to connect to CoppeliaSim via various communication means.
  • 一个使用 TCP/IP协议, ZeroMQ等的节点:此方法允许外部应用程序(例如位于机器人、另一台机器等上)通过各种通信方式连接到CoppeliaSim。

Above 6 methods are also discussed in the external controller tutorial. Following table describes in detail the respective advantages and disadvantages of each method:

外部控制器教程中也讨论了上述6种方法,下表详细说明了每种方法各自的优缺点:

 Embedded ScriptAdd-on/sanbox scriptPluginRemote API clientROS/ROS2 nodeZeroMQ node
控制实体可以在外部(比如在一个机器人,另一个机器等)nononoyesyesyes
实现难度最简单最简单相对简单简单相对简单简单
支持的语言LuaLuaC/C++C/C++,Python,Java,Matlab,Octave,LuaAnyAny
代码执行速度相对较慢相对较慢取决于编程语言取决于编程语言取决于编程语言
通讯延迟没有没有没有有,减少有,减少有,减少
控制实体完全包含在一个场景或模型中,高度便携yesnonononono
控制实体依赖于CoppeliaSimCoppeliaSimCoppeliaSimBlueZero 框架或socketsROS/ROS2框架各种,如ZeroMQ,TCP/IP
同步操作有,固有的,没有延迟有,固有的,没有延迟有,固有的,没有延迟有,由于通讯延迟比较慢有,由于通讯延迟比较慢有,由于通讯延迟比较慢
异步操作有,通过线程有,通过线程没有[可以获取线程,但是API接口禁止]有,默认操作模式有,默认操作模式

 

[Possible control methods in and around CoppeliaSim]


分享:

低价透明

统一报价,无隐形消费

金牌服务

一对一专属顾问7*24小时金牌服务

信息保密

个人信息安全有保障

售后无忧

服务出问题客服经理全程跟进