編程語言有彙編,高級語言,解釋語言等,如今圖形化編程也愈來愈流行。圖形化編程簡單易學。8年前,微軟推出了VPL用於機器人程序設計,如Python和JavaScript均可以用圖形化框圖實現程序,有趣直觀。html
視頻介紹教程,請參考:http://v.youku.com/v_show/id_XMTc4NjkwMDgyOA前端
固然也能夠用Matlab的Simulink實現:node
https://cn.mathworks.com/help/robotics/examples/get-started-with-ros-in-simulink.htmlgit
圖1github
LiveBlox就是典型的一種,具體參考以前博客:http://blog.csdn.net/ZhangRelay/article/details/51991997
web
這裏主要介紹用於ROS的圖形化編程工具,首先,主要參考網址以下:數據庫
1 https://github.com/erlerobot/robot_blocklynpm
2 https://github.com/hcrlab/code_it編程
其中,1 robot_blockly實現簡潔,而且介紹詳細,這裏不過多介紹。gulp
這裏主要介紹2 code_it。
圖2
依次輸入下面命令:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - sudo apt-get install -y nodejs
sudo apt-get install ros-indigo-rosbridge-server
npm install -g gulp bower npm install bower install
並用nvm use 4.6.1,選擇合適的node版本。
~/catkin_ws/src/blinky-indigo-devel/frontend$ nvm use 4.6.1 Now using node v4.6.1 (npm v2.15.9)
~/catkin_ws/src/blinky-indigo-devel/frontend$ gulp [13:51:49] Using gulpfile ~/catkin_ws/src/blinky-indigo-devel/frontend/gulpfile.js [13:51:49] Starting 'clean'... [13:51:50] Finished 'clean' after 472 ms [13:51:50] Starting 'default'... [13:51:50] Starting 'copy'... [13:51:50] Starting 'styles'... [13:51:51] styles all files 98 B [13:51:51] Finished 'styles' after 1.08 s [13:51:52] copy all files 16.77 MB [13:51:52] Finished 'copy' after 2.1 s [13:51:52] Starting 'elements'... [13:51:52] Finished 'elements' after 9.34 ms [13:51:52] Starting 'lint'... [13:51:53] Starting 'images'... [13:51:53] Starting 'fonts'... [13:51:53] Starting 'html'... [13:51:54] Finished 'fonts' after 461 ms [13:51:57] Finished 'lint' after 5.48 s [13:51:57] gulp-imagemin: Minified 7 images (saved 1.45 kB - 3.2%) [13:51:57] images all files 43.69 kB [13:51:57] Finished 'images' after 4.08 s [13:51:57] html all files 83.06 kB [13:51:57] Finished 'html' after 4.01 s [13:51:57] Starting 'vulcanize'... [13:52:00] vulcanize all files 628.85 kB [13:52:00] Finished 'vulcanize' after 2.53 s [13:52:00] Finished 'default' after 10 s
分別在不一樣終端輸入下面命令:
~$ roslaunch rosbridge_server rosbridge_websocket.launch
logging to /home/exbot/.ros/log/084a8eba-a18a-11e6-9113-70f1a1ca7552/roslaunch-relay-Aspire-4741-6570.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://relay-Aspire-4741:38297/ SUMMARY ======== PARAMETERS * /rosbridge_websocket/address: * /rosbridge_websocket/authenticate: False * /rosbridge_websocket/delay_between_messages: 0 * /rosbridge_websocket/fragment_timeout: 600 * /rosbridge_websocket/max_message_size: None * /rosbridge_websocket/port: 9090 * /rosbridge_websocket/retry_startup_delay: 5 * /rosdistro: indigo * /rosversion: 1.11.20 NODES / rosapi (rosapi/rosapi_node) rosbridge_websocket (rosbridge_server/rosbridge_websocket) auto-starting new master process[master]: started with pid [6582] ROS_MASTER_URI=http://localhost:11311 setting /run_id to 084a8eba-a18a-11e6-9113-70f1a1ca7552 process[rosout-1]: started with pid [6595] started core service [/rosout] process[rosbridge_websocket-2]: started with pid [6602] process[rosapi-3]: started with pid [6613] registered capabilities (classes): - rosbridge_library.capabilities.call_service.CallService - rosbridge_library.capabilities.advertise.Advertise - rosbridge_library.capabilities.publish.Publish - rosbridge_library.capabilities.subscribe.Subscribe - <class 'rosbridge_library.capabilities.defragmentation.Defragment'> - rosbridge_library.capabilities.advertise_service.AdvertiseService - rosbridge_library.capabilities.service_response.ServiceResponse - rosbridge_library.capabilities.unadvertise_service.UnadvertiseService [INFO] [WallTime: 1478152491.544249] Rosbridge WebSocket server started on port 9090 [INFO] [WallTime: 1478152523.004659] Client connected. 1 clients total. [INFO] [WallTime: 1478152524.576138] [Client 0] Subscribed to /blinky/goal [INFO] [WallTime: 1478152524.583260] [Client 0] Subscribed to /blinky/cancel
~/catkin_ws/src/blinky-indigo-devel/frontend$ gulp serve
[13:55:03] Using gulpfile ~/catkin_ws/src/blinky-indigo-devel/frontend/gulpfile.js [13:55:03] Starting 'lint'... [13:55:05] Starting 'styles'... [13:55:06] Starting 'elements'... [13:55:06] Starting 'images'... [13:55:06] Finished 'elements' after 128 ms [13:55:06] styles all files 98 B [13:55:06] Finished 'styles' after 1.36 s [13:55:07] Finished 'lint' after 3.49 s [13:55:07] gulp-imagemin: Minified 7 images (saved 1.45 kB - 3.2%) [13:55:07] images all files 43.69 kB [13:55:07] Finished 'images' after 1.71 s [13:55:07] Starting 'serve'... [13:55:07] Finished 'serve' after 101 ms [PSK] Access URLs: -------------------------------------- Local: http://localhost:5001 External: http://192.168.1.102:5001 -------------------------------------- UI: http://localhost:3001 UI External: http://192.168.1.102:3001 -------------------------------------- [PSK] Serving files from: .tmp [PSK] Serving files from: app
圖3
輸入:http://localhost:3001/,就能夠看到:
圖4
$ rostopic list /blinky/cancel /blinky/feedback /blinky/goal /blinky/result /blinky/status /rosout /rosout_agg在終端直接輸入下面命令,就能夠發佈一段文字:
rostopic pub -1 blinky/goal blinky/FaceActionGoal "header: seq: 0 stamp: secs: 0 nsecs: 0 frame_id: '' goal_id: stamp: secs: 0 nsecs: 0 id: '' goal: display_type: 'displayMessage' h1_text: 'Hi relay,this is OK' h2_text: 'Do you happy Now?'"圖5
更多內容查看原版介紹,發現更多驚喜。
一個獨立的Blockly編程應用程序,並與ROS集成。 它容許您使用圖形界面生成機器人的代碼,並運行它。 你實現機器人的「創意」,它們與JavaScript的一個子集結合造成程序。您從界面能夠運行程序並在程序中中止它們。
CodeIt! 與RWS兼容。
它是如何工做的?
CodeIt!提供前端和後端。前端是一個網站,它容許您使用Blockly編程接口建立程序。它還具備用於添加,更新或刪除程序的簡單界面。
後端提供了一個運行JavaScript程序的ROS actionlib服務器。程序經過沙盒解釋器運行。您必須定義解釋器將運行的機器人基元。大多數原語只作了不多的工做,只是調用ROS服務。後端還包括已建立的程序的數據庫。
注意CodeIt!自己並不實現任何機器人功能。相反,它調用ROS服務來作機器人上的實際工做,假定存在提供這些服務的一些節點。由你來實現這些服務來作你的機器人的事情。咱們有一些預先實現的這些服務的PR2和Turtlebot。然而,這些仍處於發展的早期階段,沒有記錄。若是您真的有興趣使用這些,請經過提交問題與咱們聯繫,咱們將很樂意提供幫助。
主要分爲四步,分別在不一樣終端運行,步驟和解釋以下:
1 roslaunch rosbridge_server rosbridge_websocket.launch
2 rosrun code_it programs.py - 這是保存和加載程序到MongoDB和從MongoDB的後端。
3 從後端文件夾,運行 nvm use 0.10.40; meteor - 這是運行程序的JavaScript解釋器。
4 從frontend文件夾,運行 nvm use node; gulp serve - 這是前端。 用瀏覽器localhost:5000查看頁面。
圖6
注意:meteor和gulp必須正常加載,若是報錯須要結合狀況進行調試,出現以下結果,就OK!:
meteor:
exbot@relay-Aspire-4741:~/catkin_ws/src/code_it-indigo-devel/backend$ meteor [[[[[ ~/catkin_ws/src/code_it-indigo-devel/backend ]]]]] => Started proxy. => Meteor 1.4.2 is available. Update this project with 'meteor update'. => Started MongoDB. => Started your app. => App running at: http://localhost:3000/ I20161103-14:23:00.028(8)? Error connecting to websocket server. W20161103-14:23:00.026(8)? (STDERR) DEBUG: ROSLib uses utf8 encoding by default.It would be more efficent to use ascii (if possible)這時沒有啓動websocket server,啓動便可。
gulp:
exbot@relay-Aspire-4741:~/catkin_ws/src/code_it-indigo-devel/frontend$ gulp [14:22:02] Using gulpfile ~/catkin_ws/src/code_it-indigo-devel/frontend/gulpfile.js [14:22:02] Starting 'clean'... [14:22:03] Finished 'clean' after 633 ms [14:22:03] Starting 'default'... [14:22:03] Starting 'copy'... [14:22:03] Starting 'styles'... [14:22:05] styles all files 115.06 kB [14:22:05] Finished 'styles' after 2.21 s [14:22:06] copy all files 25.72 MB [14:22:06] Finished 'copy' after 3.53 s [14:22:06] Starting 'elements'... [14:22:06] Finished 'elements' after 9.43 ms [14:22:06] Starting 'lint'... [14:22:08] Starting 'images'... [14:22:09] Starting 'fonts'... [14:22:09] Starting 'html'... [14:22:09] Finished 'fonts' after 797 ms [14:22:13] Finished 'lint' after 7.14 s [14:22:13] gulp-imagemin: Minified 6 images (saved 494 B - 1.4%) [14:22:13] images all files 35.41 kB [14:22:13] Finished 'images' after 5.08 s [14:22:15] html all files 747.78 kB [14:22:15] Finished 'html' after 5.94 s [14:22:15] Starting 'vulcanize'... [14:22:19] vulcanize all files 1.52 MB [14:22:19] Finished 'vulcanize' after 3.95 s [14:22:19] Finished 'default' after 16 s
啓動後效果以下:
圖8
圖9
-End-