1.6 VREP之模型外部控制器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lwz45698752/article/details/84697645


控制机器人或仿真有如下六种方式:


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.

猜你喜欢

转载自blog.csdn.net/lwz45698752/article/details/84697645
1.6