<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>KUKA YouBot Development</title>
    <description>keep hungry and keep fool!</description>
    <link>https://adangge.github.io/</link>
    <atom:link href="https://adangge.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Wed, 10 May 2017 03:41:06 +0000</pubDate>
    <lastBuildDate>Wed, 10 May 2017 03:41:06 +0000</lastBuildDate>
    <generator>Jekyll v3.4.3</generator>
    
      <item>
        <title>KUKA YouBot实体机开发及Apache Web Server应用</title>
        <description>&lt;p&gt;这是我的第一篇博文，诣在分享KUKA YouBot的开发经验，同时也是对在学习过程中帮助过我的朋友的一个反馈！&lt;/p&gt;

&lt;p&gt;这篇博文的主题有两个:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;在YouBot实体机上完成手臂的指定运动，将工作台上的一个小方块从左边移动至右边，暂且称之为”SmartMove”;&lt;/li&gt;
  &lt;li&gt;通过Apache Web Server完成前端开发，在网页上控制YouBot的运动。同时，基于这个WebServer可以开发Android App实现对YouBot的控制。这篇博文不介绍App的开发，有兴趣的朋友可以私信我！&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;smartmove&quot;&gt;SmartMove&lt;/h3&gt;
&lt;p&gt;磨刀不误砍柴工，对于第一次学习ROS开发的朋友，以下基础是有必要掌握的:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;通过CatKin创建工作目录和Package， 详见 &lt;a href=&quot;http://wiki.ros.org/catkin/Tutorials&quot;&gt;link to Catkin!&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;建立自己的GitHub账号，学习如何使用git命令。这方面网上有很都资料，大家很容易学会！&lt;/li&gt;
  &lt;li&gt;安装ROS Wrapper，详见 &lt;a href=&quot;http://www.youbot-store.com/wiki/index.php/ROS_Wrapper&quot;&gt;link to ROS Wrapper!&lt;/a&gt;。这个Tutorial中包括一个键盘控制YouBot Base的程序,将来在仿真中也会有类似应用。同时，rostopic是非常有用的一个命令，往后会经常用到，例如查看各个joint的角度和速度，详见 &lt;a href=&quot;http://wiki.ros.org/rostopic&quot;&gt;link to rostopic!&lt;/a&gt;。但是用这个命令无法查看ROBOT电池的电压和HDD的温度信息。这个需要用到一个PYTHON程序，有兴趣的朋友可以私信我！&lt;/li&gt;
  &lt;li&gt;运行HelloWorld Demo, 详见 &lt;a href=&quot;http://www.youbot-store.com/wiki/index.php/C%2B%2B_Hello_World_example&quot;&gt;link to HelloWorld Demo!&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;以上是很基础的知识，但是非常重要，特别是1和2，掌握扎实，能够事半功倍!&lt;/p&gt;

&lt;p&gt;完成了上述4点以后，必要的API和开发基础大家都会有了。我的YouBot是12.04Ubuntu和ROS hydro，现在介绍”SmartMove”程序。这个程序是在HelloWorld Demo基础上改的，主要是手臂的运动。这里一共有20个手臂的动作，除了gripper的张合每一个动作对应5个jointvalues,这个值就是手臂joint的弧度值。同时，速度的控制其实就是控制每个动作之间的间隔时间 ‘ros::Duration(3).sleep()’。以下代码显示的是一个手臂动作:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;moveArmstart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    
     &lt;span class=&quot;nl&quot;&gt;brics_actuator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;JointPositions&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;nl&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;double&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     
     &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;5.84014&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.846735&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.8950&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;3.02356&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.95&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     
     &lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createArmPositionCommand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;jointvalues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;armPublisher&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;publish&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     
     &lt;span class=&quot;nl&quot;&gt;ros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;其中，JV[0]是手臂连接base的最大的joint，JV[4]是手臂顶端连接gripper的joint。在测试角度的时候一定要注意每个joint的有效范围，如果出错在后台都会有显示，所以要注意后台信息。以下代码显示的是gripper的打开，其实就是设置gripper的距离值，当然这个值也有有效范围，后台一样会显示给值是否法。&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;moveGripperopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;

     &lt;span class=&quot;nl&quot;&gt;brics_actuator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;JointPositions&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     
     &lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;createGripperPositonCommand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0115&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     &lt;span class=&quot;nx&quot;&gt;gripperPublisher&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;publish&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
     
     &lt;span class=&quot;nl&quot;&gt;ros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;理解上述代码以后，大家可以开始自己编写手臂运动。我的完整代码详见 &lt;a href=&quot;https://github.com/Adangge/Apache-Server_YouBot_Object_Displacer/blob/master/main.cpp&quot;&gt;Apache-server_YouBot_Object_Displacer，main.cpp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;总得来说，对手臂运动包括底盘运动的开发是很基础的，在没有其他传感器的参与下，除了加入前端控制，YouBot的开发相当有限！接下来介绍运用Apache Web Server开发一个网页服务器来控制YouBot完成SmartMove。&lt;/p&gt;

&lt;h3 id=&quot;apache-web-server&quot;&gt;Apache Web Server&lt;/h3&gt;
&lt;p&gt;首先还是介绍下必要的基础知识:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;在Ubuntu下安装并配置Apache Web Server，这里介绍两篇博文，讲的还是非常清楚的，大家做下来应该可以清楚Apache Web Server是什么。&lt;a href=&quot;blog.csdn.net/ichuzhen/article/details/8217577&quot;&gt;Ubuntu下安装配置Apache http server&lt;/a&gt;, &lt;a href=&quot;blog.csdn.net/guaikai/article/details/6905781&quot;&gt;手把手教你在ubuntu上安装apache和mysql和php&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;编写一个Shell Script，并通过Apache在Html Page上加载，介绍一篇英文博文，&lt;a href=&quot;https://kuldeeparya.wordpress.com/2014/07/20/demo-how-to-invoke-a-shell-script-on-a-html-page-being-served-by-apache-on-linux-machine/&quot;&gt;Demo:How to invoke a Shell Script on a HTML Page being served by Apache on Linux Machine&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;准备工作做完之后，其实整个事情就完成一大半了。不过具体的配置和出现的问题是因人而异的，大家耐心做肯定可以完成！现在介绍两个关键的程:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;test_script.sh&lt;/strong&gt; 这个文件包括IP配置和所有你想要实现的ROS程序。它存在的目录位置通常有两种，&lt;strong&gt;usr/lib/cgi-bin/test_script.sh&lt;/strong&gt;和&lt;strong&gt;var/www/cgi-bin&lt;/strong&gt;，这取决于个人配置。我的代码详见&lt;a href=&quot;https://github.com/Adangge/Apache-Server_YouBot_Object_Displacer/blob/master/test_script.sh&quot;&gt;Apache-server_YouBot_Object_Displacer, test_script.sh&lt;/a&gt;。这里关键是要注意修改IP和URI，同时运行ROS程序前要source相关路径，否则会报错！&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;youbot.html&lt;/strong&gt; 这个文件调用了test_script.sh文件，并定义了一个button和一些导言，这些在网页上都会显现。它的位置通常都是在&lt;strong&gt;/var/www/html/youbot.html&lt;/strong&gt;。我的代码详见&lt;a href=&quot;https://github.com/Adangge/Apache-Server_YouBot_Object_Displacer/blob/master/youBot.html&quot;&gt;Apache-server_YouBot_Object_Displacer, youBot.html&lt;/a&gt;。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;代码很简单，相信大家都可以理解！只不过是刚开始时不熟悉Apache Web Server,大家从逻辑上可能会不大理解它在Linux下如何和YouBot产生联系。这也是为什么我不建议大家直接 git clone 所有文件的原因，从头开始一步步理解所有程序才会有很大收获。从效率上来讲，这样做似乎比较费时，其实是事半功倍的。只不过很多人想要打好基础，但苦于不知从何入手或者找不到有效的资料而走了不少弯路。&lt;/p&gt;

&lt;p&gt;写到这里这篇博文基本上就结束了！最后附上通过WebServer控制YouBot完成SmartMove的&lt;a href=&quot;http://v.youku.com/v_show/id_XMjc1NDYxNTM2MA==.html?spm=a2hzp.8244740.userfeed.5!2~5~5~5!3~5~A&quot;&gt;视频&lt;/a&gt;！&lt;/p&gt;

&lt;p&gt;由于多说无法继续使用，大家最好注册Disqus，这样就可以参与评论了！&lt;/p&gt;
</description>
        <pubDate>Thu, 04 May 2017 00:00:00 +0000</pubDate>
        <link>https://adangge.github.io/2017/05/development-of-kuka-youbot-with-apache-web-server/</link>
        <guid isPermaLink="true">https://adangge.github.io/2017/05/development-of-kuka-youbot-with-apache-web-server/</guid>
        
        <category>KUKA YouBot</category>
        
        <category>Apache Web Server</category>
        
        <category>教程</category>
        
        
      </item>
    
  </channel>
</rss>
