天天看點

1.6 VREP之模型外部控制器child script(子腳本)plugin(插件)外部用戶端應用(依賴于remote API)ROS節點BlueZero (BØ) node多種方式綜合執行個體(待補)

文章目錄

  • child script(子腳本)
    • 優點
    • 缺點
  • plugin(插件)
    • 優點
    • 缺點
  • 外部用戶端應用(依賴于remote API)
  • ROS節點
  • BlueZero (BØ) node
  • 多種方式綜合
  • 執行個體(待補)

控制機器人或仿真有如下六種方式:

child script(子腳本)

寫child script(最便捷)來定義機器人或其他模型的行為,

優點

  • child script直接綁定到scene objects上,當複制object,同時也複制其所綁定的腳本child script。
  • 這些腳本能以threaded or non- threaded的模式運作,且可通過custom Lua function or a Lua extension library來拓展(extend)
  • 與下面提到的最後3種方法相比,沒有通信延遲((i.e. the regular API is used)),且child scripts是使用者主線程(固有的同步操作 inherent synchronous operation)的一部分

缺點

  • 不能選擇程式設計語言
  • 代碼效率不一定最高
  • 不能直接調用外部函數庫(access external function libraries),除了LUA拓展庫

plugin(插件)

  • 插件機制允許回調機制,自定義lua函數注冊以及外部函數庫。插件通常在子腳本一起使用,比如插件注冊自定義的Lua函數,當從子腳本調用這些LUA函數時,将調用特定的插件函數
The plugin mechanism allows for callback mechanisms, custom Lua function registration, and of course access to external function libraries. A plugin is often used in conjunction with child scripts (e.g. the plugin registers custom Lua functions, that, when called from a child script, will call back a specific plugin function).

優點

  • 與下面提到的最後3種方法相比,沒有通信延遲((i.e. the regular API is used)),且插件是使用者主線程(固有的同步操作 inherent synchronous operation)的一部分

缺點

在于程式設計較複雜,需要外部工具編譯

外部用戶端應用(依賴于remote API)

  • 當需要從外部應用中運作控制代碼,是一種友善和簡單的方式。這種方式允許你用完全相同的代碼(運作在real機器人上)來控制仿真或模型(control a simulation or a model)
  • 遠端API功能依賴于遠端API插件(伺服器端)和用戶端的遠端API代碼。
  • 這兩個程式/項目都是開源的(即可以很容易地擴充或translated以支援其他語言),可以在程式設計檔案夾或線上找到它們。
  • 目前有六種支援的語言:C/C++, Python, Java, Matlab, Octave and Lua
The remote API functionality relies on the remote API plugin (on the server side), and the remote API code on the client side. Both programs/projects are open source (i.e. can be easily extended or translated for support of other languages) and can be found in the programming folder or online.

ROS節點

同Remote API方式類似,ROS是一種可以讓多個分布式程序互相通信的便捷方式。Remote API隻允許與VREP通信,是以輕量和迅速,ROS允許幾乎任意數量的程序互相連接配接,并且可以使用大量相容庫,是以比remote API更加複雜和heavier。

BlueZero (BØ) node

同Ros方式類似,BlueZero是一種可以讓多個分布式程序互相通信的便捷方式,且是lightweight and cross-platform解決方案。

多種方式綜合

  • 使用V-REP插件或V-REP腳本來編寫通過各種方式(例如pipe、套接字、序列槽等)進行通信的外部應用程式
  • 好處在于程式設計語言任選,靈活,且控制代碼可運作在機器人或不同電腦上,但相比于remote API,更複雜。
A sixth way to control a robot or a simulation is by writing an external application that communicates via various means (e.g. pipes, sockets, serial port, etc.) with a V-REP plugin or V-REP script. Two major advantages are the choice of programming language, which can be just any language, and the flexibility. Here also, the control code can run on a robot, or a different computer. This way of controlling a simulation or a model is however more tedious that the method with the remote API.

執行個體(待補)

參見controlTypeExamples.ttt

In all 6 cases, child scripts are used, mainly to make the link with the outside world (e.g. launch the correct client application, and pass the correct object handles to it).

  • There are two other ways one can control a robot, a simulation, or the simulator itself: by using customization scripts, or add-ons. They are however not recommended for control and should be rather used to handle functionality while simulation is not running.
  • notice that the green robot is controlled via bubbleRobServer, but that its child script acts as client that communicates with the server. You could also imagine having the client part not inside of a child script, but inside of a plugin. Such an example is illustrated in the robot language interpreter integration tutorial.