Basic ROS functionality with roslibjs

  1. 创建simple.html文件,将代码复制进去。
    
    
    
    

   
  

  


   
   

Simple roslib Example

Check your Web Console for output.

``` 2. 运行实例 首先启动ROS,终端输入: $ roscore 从server发布一条消息来测试我们的JavaScript subscriber: $ rostopic pub /listener std_msg/String "hello world" 订阅一个topic来测试从浏览器发布消息: $ rostopic echo /cmd_vel 运行一个service server,用来从从浏览器返回service调用: $ rosrun rospy_tutorials add_two_ints_server 当所有命令都运行起来之后,我们启动rosbridge v2.0 server: $ roslaunch rosbridge_server rosbridge_websocket.launch 3. 运行结果: ![simple_add_two_ints](http://upload-images.jianshu.io/upload_images/3869738-fbe2fefd23ff74f8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![simple_cmd_vel](http://upload-images.jianshu.io/upload_images/3869738-a01f48b014d6254c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![浏览器控制台输出](http://upload-images.jianshu.io/upload_images/3869738-b96a39288a4ee68a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Basic ROS functionality with roslibjs)