<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tutorial &#8211; Robohub</title>
	<atom:link href="https://robohub.org/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://robohub.org</link>
	<description>Connecting the robotics community to the world</description>
	<lastBuildDate>Mon, 05 Oct 2026 00:51:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>
	<item>
		<title>How to calculate a robot&#8217;s forward kinematics in 5 easy steps</title>
		<link>https://robohub.org/how-to-calculate-a-robots-forward-kinematics-in-5-easy-steps/</link>
		
		<dc:creator><![CDATA[Alex Owen-Hill]]></dc:creator>
		<pubDate>Wed, 25 Nov 2015 19:48:00 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/how-to-calculate-a-robots-forward-kinematics-in-5-easy-steps/</guid>

					<description><![CDATA[<div> 
 <a href="http://blog.robotiq.com/how-to-calculate-a-robots-forward-kinematics-in-5-easy-steps" title="" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"> <img src="http://blog.robotiq.com/hubfs/hd_diagram.jpg"></a> 
</div>    
<p><strong>Calculating the Forward Kinematics is often a vital first step to using a new robot in research. While there are some good tutorials available online, up until now there hasn't been a simple step-b</strong><strong>y-step guide for calculating Forward Kinematics. In this post, we provide a simple guide along with some tips on calculating the kinematics of any robotic manipulator.</strong></p> 
<p><strong></strong></p>]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-56700" src="http://robohub.org/wp-content/uploads/2015/11/forward_kinematics.jpg" alt="forward_kinematics" width="900" height="600" srcset="https://robohub.org/wp-content/uploads/2015/11/forward_kinematics.jpg 900w, https://robohub.org/wp-content/uploads/2015/11/forward_kinematics-425x283.jpg 425w, https://robohub.org/wp-content/uploads/2015/11/forward_kinematics-450x300.jpg 450w" sizes="(max-width: 900px) 100vw, 900px" />Calculating the forward kinematics is often a vital first step to using a new robot in research. While there are some good tutorials available online, up until now there hasn&#8217;t been a simple step-by-step guide for calculating forward kinematics. In this post, we provide a simple guide along with some tips on calculating the kinematics of any robotic manipulator.<span id="more-56684"></span></p>
<p>Calculating kinematics is a cornerstone skill for robotics engineers.  <a href="http://blog.robotiq.com/kinematics-why-robots-move-like-they-do" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Kinematics can sometimes be a pain,</a> however, being told to &#8220;go and calculate the Forward Kinematics&#8221; is almost robotics research shorthand for &#8220;go and get familiar with this robot&#8221;. It&#8217;s the vital first step when using any new robot in research, particularly for manipulators.</p>
<p>Even though I had learned the theory of kinematics in university, it wasn&#8217;t until I had calculated various kinematic solutions for a few real research robots that the whole process started to feel intuitive. Even then, because I was not calculating kinematics every day I had to go back to my notes to &#8220;remind myself&#8221; how to do it every time. It would have been really helpful to have a step-by-step guide to remind myself which stages to go through, without having to read through hundreds of pages of academically written equations in text books. A sort of kinematics &#8220;cheat sheet&#8221; would have been useful.</p>
<p>This post is exactly that sort of cheat sheet. For now, we&#8217;ll primarily focus on the Devanit-Hartenberg (DH) approach to forward kinematics, as it&#8217;s the most common, and we&#8217;ll get to inverse kinematics in a future post.</p>
<p>&nbsp;</p>
<p><strong>Step 1: Get a Pencil and Paper</strong></p>
<img decoding="async" class="alignleft size-medium wp-image-56697" src="http://robohub.org/wp-content/uploads/2015/11/kinematics-425x313.png" alt="kinematics" width="425" height="313" srcset="https://robohub.org/wp-content/uploads/2015/11/kinematics-425x313.png 425w, https://robohub.org/wp-content/uploads/2015/11/kinematics-408x300.png 408w, https://robohub.org/wp-content/uploads/2015/11/kinematics.png 496w" sizes="(max-width: 425px) 100vw, 425px" />
<p>It can be tempting to jump straight for the computer when starting out with a new robot. However, even if the robot looks like a &#8220;standard&#8221; 6R manipulator, I always sit down with a pencil and paper to draw out the kinematic diagram. This simple task forces you to carefully consider the actual physical configuration of the robot, avoiding false assumptions that can wreak havoc later on during coding.</p>
<p>There are various ways to draw a kinematic chain. Pick whichever style you prefer. I favor simple cylinders for the revolute joints and lines for the links. Do a Google Image Search for <a href="https://www.google.com/search?newwindow=1&amp;site=&amp;tbm=isch&amp;source=hp&amp;biw=1366&amp;bih=667&amp;q=kinematic+diagram&amp;oq=kinematic+diagram&amp;gs_l=img.3..0l4j0i30l3j0i8i30j0i24l2.1858.8878.0.9132.17.15.0.0.0.0.296.1733.0j5j4.9.0....0...1.1.64.img..8.9.1721.saMLURuVAKo" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">&#8220;kinematic diagram&#8221;</a> and see some of the different styles available.</p>
<p>As you draw, work out which way each joint moves and draw this motion as double-ended arrows onto the diagram.</p>
<p>&nbsp;<br />
<strong>Step 2: Figure Out Your Axes</strong></p>
<p>The next key step is to draw the axes onto each joint. The DH approach assigns a different axis to each movable joint.</p>
<p>If you set up your axes correctly then working with the robot will be easy. Set them up incorrectly and you will suffer countless headaches. These axes will be required by simulators, inverse kinematic solvers, and even other researchers (nobody wants to solve a forward kinematic problem if someone else has already done it).</p>
<p>The z-axis should lie on the axis of rotation, for a revolute joint, or axis of extension, for a prismatic joint. The x-axis should lie along the &#8220;common normal&#8221;, which is the shortest orthogonal line between the previous z-axis and the current z-axis. Have a look at the video below to see how to set them up:</p>
<div class="keep-aspect"><iframe title="Denavit-Hartenberg Reference Frame Layout" width="500" height="281" src="https://www.youtube-nocookie.com/embed/rA9tm0gTln8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p></p>
<p>Personally, I draw the axes using the following coloring: <strong>z-axis (blue)</strong>, <strong>x-axis (red)</strong> and <strong>y-axis (green)</strong>. This is the coloring scheme <a href="http://wiki.ros.org/rviz/DisplayTypes/Axes" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">that&#8217;s used in the RViz visualizer</a> from ROS. Back in my undergraduate days, our lecturer made an axis &#8220;sculpture&#8221; out of three colored straws stuck into a sphere of blue-tack to explain the theory to us. Though this might seem a bit &#8220;playschool,&#8221; it can sometimes actually be helpful as you can position the sculpture next to the physical robot to make sure you&#8217;ve got the axes pointing in the right direction. For a virtual version of this, check out <a href="http://twist-and-shout.appspot.com/#0_0_0_0_0_1_0_0_0_0" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">this interactive tool</a>.</p>
<p>&nbsp;</p>
<h2>Step 3: Remember Your End Effector</h2>
<img decoding="async" class="alignleft size-medium wp-image-56698" src="http://robohub.org/wp-content/uploads/2015/11/Robotiq_gripper_kinematics-385x425.jpg" alt="Robotiq_gripper_kinematics" width="385" height="425" srcset="https://robohub.org/wp-content/uploads/2015/11/Robotiq_gripper_kinematics-385x425.jpg 385w, https://robohub.org/wp-content/uploads/2015/11/Robotiq_gripper_kinematics-272x300.jpg 272w, https://robohub.org/wp-content/uploads/2015/11/Robotiq_gripper_kinematics.jpg 728w" sizes="(max-width: 385px) 100vw, 385px" />
<p>The goal of calculating the forward kinematics is to be able to calculate the end effector pose from the position of the joints.</p>
<p>Most forward kinematic tutorials will generalize the end effector as a single distance from the final joint. This is fine for a simple &#8220;open-close&#8221; gripper. However, as modern grippers are often more complicated than this, it&#8217;s worth considering how the end effector operates. The Robotiq 3-Fingered Adaptive Gripper, for example, has a few different gripping modes. Each mode will correspond to a slightly different desired end effector pose. You should consider the end effector carefully when formulating the kinematic model.</p>
<p><div style="clear:both"></div><br />
&nbsp;</p>
<h2>Step 4: Calculate the DH parameters</h2>
<p>Denavit-Hartenberg parameters are often required to enter the robot model into a simulator and start performing any sort of analysis on it.</p>
<p>The best way to visualize the DH parameters is to once again watch the video above. Have a look one more time with the DH parameters in mind.</p>
<p>The DH parameters break down each joint of the robot into four parameters, each taken with reference to the previous joint. They are calculated in reference to the &#8220;common normal&#8221; described above. Note that if the previous z-axis intersects the current z-axis, which is often the case, the common normal has a length of zero.</p>
<ul>
<li><strong><em>d</em></strong> &#8211; the distance between the previous x-axis and the current x-axis, along the common normal</li>
<li><strong><em>θ</em></strong> &#8211; the angle around the z-axis between the previous x-axis and current x-axis.</li>
<li><strong>a (or r)</strong> &#8211; the length of the common normal</li>
<li><strong>α</strong> &#8211; the angle around the common normal to between the previous z-axis and current z-axis.</li>
</ul>
<p>Go through each joint on your drawing and write down the DH parameters for each joint. Each joint should have one value, which is a variable representing the actuated joint. For a more detailed explanation and some examples, I recommend <a href="http://petercorke.com/doc/rtb_dh.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">this handout by Peter Corke</a> or <a href="http://www.roboanalyzer.com/uploads/2/5/8/8/2588919/dhparams.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">this chapter from Introduction to Robotics</a>.</p>
<p><strong>Alternatives to the DH parameters &#8212; </strong>The DH approach is the most common approach to forward kinematics, but it&#8217;s not perfect. <a href="http://robotics.stackexchange.com/questions/4610/forward-kinematics-d-h-parameters-for-perpendicular-joint-axes" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">One of its failings is</a> that it doesn&#8217;t handle parallel z-axes very elegantly. There are various alternatives, including Screw Theory representations, Hayati-Roberts and other geometric modelings (<a href="http://www.superior.edu.pk/CEET/pdf/research/DevCS/Paper-Modeling%20Robotic%20Arms-iqbal.jam@gmail.com.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">see this paper for a comparison</a>). Although these may (or may not) be better approaches, most of the kinematic libraries below do accept the DH parameters, and for that reason it&#8217;s a reasonable approach to begin with.</p>
<p>&nbsp;</p>
<h2>Step 5: Choose Your Library</h2>
<p>There are loads of kinematic software libraries, and many of them do far more than just calculate forward kinematics. Most of them include inverse kinematic solvers, dynamics, visualization, motion planning and collision detection, to name just a few features. These libraries will transform your DH parameters into matrices, which are then multiplied together to calculate the relationship between joint positions and end effector pose.</p>
<p>Of course, you can also quite easily &#8220;roll your own&#8221; forward kinematic library using your favorite programming language, if you&#8217;re inclined that way. I&#8217;ve taken this approach myself, but apart from being a good learning exercise it didn&#8217;t offer many more benefits than using an existing library.</p>
<p>Some good development libraries include: <a href="http://www.roboticslibrary.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Robotics Library</a>, <a href="http://www.orocos.org/kdl" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Orocos Kinematics and Dynamics Library</a>, <a href="http://moveit.ros.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">ROS MoveIt</a>, <a href="http://openrave.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">OpenRave</a>, <a href="http://www.roboanalyzer.com/tutorials.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">RoboAnalyzer</a> and the <a href="http://petercorke.com/Robotics_Toolbox.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Matlab Robotics Toolbox</a>.</p>
<p>Even though you&#8217;ll usually require inverse kinematics to actually control the robot, computing the forward kinematics is a necessary step to get familiar with any new robotic arm. If you found this post useful, make sure to bookmark it so you can find it when you next encounter a new robot!</p>
<p><em>What is your favorite method of getting familiar with a new robot&#8217;s kinematics? Do you prefer another method over the DH parameters? Have you got any questions on implementing Forward Kinematics in your research robot? Tell us in the comments below.</em></p>
<hr class="xh2  ">
<p><em>Enjoy this post? Find more <a href="http://robohub.org/tag/tutorial/" data-wpel-link="internal">tutorials and robotics how-tos here</a>. </em></p>
<img decoding="async" style="min-height: 1px!important; width: 1px!important; border-width: 0!important; padding: 0!important; margin: 0!important;" src="http://track.hubspot.com/__ptq.gif?a=13401&amp;k=14&amp;r=http%3A%2F%2Fblog.robotiq.com%2Fhow-to-calculate-a-robots-forward-kinematics-in-5-easy-steps&amp;bu=http%253A%252F%252Fblog.robotiq.com&amp;bvt=rss" alt="" width="1" height="1" />
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Where to place fuses and how to protect your robot and motors</title>
		<link>https://robohub.org/where-to-place-fuses-and-how-to-protect-your-robot-and-motors/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Sun, 02 Aug 2015 13:30:19 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/where-to-place-fuses-and-how-to-protect-your-robot-and-motors/</guid>

					<description><![CDATA[<p>Hi all I wanted to write a quick post today about where to place fuses and how to protect your robot. When you design a system it is often tempting to place a fuse on every component. This idea is fine for most batteries, sensors, and computers. However this can really cause destruction when you [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/proper-fuse-locations-protection-shunt-regulation/" data-wpel-link="external" target="_blank">Fuse Locations, Protection, Shunt Regulation, &#38; Motors</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="aligncenter size-large wp-image-52769" src="http://robohub.org/wp-content/uploads/2015/07/shunt_regulator_a-m-c-1024x762.jpg" alt="shunt_regulator_a-m-c" width="1024" height="762" srcset="https://robohub.org/wp-content/uploads/2015/07/shunt_regulator_a-m-c-1024x762.jpg 1024w, https://robohub.org/wp-content/uploads/2015/07/shunt_regulator_a-m-c-425x316.jpg 425w, https://robohub.org/wp-content/uploads/2015/07/shunt_regulator_a-m-c-403x300.jpg 403w, https://robohub.org/wp-content/uploads/2015/07/shunt_regulator_a-m-c.jpg 1075w" sizes="(max-width: 1024px) 100vw, 1024px" />When you design a system it is often tempting to place a fuse on every component. This idea is fine for most batteries, sensors, and computers. However this can really cause destruction when you are working with motors. I have seen several motor drivers burn up (probably the FET’s got damaged) from having this set up wrong.<span id="more-52727"></span></p>
<p>To start with the simple devices &#8230; having a fuse where the batteries enter the system is a good idea. After that I like to fuse each voltage rail (ie. DC-DC converter) so that we can take groups of sensors/computers offline at a time for testing as well as for the protection the fuses provide. I think fusing each bus is often a good compromise between fusing everything and fusing nothing.</p>
<p>The place where fusing gets tricky is with motors. To start, whenever you have a lot of energy (relative to your system) being converted from mechanical to electrical energy through your motor, a shunt regulator should be used. Any time your motors might be back driving, decelerating quickly, or dropping due to gravity (such as in a robotic arm) you have the potential for the voltage on your power bus to increase. When the voltage starts increasing you can burn out the components on your bus. For example if your motor controller is rated for 55V Maximum and you are driving a 48V motor, it is very easy for the back driving of the motor to raise the voltage above that maximum value. Remember <em>Every motor is a generator; and every generator is a motor &#8211;</em> it just depends which direction you spin it. The solution to this problem is to put a <em>shunt regulator</em> on your bus.</p>
<p>A shunt regulator is pretty much a big resistor that can shunt energy to ground in order to prevent the bus voltage from increasing to dangerous levels and destroying your robot. You generally want to set (or purchase) the shunt regulator at a value higher than the bus voltage. For example on a 48V motor you might want to set the shunt regulation voltage to 56V. One thing to be careful about is if your motors are on the main bus with the batteries, and you are charging the batteries in place, then the bus voltage increases from the charger. The shunt regulator voltage setpoint must be higher than the highest voltage that your battery charger will use while charging the batteries. Wiring the shunt regulator is super-simple. All you need to do is run two wires to the positive and ground rails of the power bus that you are trying to protect.</p>
<p>It&#8217;s common to go ahead and put a fuse before each motor driver (and its motor), and put the shunt regulator on the main bus (with no fuse). This looks pretty but you just set yourself up for problems: if the fuse blows, the amplifier is now disconnected from the shunt regulator, allowing the voltage to increase on that segment and destroy your motor (and driver)!</p>
<p>So what is the solution? There are generally two approaches:</p>
<ul>
<li>Do not fuse each motor driver individually. This lets you put all your motors and the shunt regulator on the same segment, so that if the fuse blows there is still a path to the shunt regulator.</li>
<li>Fuse each motor driver separately. However you put a power diode across the fuse to allow current to flow from the motor amplifier to your main bus where the shunt regulator is.</li>
</ul>
<p>There are two other approaches for this that are seldom used in robotics.</p>
<ul>
<li>You can put a shunt regulator next to each motor driver, but this is often not done due to cost and volume.</li>
<li>You can increase the capacitance of your power supply/system, allowing it to store more energy.</li>
</ul>
<p>When you choose the value for the fuse there are generally two approaches:</p>
<ol>
<li>Choose the value based on what you expect currents to be (plus some margin).</li>
<li>Select a fuse based on protecting a device from the maximum current that will destroy it.</li>
</ol>
<p>When you select fuses for a motor you will often want to use the second method of selecting a fuse just to avoid having to deal with voltage spikes blowing fuses. An example of when you might want the first option is if you want to limit current so something will not damage its environment if things go bad. You will also usually want to get a slow blow fuse and not a fast or quick blow fuse. This will give a little extra margin before the fuse blows to handle small transients.</p>
<hr />
<p>There are several places to purchase shunt regulators from. Two of the common sources are <a href="http://www.maxonmotor.com/maxon/view/product/235811" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Maxon Motors</a> and <a href="http://www.a-m-c.com/products/shunt-regulators.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Advanced Motion Controls</a>. In some cases you can get a shunt regulator integrated into your motor driver, for example <a href="http://www.galil.com/motion-controllers/multi-axis/dmc-41x3" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Galil Motion Control</a> has some nice (and inexpensive) integrated options.</p>
<hr />
<p><a href="https://www.servo2go.com/support/attachments/Galil%20Using%20Shunt%20Regulators.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Here is an interesting app note from Galil Motion Control about computing voltage increases.</a></p>
<hr />
<p>Main image is from <a href="http://www.a-m-c.com/products/shunt-regulators.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Advanced Motion Controls</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to convert Linux into an embedded system</title>
		<link>https://robohub.org/how-to-convert-linux-into-an-embedded-system/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Fri, 12 Jun 2015 17:30:14 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/how-to-convert-linux-into-an-embedded-system/</guid>

					<description><![CDATA[<p>Hi all Running Linux on your embedded system can be great for giving you a stable base, lots of tools, and you can often solve problems with a quick google search. I define embedded as any custom-built computer system, not only tiny devices. In many cases you can develop on the computer itself for ease [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/convert-linux-embedded-system/" data-wpel-link="external" target="_blank">Convert Linux into an Embedded System</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="aligncenter size-full wp-image-50874" src="http://robohub.org/wp-content/uploads/2015/06/CoreModule-745.jpg" alt="CoreModule-745 linux" width="900" height="500" srcset="https://robohub.org/wp-content/uploads/2015/06/CoreModule-745.jpg 900w, https://robohub.org/wp-content/uploads/2015/06/CoreModule-745-425x236.jpg 425w, https://robohub.org/wp-content/uploads/2015/06/CoreModule-745-500x278.jpg 500w" sizes="(max-width: 900px) 100vw, 900px" />Running Linux on your embedded system can be great for giving you a stable base, lots of tools, and you can often solve problems with a quick Google search.<span id="more-50620"></span></p>
<p>I define embedded as any custom-built computer system, not only tiny devices. In many cases you can develop on the computer itself for ease of development, however in other cases you will need to be able to set up a cross compile environment (for example if you have a slow ARM computer and you want to compile things on your fast Intel i7 processor).</p>
<p>This post will give you a high level list of the steps I take when setting up my Linux systems, with links for more information is some cases.</p>
<p>Linux is great since you can modify just about anything, it is free, you can strip out components you do not need, and you can configure just about anything (including the scheduler). The downside is that you can configure just about anything and break something in the process. Linux also tends to be a little behind when new technologies are released; common problems have been wireless cards, SSDs, firewire and USB3. Linux is in essence just a kernel that let&#8217;s you build operating system distributions on it. Some of the common distros are Debian, Ubuntu (I know this is Debian, but this is the flavor that is very common, supported, and one that I often use), Fedora, Suse, and Wind River.</p>
<p>A common question is whether you need a real-time version of Linux, and the answer is that most people do not. Look at your system and determine how critical it is to have guaranteed timing that an event will happen within a specific time allotment; usually the answer is no. I heard a speaker from Space X who said they mostly just use Ubuntu and not any real-time system on their rockets. If you do need real-time Linux, there are several variants including <a href="http://www.windriver.com/products/linux/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Wind River</a> (costs $$$) and <a href="http://www.rtems.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">RTEMS</a> (FREE).</p>
<p>There are many people who come from the world of servers who want to setup virtual machines (VMs) and use the Linux VMs to run the robot. I generally don’t like this. I have had many reliability problems from VMs that are constantly being turned on and off. I have also had VMs randomly not recognize devices/ports that are then recognized with a reboot. You also take a large performance hit since there is a lot of overhead in running a VM. The notion that you can have a VM on the robot and then a VM on your desktop for development usually does not work since they do not stay in sync. If you are mass producing a system, then you should just create a master drive or image, and clone that to all of the other drives; a VM is not needed.</p>
<p>Here is a rough list of steps for how to convert your Linux system into an embedded system:</p>
<ol>
<li>Choosing a filesystem. Select a volatile RAM drive for maximum reliability (and hardest development cycle). For a generic drive use journaling for reliability if the system crashes or shuts down uncleanly. In Linux this generally means EXT3 or EXT4.</li>
<li>Set the OS as read-only so you can handle system crashes. <a href="http://robotsforroboticists.com/read-operating-systems/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Learn more</a>.</li>
<li>Set bootloader to not stop on failure. This is especially true for new versions of Ubuntu; if the computer does not shut down cleanly it will halt at the bootloader until you press a key. <a href="http://robotsforroboticists.com/ubuntu-boot-automatically-failed-shutdown-stuck-bootloader/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Learn More</a>.</li>
<li>Set BIOS (I know this is not technically Linux) to autostart when power is applied (the default is to use the switch on the computer).</li>
<li>While I am in the BIOS I will often enable some of the options to speed up boot time, including reducing the length of the countdown before booting.</li>
<li>If large amounts of storage are needed, use an SSD for the OS and a spinning disk drive or second SSD for the data.</li>
<li>Change the default setting to not do a disk scan after X days or X boots. If your computer decides to do those scans you tend to stand around thinking your robot is broken, and then after it finally boots you wonder how it fixed itself.</li>
<li>Have a system watchdog. This will let you detect if your software crashes so you can restart the system. At minimum you can add a software watchdog. Even better is to purchase a computer with an integrated hardware watchdog.</li>
<li>Create a script in <em>/etc/init.d/</em> for starting your process. Any paths you use should be absolute (and not relative) paths. The newer way to do this is with upstart, though I don&#8217;t have much experience with this yet.</li>
<li>Add symlinks to your <em>/etc/init.d/</em> in <em>/etc/rc*.d</em> for the code you want to run at a given runlevel. I usually put a symlink into <em>/etc/rc2.d/, /etc/rc3.d/, and /etc/rc5.d/</em>. The other way to do this is to just edit the <em>/etc/rc.local</em> file.</li>
<li>Add /etc/udev entries for mapping devices (such as USB). This can sometimes be a tricky process that needs some experimentation with to get right. <a href="http://www.clearpathrobotics.com/blog/udev/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Learn More</a>.</li>
<li>Add other drives to /etc/fstab so that the drives come up the same with proper mount points and permissions every time. One thing to watch out for is that if the drive is not available, fstab might panic and not boot fully. If you think your drive might not be available (or you just want to be cautious) you can set <em>nofail</em> as one of the options.</li>
<li>Disable all software updates (except maybe security updates). I have seen many times where a software update will break code that has been working for a long time.</li>
<li>Good tools to install are <em>ssh</em> (or <em>openssh</em>) server and rsync for managing and updating code.</li>
<li>Use GCC tool chains when possible. Do NOT mess with other tool chains unless you have a <em>very</em> good reason.</li>
<li>Use <em>top</em> or <em>htop</em> to monitor system usage after loading your code. I try to only use around 75% of CPU and memory to allow for mostly repeatable code timing.</li>
<li>If I am using a wired network (which I almost always do) I try to put my settings in <em>/etc/networking/interfaces</em> and not in the GUI network manager. The reason for this is that it is easier to remotely change the setting (I use SSH for everything) if you ever need to change them in the future. I rarely use wireless in an embedded application for reliability reasons. If I am using wireless I will often use the GUI out of laziness, but there are ways to still use config files for wireless (which is the better way).</li>
</ol>
<p>There you have it &#8211; my list of things I do to stabilize and prepare a fresh Linux install to work in an embedded application.</p>
<p>What other steps do you take? Leave it in the comments below.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Robots 101: Lasers</title>
		<link>https://robohub.org/robots-101-lasers/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Wed, 29 Apr 2015 21:05:36 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[LIDAR]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Vision]]></category>
		<guid isPermaLink="false">http://robohub.org/robots-101-lasers/</guid>

					<description><![CDATA[<p>By Ilia Baranov In this new Robots 101 series, we will be taking a look at how robots work, what makes designing them challenging, and how engineers at Clearpath Robotics tackle these problems. To successfully operate in the real world, robots need to be able to see obstacles around them, and locate themselves. Humans do [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/blog/robots-101-lasers/" data-wpel-link="external" target="_blank">Robots 101 &#8211; Lasers</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/" data-wpel-link="external" target="_blank">Clearpath Robotics Inc.</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><em><img decoding="async" class="aligncenter size-full wp-image-49067" src="http://robohub.org/wp-content/uploads/2015/04/mapping.jpg" alt="mapping" width="800" height="400" srcset="https://robohub.org/wp-content/uploads/2015/04/mapping.jpg 800w, https://robohub.org/wp-content/uploads/2015/04/mapping-425x212.jpg 425w, https://robohub.org/wp-content/uploads/2015/04/mapping-500x250.jpg 500w" sizes="(max-width: 800px) 100vw, 800px" /><br />
By Ilia Baranov</em></p>
<p>In this new <a href="http://robohub.org/tag/robots-101/" data-wpel-link="internal">Robots 101 series</a>, we will be taking a look at how robots work, what makes designing them challenging, and how engineers at Clearpath Robotics tackle these problems. To successfully operate in the real world, robots need to be able to see obstacles around them, and locate themselves. Humans do this mostly through sight, whereas robots can use any number of sensors. Today we will be looking at lasers, and how they contribute to robotic systems.</p>
<p><span id="more-48990"></span></p>
<h2><strong><img decoding="async" class="alignleft wp-image-49063 size-full" src="http://robohub.org/wp-content/uploads/2015/04/the-day-the-earth-stood-still-gort3.jpg" alt="the-day-the-earth-stood-still-gort3" width="475" height="317" srcset="https://robohub.org/wp-content/uploads/2015/04/the-day-the-earth-stood-still-gort3.jpg 475w, https://robohub.org/wp-content/uploads/2015/04/the-day-the-earth-stood-still-gort3-425x283.jpg 425w, https://robohub.org/wp-content/uploads/2015/04/the-day-the-earth-stood-still-gort3-449x300.jpg 449w" sizes="(max-width: 475px) 100vw, 475px" />Overview</strong></h2>
<p>When you think of robots and lasers, the first image that comes to mind might come from science fiction; robots using laser weapons. However, almost all robots today use lasers for remote sensing. This means that the robot is able to tell, from a distance, some characteristics of an object. This can include size, reflective, color, etc. When the laser is used to measure distance in an arc around the robot, it is called LIDAR. <span style="line-height: 1.5;">LIDAR is a portmanteau of Light and Radar, essentially think of a sweeping radar beam shown in the films, using light.</span></p>
<p><strong style="color: #000000; background-color: #ffffff;">Function and Concepts</strong></p>
<div style="width: 651px" class="wp-caption alignleft"><img decoding="async" src="https://31.media.tumblr.com/e27ec98d7a33d1720021d87cd8e09e82/tumblr_nnl5uwaEoJ1s0pr7xo1_1280.gif" alt="" width="641" height="1391" /><p class="wp-caption-text">By Mike1024, via Wikimedia Commons</p></div>
<p>All LIDAR units operate using this basic set of steps:</p>
<p>1. Laser light is emitted from the unit (usually infrared)<br />
2. Laser light hits an object and is scattered<br />
3. Some of the light makes it back to the emitter<br />
4. The emitter measures the distance (more on how later)<br />
5. Emitter turns, and process begins again</p>
<p>A great visual deception of that process to the right.</p>
<h2><strong>Types of LIDAR sensing</strong></h2>
<p>How exactly the laser sensor measures the distance to an object depends on how accurate the data needs to be. Three different methods commonly found on LIDAR sensors are:</p>
<p><strong>Time of flight</strong><br />
The laser is emitted, and then received. The time difference is measured, and distance is simply (speed of light) x (time). This approach is very accurate, but also expensive due to the extremely high precision clocks needed on the sensor. Thus, it is usually only used on larger systems, and at longer ranges. Rare to use on robots</p>
<p><strong><br />
Phase difference</strong><br />
In this method, the emitted laser beam is modulated to a specific frequency. By comparing the phase shift of the returned signal on a few different frequencies, the distance is calculated. This is the most common way laser measurement is done. However, it tends to have limited range, and is less accurate than time of flight. Almost all of our robots use this.</p>
<p><strong><img decoding="async" class="alignleft wp-image-49062 size-full" src="http://robohub.org/wp-content/uploads/2015/04/Untitled-140x300.png" alt="Untitled-140x300" width="140" height="300" />Angle of incidence</strong><br />
The cheapest and easiest way to do laser range-finding is by angle of incidence. Essentially, by knowing what angle the reflected laser light hits the sensor, we can estimate the distance. However, this method tends to be of low quality. The Neato line of robotic vacuum cleaners use this technology.</p>
<p>Another thing to note is that so far, we have only discussed 2D LIDAR sensors. This means they are able to see a planar slice of the world around them, but not above or below. This has limitations, as the robot is then unable to see obstacles lower or higher than that 2d plane. To fix this issue, either multiple laser sensors can be used, or the laser sensor can be rotated or “nodded” up and down to take multiple scans. The first solution is what the Velodyne line of 3D LIDAR sensors employ, while the second solution tends to be a hack done by roboticists. The issue with nodding a LIDAR unit is a drastic reduction of refresh rate, from tens of Hz, down to 1 Hz or less.</p>
<h2><strong>Manufacturers and Uses</strong></h2>
<p>Some of the manufacturers we tend to use are SICK, Hokuyo, and Velodyne.<br />
This is by no means an exhaustive list, just the ones we use most often.</p>
<p><strong>SICK</strong><br />
Most of our LIDARs are made by SICK. Good combo of price, size, rugged build, and software support. Based in Germany</p>
<p><strong>Hokuyo</strong><br />
Generally considered cheaper than SICK, in larger quantities. Some issues with fragility, and software support is not great. Based in Japan</p>
<p><strong>Velodyne</strong><br />
Most expensive, used only when robot MUST see everything in the environment. Based in US.</p>
<p>Once the data is collected, it can be used for a variety of reasons. For robots, these tend to be:</p>
<ul>
<li>Mapping
<ul>
<li>Use the laser data to find out dimensions and locations of obstacles and rooms. This allows the robot to find its position (localisation) and also report dimensions of objects. The title image of this article shows the Clearpath Robotics Jackal mapping a room.</li>
</ul>
</li>
<li>Survey
<ul>
<li>Similar to mapping, however this tends to be outside. The robot collects long range data on geological formations, lakes, etc. This data can then be used to create accurate maps, or plan out mining operations.</li>
</ul>
</li>
<li>Obstacle Avoidance
<ul>
<li>Once an area is mapped, the robot can navigate autonomously around it. However, obstacles that were not mapped (for example, squishy, movable humans) need to be avoided.</li>
</ul>
</li>
<li>Safety Sensors
<ul>
<li>In cases where the robot is very fast or heavy, the sensors can be configured to automatically cut out motor power if the robot gets too close to people. Usually, this is a completely hardware-based feature.</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<h2><strong>Selection Criteria</strong></h2>
<p>A lot of criteria is used to select the best sensor for a given application. The saying goes that an engineer is someone who can do for $1 what any fool can do for $2. Selecting the right sensor for the job not only reduces cost, but also ensures that the robot has the most flexible and useful data collection system.</p>
<ul>
<li>Range
<ul>
<li>How far can laser sensor see? This impacts how fast a robot is able to move, and how well it is able to plan.</li>
</ul>
</li>
<li>Light Sensitivity
<ul>
<li>Can the laser work properly outdoors in full sunlight? Can it work with other lasers shining at it?</li>
</ul>
</li>
<li>Angular Resolution
<ul>
<li>What is the resolution of the sensor? More angular resolution means more chances of seeing small objects.</li>
</ul>
</li>
<li>Field of view
<ul>
<li>What is the field of view? A greater field of view provides more data.</li>
</ul>
</li>
<li>Refresh rate
<ul>
<li>How long does it take the sensor to return to the same point? The faster the sensor is, the faster the robot can safely move.</li>
</ul>
</li>
<li>Accuracy
<ul>
<li>How much noise is in the readings? How much does it change due to different materials?</li>
</ul>
</li>
<li>Size
<ul>
<li>Physical dimensions, but also mounting hardware, connectors, etc</li>
</ul>
</li>
<li>Cost
<ul>
<li>What fits the budget?</li>
</ul>
</li>
<li>Communication
<ul>
<li>USB? Ethernet? Proprietary communication?</li>
</ul>
</li>
<li>Power
<ul>
<li>What voltage and current is needed to make it work?</li>
</ul>
</li>
<li>Mechanical (strength, IP rating)
<ul>
<li>Where is the sensor going to work? Outdoors? In a machine shop?</li>
</ul>
</li>
<li>Safety
<ul>
<li>E-stops</li>
<li>regulation requirements</li>
<li>software vs. hardware safety</li>
</ul>
</li>
</ul>
<p>For example, here is a collected spec sheet of the SICK TIM551.</p>
<table style="height: 593px; width: 476px;" border="1" width="1009">
<tbody>
<tr>
<td width="227">Range (m)</td>
<td width="227">0.05 – 10 (8 with reflectivity below 10%)</td>
</tr>
<tr>
<td width="227">Field of View (degrees)</td>
<td width="227">270</td>
</tr>
<tr>
<td width="227">Angular Resolution (degrees)</td>
<td width="227">1</td>
</tr>
<tr>
<td width="227">Scanning Speed (Hz)</td>
<td width="227">15</td>
</tr>
<tr>
<td width="227">Range Accuracy (mm)</td>
<td width="227">±60</td>
</tr>
<tr>
<td width="227">Spot Diameter (mm)</td>
<td width="227">220 at 10m</td>
</tr>
<tr>
<td width="227">Wavelength (nm)</td>
<td width="227">850</td>
</tr>
<tr>
<td width="227">Voltage (V)</td>
<td width="227">10 – 28</td>
</tr>
<tr>
<td width="227">Power (W) (nominal/max)</td>
<td width="227">3</td>
</tr>
<tr>
<td width="227">Weight (lb/kg)</td>
<td width="227">0.55/0.25</td>
</tr>
<tr>
<td width="227">Durability (poor) 1 – 5 (great)</td>
<td width="227">4 (It is IP67, metal casing)</td>
</tr>
<tr>
<td width="227">Output Interface</td>
<td width="227">Ethernet, USB (non-IP67)</td>
</tr>
<tr>
<td width="227">Cost (USD)</td>
<td width="227">~2,000</td>
</tr>
<tr>
<td width="227">Light sensitivity</td>
<td width="227">This sensor can only be used indoors.</td>
</tr>
<tr>
<td width="227">Other</td>
<td width="227">Can synchronize for multiple sensors.Connector mount rotates nicely.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><hr class="xh2  "><br />
<i>If you liked this article, you may also be interested in:</i></p>
<ul>
<li><a title="ROS 101: Intro to the Robot Operating System" href="http://robohub.org/ros-101-intro-to-the-robot-operating-system/" rel="bookmark" data-wpel-link="internal">ROS 101: Intro to the Robot Operating System</a></li>
<li><a title="ROS 101: A practical example" href="http://robohub.org/ros-101-a-practical-example/" rel="bookmark" data-wpel-link="internal">ROS 101: A practical example</a></li>
<li><a title="Arduino for Makers #1: Setting up a development station" href="http://robohub.org/arduino-for-makers-1-setting-up-a-development-station/" rel="bookmark" data-wpel-link="internal">Arduino for Makers #1: Setting up a development station</a></li>
<li><a title="Arduino for Makers #2: Deconstructing Arduino programs" href="http://robohub.org/arduino-for-makers-2-deconstructing-arduino-programs/" rel="bookmark" data-wpel-link="internal">Arduino for Makers #2: Deconstructing Arduino programs</a></li>
<li><a title="Robots Podcast: Soft Robotics Toolkit, with Donal Holland" href="http://robohub.org/robots-soft-robotics-toolkit/" rel="bookmark" data-wpel-link="internal">Robots Podcast: Soft Robotics Toolkit, with Donal Holland</a></li>
</ul>
<p><i>See all </i><a href="http://robohub.org/" data-wpel-link="internal"><i>the latest robotics news</i></a><i> on Robohub, or </i><a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><i>sign up for our weekly newsletter</i></a><i>.</i></p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Software engineering principles</title>
		<link>https://robohub.org/software-engineering-principles/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Wed, 15 Apr 2015 21:26:09 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/software-engineering-principles/</guid>

					<description><![CDATA[<p>Hi all I have often thought about what the proper software methodology should be for the various robots that I build. My thoughts have evolved over time as I have seen these tool work. I do not have any formal software engineering training, however these are things that I have seen, heard, read, etc.. that [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/software-engineering-principles/" data-wpel-link="external" target="_blank">Software Engineering Principles</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/04/coding-425x283.png" alt="coding" width="425" height="283" class="alignleft size-medium wp-image-48411" srcset="https://robohub.org/wp-content/uploads/2015/04/coding-425x283.png 425w, https://robohub.org/wp-content/uploads/2015/04/coding-450x300.png 450w, https://robohub.org/wp-content/uploads/2015/04/coding.png 900w" sizes="(max-width: 425px) 100vw, 425px" />
<p>I have often thought about what the proper software methodology should be for the various robots that I build. My thoughts have evolved over time as I have seen these tool work. While I do not have any formal software engineering training, these are the common principles that I have seen, heard, read, etc. that I believe in (at 2am while I write this).<span id="more-47939"></span></p>
<div style="clear:both"></div>
<p><em>Disclaimer: Most of the suggestions here have come from other sources. Please check out the links attached for more information.</em></p>
<p>I will start with how to write code, since that is the basis of everything else. After that we will move into the software engineering infrastructure needed to make the software work properly.</p>
<div style="clear:both"></div>
<h2>General Programming Rules</h2>
<p>Without having basic rules that you follow when coding, your code is doomed to fail and be unreliable. Everything else is built upon this. Many people start programming and want to use crazy template magic where everything inherits something else, however you must STOP and write simple code that is easy to understand and test.</p>
<ul>
<li><strong>Keep control structures simple</strong> – Limit your branching, don’t have long nested <em>if, case, and loop</em> statements, no recursive magic.</li>
<li><strong>Endless loops</strong> – Do not use boundless loops unless you really want to be stuck there forever (such as the main loop). Everything else must have an upper/lower bound for exiting the loop. Think more about <em>for</em> loops than <em>while</em> loops.</li>
<li><strong>No dynamic memory</strong> – Forget that <em>malloc</em> exists. It can cause programs to act differently at each run time, and can also add memory leaks that can be hard to detect.</li>
<li><strong>asserts</strong> – Asserts can help you to enforce that the proper thing is helping in each function. I generally do not like the default assert functions that simply cause an exit; sometimes that is appropriate, but in many cases you should try recovering from the error instead of just exiting. You need to evaluate what is the safer approach in your application.</li>
<li><strong>Keep scope</strong> – Try to assign and initialize variables, structures, etc. in as small a scope as possible. This includes limiting your usage of global variables.</li>
<li><strong>Pointers</strong> – Limit your use of pointers when this is easily possible. You should really avoid multiple levels of pointers. They can be very confusing to follow and lead to all sorts of problems if you reference memory addresses that you should not be touching.</li>
<li><strong>Check return value from all (non void) functions</strong> – If a function can (and should be able to) return an error value, make sure to catch it and act on it. It can also be good to check the bounds of a value returned instead of blindly trusting it.</li>
<li><strong>Turn on all compiler warnings</strong> – So you catch things early. This is especially important when formatting text, working with memory, and when bit banging.</li>
<li><strong>Use parentheses to control order of operations</strong> – I have seen many people assume or forget about the proper order of operations. Using parentheses can clarify and enforce the desired result.</li>
<li><strong>Hard coded number</strong> – Please use variables for any value that might need to be changed by a programmer. If you have an even slightly non-obvious number, include a comment about the source of that number and how to derive it.</li>
<li><strong>Preprocesor</strong> – Limit the preprocessor to “simple” things, such as <em>#define</em> and <em>#if</em>. Using complex macros can lead to hard-to-understand code, poor portability, and a increased probability of bugs.</li>
<li><strong>Standards</strong> – Keep your code consistent. This includes naming, white space, and where your curly braces go. This makes it easier to follow the code. If you are editing existing code, use the format of the existing code.</li>
<li><strong>Sleep with <em>noop’s</em> or empty <em>for</em> loops</strong> – These should be avoided since they will run differently on different systems. This is primarily for embedded systems.</li>
<li><strong>Document your code</strong> – Need I say more?</li>
</ul>
<p><strong>Helpful links:</strong><br />
<a href="http://www.eetindia.co.in/ARTICLES/1999DEC/PDF/EEIOL_1999DEC01_EMS_TA_1.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Rules for defensive C programming</a><br />
<a href="http://spinroot.com/gerard/pdf/P10.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">The Power of Ten – Rules for Developing Safety Critical Code</a><br />
<!--Pitfalls for Real-Time Software Developers, <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.133.761&#038;rep=rep1&#038;%23038;type=pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">[Part 1]</a> <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.122.4906&#038;rep=rep1&#038;%23038;type=pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">[Part 2]</a>--></p>
<div style="clear:both"></div>
<h2>Software Repositories</h2>
<p>Having a code repo should be a given for every programmer and programming team. There are many free tools available, so there is no excuse to not use them.</p>
<p>Having a software repository lets you save your code at various points so that you can roll back to prior working versions. Repositories also let you log what was changed in each file and by whom. These tools are a great way to share code with a team &#8211; there is no need to email code back and forth. You can also put documentation in the repo so that is is always available.</p>
<p>There are many options to choose, from cvs, svn, mercurial, git, bitkeeper, etc. Just pick one!</p>
<p>Lately I have been using a hosted repo service called <a href="http://github.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">github.com</a> &#8211; I like all of the tools that are packaged with git on the website. <a href="https://bitbucket.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">bitbucket.org</a> is another similar option.</p>
<p>I generally like to create repositories with the following directories in the root directory:</p>
<ul>
<li><strong>bin</strong> – A place to put all of the binaries after they are compiled. By default this directory should have nothing checked into the repository.</li>
<li><strong>config</strong> – If I have lots of config files I will put them all in this directory.</li>
<li><strong>doc</strong> – Documentation for the system (datasheets, diagrams, notes, etc..)</li>
<li><strong>externals</strong> – Source code and libraries from outside parties (ie. you did not write them)</li>
<li><strong>includes</strong> – Header files that other multiple programs want access to at compile time</li>
<li><strong>libs</strong> – A place to put all of the libraries after they are compiled. By default this directory should have nothing checked into the repository.</li>
<li><strong>src</strong> – This is where all of the code we write should live.</li>
<li><strong>tools</strong> – This is for random “tools” that do not fit anywhere else.</li>
</ul>
<p>In addition to the directories above, I will usually put the main make file for the project and a README in the root directory.</p>
<p><strong>Links:</strong><br />
<a href="http://robotsforroboticists.com/repos/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Software repositories or just plain repo</a></p>
<div style="clear:both"></div>
<h2>Bug/Issue tracking</h2>
<p>Having a central database to track bugs is very important for developing great code that runs bug free. This lets anyone who identifies a bug to report it in such a way that it does not get lost. Just telling the developer or emailing them is not sufficient. People forget things easily. Ideally, you do not want the developer to close a bug; you want somebody to report the bug, the developer to fix it, and then the original person who identified the bug verify that it was properly fixed.</p>
<p>A bug report needs three things:</p>
<ol>
<li>What you expected to happen</li>
<li>What did happen</li>
<li>Steps to reproduce observed behavior (ie bug). Try to minimize the number of steps needed to reproduce error. Include versions of code that you are using.</li>
</ol>
<p><strong>Links:</strong><br />
<a href="http://www.joelonsoftware.com/articles/fog0000000029.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Painless Bug Tracking</a></p>
<div style="clear:both"></div>
<h2>Automated Testing</h2>
<p>Each of your processes/functions should have a set of tests (often called “unit tests”) performed on them to verify functionality. These tests make sure that functions work with various input extremes and combinations. Ideally you should have a test for each possible control path within a function.</p>
<p>For example if you are testing a “sum(number1, number2)” function, you can have the following test file:</p>
<pre>int main () {
assert( 2 = sum(1,1));
assert( 0 = sum(-1,1));
assert( NULL = sum(1,NULL)); // or whatever you want it to be doing…
assert( 0 = sum(0,0));
assert( 1999998 = sum(999999,999999));
assert( 5 = sum(4.2,1)); // assuming integers and that floats are rounded.

RETURN (TRUE);
}
</pre>
<p><em>In this example assert will print an error message about where it failed and exit. (This is just my quick example, and can definitely be expanded and improved. It can also be changed to fail at compile time so that you do not need to “run” it.)</em></p>
<div style="clear:both"></div>
<h2>Automatic (Daily) build system</h2>
<p>Having a build server that builds every time somebody commits code, or at minimum, every night, is valuable for identifying inadvertent bugs introduced into your system and automatically running your tests.</p>
<p>Often you will make a change to one module that will cause another module to fail. But as developers we get focused on our modules and tend to not try recompiling all of the code to make sure that we did not break anything. It is always better to find out you broke something earlier than later.</p>
<p>Certain things tend to cause other modules to break more than others. For example making a change to a widely used header file or message definition file can affect other items.</p>
<p>This also makes programmers only commit code that compiles to the repo and not broken code. If they commit broken code the build tools can/should send out emails to notify people that the build failed (and whose fault it was).</p>
<p>You can either just make a quick script to check out the repo, build it, parse the output and email the results; or you can get a proper build system such as <a href="https://jenkins-ci.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Jenkins</a>. Generally using somebody else’s product will be more reliable and a better use of your time.</p>
<p><strong>Links:</strong><br />
<a href="http://www.joelonsoftware.com/articles/fog0000000023.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Daily Builds Are Your Friend</a></p>
<div style="clear:both"></div>
<h2>Code Reviews</h2>
<p>Code reviews are tough, but they are also one of the best ways to reduce the number of bugs in a piece of software. The traditional code review &#8211; where a person gets up and talks others in the room through the code (that the people have never seen before) &#8211; DOES NOT WORK! This might be good for getting people familiar with the program&#8217;s operation, but it is not the best way to do a code review and find problems.</p>
<p>To do a code review you should have the programmer send a review request to 1-3 other software engineers. The review request should have an overview of the code, a flowchart, and directions to access the code. The number of engineers and the experience level of those engineers should be based on how critical the code it. Each reviewer should:</p>
<ol>
<li>Review the code (obviously) – Don’t dwell on style, you have better things to do with your time.</li>
<li>Develop a list of questions about the code</li>
<li>Write some tests and make sure they pass (these can be committed to always run in the nightly build).</li>
</ol>
<p>Some of things reviewers should watch out for are when reviewing code before a large review:</p>
<ul>
<li>Does the code do what it is supposed to do (and not do what it is not supposed to do)?</li>
<li>Should the code/function be written in a more efficient manner?</li>
<li>Is the control flow simple/clean/good (if, else, return, etc..)?</li>
<li>Do switch statements have a default catch all?</li>
<li>Is the code commented adequately?</li>
<li>Are variables declared at the proper scope (minimizing globals)?</li>
<li>Are there memory leaks?</li>
<li>What happens if things return NULL?</li>
<li>Error/Exception handling</li>
<li>Buffer overflows (doing raw things with char’s, int’s, etc.. memory locations)</li>
<li>Pointer and pointer based math</li>
<li>Array indexing</li>
<li>Closing all handles (files, ports, etc..)</li>
<li>Macro usage</li>
<li>64bit vs 32 bit modifications</li>
<li>Multithreading (is it needed?, number of threads, race points, deadlocks, data passing, priority inversion, etc.)</li>
<li>Operators (precedence and proper usage [ &amp; vs &amp;&amp;, = vs == ])</li>
<li>If input items from users and functions is checked before being used</li>
</ul>
<p>(Did you notice how this list is similar to the good programming practices above?)</p>
<p>After doing the above steps it is now OK to hold the big meeting where people sit down and walk through and review the code; although this is not strictly necessary.</p>
<p>Reviewing code can be hard. Getting your programmers used to reading code and reviewing it will help strengthen their own coding. It can also be useful to have dedicated QA people who review code.</p>
<p><strong>Links:</strong><br />
<a href="http://betterembsw.blogspot.com/2011/11/embedded-system-code-review-checklist.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Embedded System Code Review Checklist</a><br />
<a href="https://msdn.microsoft.com/en-us/library/bb871031.aspx" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Microsoft: Best Practices: Code Reviews</a></p>
<div style="clear:both"></div>
<h2>Build System</h2>
<p>You should be using a build tool so that you are not manually compiling each file. Probably the most common one is <a href="http://en.wikipedia.org/wiki/Make_%28software%29" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">make</a>.</p>
<p>Each make file should have at minimum the following directives:</p>
<ul>
<li><strong>all</strong> – Build all of the production code</li>
<li><strong>clean</strong> – Deletes the binary and object files. This lets the next build be completely clean.</li>
<li><strong>install</strong> – Installs the binaries and libraries into the proper location. This can be a process such as:
<ol>
<li>Copy old binary to &lt;binaryName&gt;_&lt;archivedDateTime&gt;</li>
<li>Copy new binary to location with active processes</li>
</ol>
</li>
<li><strong>test</strong> – Builds a set of unit/system tests that verify operation and make sure bugs were not introduced.</li>
</ul>
<p>I believe you should be able to build, install, test, or clean your entire system with one command. As such I will normally create a make file for each process, and then create one master make file that calls all of the individual make files. Having a single make file that can build everything is good for installing a new system and makes setting up the nightly build easier.</p>
<div style="clear:both"></div>
<h2>Summary</h2>
<ul>
<li>Write good code.</li>
<li>Use a repository service (assuming it is not super sensitive data) such as <a href="https://github.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">github</a> or <a href="https://bitbucket.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">bitbucket</a>. That gives you the repo, the issue tracking, and the ability to easily do code reviews.</li>
<li>Setup a server that builds your repository and runs your tests, at least once a day.</li>
</ul>
<p>Do you have other favorite tools to make your software more reliable? Please leave comments below.</p>
<p><em>Main image based on sample code from wikipedia and hammer from pixabay.com/.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino for Makers #2: Deconstructing Arduino programs</title>
		<link>https://robohub.org/arduino-for-makers-2-deconstructing-arduino-programs/</link>
		
		<dc:creator><![CDATA[Myke Predko]]></dc:creator>
		<pubDate>Thu, 09 Apr 2015 21:42:27 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[Arduino for Makers]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/arduino-for-makers-2-deconstructing-arduino-programs/</guid>

					<description><![CDATA[In this new tutorial series, robotics educator and author Myke Predko introduces you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. In this tutorial, Myke dives into how to program your Arduino so that you can plan an effective software architecture and [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><em><img decoding="async" class="aligncenter size-full wp-image-48158" src="http://robohub.org/wp-content/uploads/2015/04/Simple-Arduino-Pinout.jpg" alt="Simple-Arduino-Pinout" width="800" height="355" srcset="https://robohub.org/wp-content/uploads/2015/04/Simple-Arduino-Pinout.jpg 800w, https://robohub.org/wp-content/uploads/2015/04/Simple-Arduino-Pinout-425x188.jpg 425w, https://robohub.org/wp-content/uploads/2015/04/Simple-Arduino-Pinout-500x221.jpg 500w" sizes="(max-width: 800px) 100vw, 800px" />In this new tutorial series, robotics educator and author Myke Predko introduces you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. In this tutorial, Myke dives into how to program your Arduino so that you can plan an effective software architecture and monitor your application. Look for new tutorials every 2-3 weeks, or see all the tutorials in this series <a href="http://robohub.org/tag/arduino-for-makers/" data-wpel-link="internal">here</a>. </em><br />
<span id="more-48154"></span></p>
<p><em> <img decoding="async" class="aligncenter size-full wp-image-48160" src="http://robohub.org/wp-content/uploads/2015/04/Picture-1-Initial-Arduino-Program-Development-Tool.png" alt="Picture 1 - Initial Arduino Program Development Tool" width="1280" height="720" srcset="https://robohub.org/wp-content/uploads/2015/04/Picture-1-Initial-Arduino-Program-Development-Tool.png 1280w, https://robohub.org/wp-content/uploads/2015/04/Picture-1-Initial-Arduino-Program-Development-Tool-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/04/Picture-1-Initial-Arduino-Program-Development-Tool-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/04/Picture-1-Initial-Arduino-Program-Development-Tool-500x281.png 500w" sizes="(max-width: 1280px) 100vw, 1280px" /></em></p>
<p>Welcome back. In this article, I want to discuss some of the particulars of programming an Arduino so that you better understand what is happening when your program is built. I’ll also discuss how to best architect your software. The Arduino software approach is somewhat unusual compared to other devices and, for beginners at least, takes away the need to do the high level design of the application. As a result, there are a few things to understand and keep in the back of your mind if you want your application to run without anything unexpected happening. In this article, I will provide you with a couple of simple applications to illustrate how Arduino software works, as well as a way to monitor the operation of the application.</p>
<p>In case you found the opening paragraph ominous and were wondering the Arduino is a potential minefield when it comes to software development, let me reassure you that it is as easy to program as any other device I’ve worked with and has been designed to allow for very sophisticated applications. It balances the needs of the beginner and expert application developer quite nicely.</p>
<p>When you’re creating with real time applications (applications that respond to different inputs), the common basic architecture is:</p>
<ul>
<li>System Initialization (“setup()”)
<ul>
<li>Define and initialize system and state variables</li>
<li>Setup hardware interfaces</li>
</ul>
</li>
<li>Repeat input/output processing code (“loop()”)
<ul>
<li>Get inputs</li>
<li>Process inputs with/update system and state variables</li>
<li>Drive outputs</li>
</ul>
</li>
</ul>
<p>The Arduino development software eliminates the need to come up with this program type, instead using the “setup()” and “loop()” methods, which provide this capability for you. As can be seen in Figure 1, when you first start the Arduino development tool or start a new “sketch” .ino (which I usually hear called an “ee-no”) file, the basic code with “setup()” and “loop()”are created – it is now up to you to put in the code for these two methods.</p>
<p>You may have heard that Arduino programming is really C++. However, when you compare example C++ programs to the Arduino .ino code, you will find that though there are some similarities, they really don’t look the same. This is because the .ino code is appended to the end of the C++ file containing the following “main()”:</p>
<pre>#include &lt;Arduino.h&gt;

void setup();
void loop();

int main(void)
{
 setup();

#if defined(USBCON)
USBDevice.attach();
#endif

setup();
for (;;) {
  loop();
  if (serialEventRun) serialEventRun();
 }
 return 0;
}

// user .ino file is appended here
</pre>
<p>In the “main()” code, you can see the calls to the “setup()” and “loop()” methods, along with a few other pieces that need to be explained.</p>
<p>The first is the “#include &lt;Arduino.h&gt;” statement, in which the basic operations provided by the Arduino system are defined. “#include” statements copy in the contents of the specified file before the file is compiled.</p>
<p>Next are the “USBCON” and “USBDevice” statements. These are required if an Arduino USB Host Shield is used in the application. An Arduino USB Host Shield is a shield that enables the Arduino application to be augmented with USB hubs, keyboards, mice, joysticks, thumb drives and other devices.</p>
<p>We will be discussing the “for” statement and looping in a later article, but I wanted to point out that the “for(;;)” statement is a way of creating an infinite loop. When execution reaches this statement, the statements inside the curly braces (“{“ &amp; “}”) that follow will be repeated as long as the Arduino is running.</p>
<p>I will discuss the “Serial Events” in a bit more detail below, but its purpose is to poll the Arduino’s serial communications hardware and perform any necessary operations. This is an important function for helping you to understand how your application is working.</p>
<p>Finally, the “return 0;” statement is put there as a matter of form – execution will never reach it because of the infinite loop above it. Many compilers will flag a warning or an error if a return statement is not at the end of your code, so putting it in will avoid this potential problem.</p>
<p>To demonstrate the operation of the “setup()” and “loop()” methods, I created the <a href="http://robohub.org/wp-content/uploads/2015/04/Console_Test.zip" data-wpel-link="internal">Console_Test</a> application, which you can copy and paste into the Arduino development system:</p>
<pre>// Console_Test - Message from "setup()" and "loop()"
//
// myke predko
void setup() {
 Serial.begin(9600);       // Initialize Serial Library
 Serial.println("Hello world!"); // Output with New Line
}

void loop() {
 Serial.println("Loop Line"); // Output with New Line
}</pre>
<p>This application performs the following actions:</p>
<ul>
<li>Enables “Serial Events”, and outputs a message indicating that it is up and running</li>
<li>Every time the “loop()” method is called, outputs a message</li>
</ul>
<p>To test out this application, start up the Arduino development system and copy the following statements into “setup()”:</p>
<pre>Serial.begin(9600);       // Initialize Serial Library
Serial.println("Hello world!"); // Output with New Line
</pre>
<p>and the following statement into “loop()”:</p>
<pre>Serial.println("Loop Line"); // Output with New Line
</pre>
<p>Next, save the sketch as “Console_Test” and then transfer it to your Arduino using the “Upload” button shown in Figure 1. To see the application running and outputting the messages, click on the “Open Serial Monitor” button at the top right corner of Figure 1. After a few seconds, the Arduino will reset and restart running the application. You will see a display like Figure 2 for a second or so … at least until the repeating “Loop Line” messages cause the “Hello World!” message to scroll off the screen.</p>
<p>The “Serial.begin” statement loads in and starts (“instantiates” in Object Orientated speak) the “Serial” object, which is used for serial communications between the Arduino’s processor and the host PC. Serial communications are set at 9,600 bits per second (bps), which is actually 960 bytes per second (as ten bits are required for sending each byte of data). The “Serial.println” statements send the included string of characters to the host PC.</p>
<p>Serial Events are a great way to show that your application is working and to provide instructions to the Arduino during operation, but there are a couple of things to be wary of.</p>
<p>If you look at the “main()” code above, you will see that Serial Events only execute after a “loop()” operation. In the Arduino, Serial Events are not interrupt-driven; the <em>receive</em> buffer is only checked after a “loop()” and while the <em>send</em> buffer is being transmitted. The hardware receive registers in the ATMega, the processor used in the Arduino, can really only store one byte at a time safely, so the “loop()” code must execute in less time than it takes to receive a single byte (which is 10.4 milliseconds). This is not a major issue but it does mean that you should make your “loop()” code execute as quickly as possible – this is especially true if you work at higher speeds. Normally, I like to have communications at a minimum of 115,200 bps, which means that if I were to run at this communications speed in an Arduino, my “loop()” code must always execute in less than 87 microseconds to avoid the possibility of losing characters.</p>
<p>When you’re starting out, running Arduino “Serial” communications at 9,600 bits per second will probably be fast enough for most applications. As long as you don’t have long delays in your “loop()” code, you should not have any issues.</p>
<p>The second potential issue to watch for is the size of the “Serial” <em>send</em> and <em>receive</em> buffers, which are only 64 bytes in size. These are in software, and are independent of the hardware registers. Sending a message longer than 64 bytes will result in parts of it being “truncated” (cut off) and allowing the <em>receive</em> buffer to grow beyond 64 bytes will result in incoming data being lost. This may seem like an unlikely occurrence, but it can happen if all the bytes in the send message(s) in “setup()” are longer than 64 bytes, as they aren’t sent until “loop()” is first executed. It is possible to increase the size of the “Serial” <em>send</em> and <em>receive</em> buffers, but with a bit of care in your programs, there will be no need to.</p>
<p>While it is not important at this point in time, everything that is loaded into the Arduino is built during the transfer operation. This includes “Libraries” and any other code that you want to bring in to your Sketches. The advantage of doing this is to avoid the need for separate build processes; it also allows the code to be modified easily. You may notice that the time the Arduino development tool takes to compile your application seems unreasonably long – that is because it is going out and getting all possible library and include file code, and compiling it along with your application before building an executable with only the necessary pieces.</p>
<p>I realize that there is a lot of information here. It can all be boiled down to the following statements for the beginning user:</p>
<ol>
<li>Application setup is put in “setup()”</li>
<li>Repeating code for the application is put in “loop()” and must execute as quickly as possible</li>
<li>“Serial” is used for providing information about the execution of a program</li>
</ol>
<p>… but, I wanted to provide background information for individuals who may have had some programming experience on different platforms and wanted to understand how the Arduino works “behind the curtains”. For completely new users, I’m hoping that the information here will help you when you start doing your own applications and things go a bit wonky.</p>
<img decoding="async" class="aligncenter size-full wp-image-48159" src="http://robohub.org/wp-content/uploads/2015/04/Picture-2-Looping-Arduino-Program.png" alt="Picture 2 - Looping Arduino Program" width="663" height="378" srcset="https://robohub.org/wp-content/uploads/2015/04/Picture-2-Looping-Arduino-Program.png 663w, https://robohub.org/wp-content/uploads/2015/04/Picture-2-Looping-Arduino-Program-425x242.png 425w, https://robohub.org/wp-content/uploads/2015/04/Picture-2-Looping-Arduino-Program-175x100.png 175w, https://robohub.org/wp-content/uploads/2015/04/Picture-2-Looping-Arduino-Program-500x285.png 500w" sizes="(max-width: 663px) 100vw, 663px" />
<p><strong>Example Programs:</strong></p>
<ul>
<li><a href="http://robohub.org/wp-content/uploads/2015/04/Console_Test.zip" data-wpel-link="internal">Console_Test</a></li>
</ul>
<p><strong>Next Article:</strong> Arduino Integer Data Types</p>
<p><strong>Websites for Further Reading:</strong></p>
<ul>
<li><a href="http://arduino.cc/en/Hacking/BuildProcess" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/Hacking/BuildProcess</a> “Aduino Build Process” explaining the nuts and bolts of how things go together</li>
<li><a href="https://code.google.com/p/arduino/wiki/BuildProcess" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://code.google.com/p/arduino/wiki/BuildProcess</a> A practical explanation of how the build process works</li>
<li><a href="http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader</a> Arduino Bootloader description and information</li>
<li><a href="http://arduino.cc/en/reference/libraries" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/reference/libraries</a> Arduino Libraries</li>
<li><a href="http://www.instructables.com/id/HOW-TO-use-the-ARDUINO-SERIAL-MONITOR/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.instructables.com/id/HOW-TO-use-the-ARDUINO-SERIAL-MONITOR/</a> How-To use the Arduino Serial Monitor</li>
<li><a href="http://arduino.cc/en/Main/ArduinoUSBHostShield" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/Main/ArduinoUSBHostShield</a> Arduino USB Host Shield</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Dry vs wet, oil vs grease: Choosing the right lubrication for your robot</title>
		<link>https://robohub.org/dry-vs-wet-oil-vs-grease-choosing-the-right-lubrication-for-your-robot/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Fri, 27 Mar 2015 16:34:14 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/dry-vs-wet-oil-vs-grease-choosing-the-right-lubrication-for-your-robot/</guid>

					<description><![CDATA[<p>One thing that is often looked is lubrication (lube). Changing your lubrication and selecting the proper type can dramatically modify the performance of your system. This change of lubrication was one of the primary reasons MSL was delayed from launching to Mars. Improper lubrication can cause your mechanical parts to wear out and fail. It [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/lubrication-oil-grease/" data-wpel-link="external" target="_blank">Lubrication: Dry vs Wet &#8211; Oil vs Grease</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><a href="http://robohub.org/wp-content/uploads/2015/03/grease_gun.jpg" data-wpel-link="internal"><img decoding="async" class="aligncenter size-full wp-image-47572" src="http://robohub.org/wp-content/uploads/2015/03/grease_gun.jpg" alt="grease_gun" width="800" height="395" srcset="https://robohub.org/wp-content/uploads/2015/03/grease_gun.jpg 800w, https://robohub.org/wp-content/uploads/2015/03/grease_gun-425x209.jpg 425w, https://robohub.org/wp-content/uploads/2015/03/grease_gun-500x246.jpg 500w" sizes="(max-width: 800px) 100vw, 800px" /></a>In 2008, the Mars Science Laboratory&#8217;s launch was delayed, in large part <a href="http://www.thespacereview.com/article/1319/1" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">due to issues with lubrication</a>. Lubrication can dramatically impact the performance of your system: improper lubrication can cause your mechanical parts to wear out and fail, and lead to increased power usage and annoying audible sounds. This post looks at the main types of lubrication and where you should use them.<span id="more-47510"></span></p>
<p>Tribology &#8211; the study of friction, wear, and lubrication &#8211; can help us determine the best approach.</p>
<p>Where do you need lubrication (lube) on a robot? The simple answer is: at any joint that moves. In practice this means near actuated joints, bearings, sliders, chains, and in gear boxes. Lube can also be used to reduce rust on metal components.</p>
<p>There are generally two classes of lubrication: wet, and dry (or solid).</p>
<p><strong>Wet</strong> lubes stay “wet” while on the part, which is good for operating in wet/humid conditions. The down side is that dirt can stick to it.</p>
<p><strong>Dry</strong> lube often goes on wet but then dries on the part it has been applied to. Soil particles do not stick to dry lube, but generally it does not last as long as a wet lube and needs to be reapplied more often. That said, dry lubes tends to stay in place a better than wet lubes. The dry lubes are generally more expensive and have lower performance. Dry lubes are usually required for space and vacuum applications to minimize out-gassing.</p>
<p>Another lubrication decision to make is grease vs oil. This is especially true for motor gearboxes.</p>
<p><strong>Grease</strong> adheres better than oil, tends to last longer, and has the added benefit of helping to keep dirt out by acting as a sealant. That said, if a lot of particulate matter gets into the grease, it can compromise the lubricant, so using seals to “hide” the lubricant is a good idea. Grease is thicker than oil when it&#8217;s cold, and can be very hard &#8211; making it difficult to form an effective coating on the parts. It can take a lot of energy to heat up and/or spin a motor when using grease from a cold start, and running with cold grease can be equivalent to running with no lubrication or running with a solid mass in the way. The result is that a cold motor lubricated with grease can draw a higher current that will drop as the grease starts to move, heat up, and form a light coating on the parts.</p>
<p><strong>Oil</strong> is often a better choice if you need to start from a cold temperature and/or want to reduce your current consumption. There is usually an optimal oil viscosity given a mechanical speed and power input, since the viscosity and lubricating effectiveness changes based on the heating effects. Oil often is used at higher speeds because it has a lower viscous drag than grease. There is a continuum of various “weights” in greases and oils across the viscosity spectrum that you can look at when choosing your lube. Oil is also good where lube needs to be circulated through something (examples are for automated lube systems or for transferring heat for thermal management).</p>
<div id="attachment_47571" style="width: 1252px" class="wp-caption aligncenter"><a href="http://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves.jpg" data-wpel-link="internal"><img decoding="async" aria-describedby="caption-attachment-47571" class="size-full wp-image-47571" src="http://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves.jpg" alt="Two plots of different standard engine oil. Showing the viscosity with temperature. (Click for larger image)." width="1242" height="458" srcset="https://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves.jpg 1242w, https://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves-425x156.jpg 425w, https://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves-1024x377.jpg 1024w, https://robohub.org/wp-content/uploads/2015/03/viscosity_vs_temperature_comparison_curves-500x184.jpg 500w" sizes="(max-width: 1242px) 100vw, 1242px" /></a><p id="caption-attachment-47571" class="wp-caption-text">Two plots of different standard engine oil. Showing the viscosity with temperature. (Click for larger image).</p></div>
<p>People often put too much lube on their system. Usually only a thin coat is needed on your moving parts, and any extra globs are generally a waste. Factory systems that require regular lubrication often use automated systems that apply the lube on a schedule.</p>
<p>The above is general information. There are many different types of oil and grease, each with different characteristics. When you really start getting into the details there are all sorts of material compatibilities, corrosion properties, organic vs. synthetic lubes, viscosities, temperatures, speeds, forces, fretting, water displacement film layers, etc.. that you must take into account. If you are too lazy to select a lubricant (and I often am), purchasing a “general purpose” grease or oil will probably give you medium performance, medium viscosity, and medium just about every other parameter.</p>
<p>It is important to note that lubricants can sometimes be avoided in mechanisms (I know I am contradicting what I have said above). Low friction bushing materials like teflon, nylon, rulon-J, bronze, and even steel on steel, are simple options for mechanisms with low-speed joints that can require no lubrication.</p>
<p>Do you know more about lube? Please leave your comments below.</p>
<hr />
<p>I would like to thank Nick for helping me edit this and provide information to improve this article.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MATLAB Robotics System Toolbox and ROS</title>
		<link>https://robohub.org/matlab-robotics-system-toolbox-and-ros/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Thu, 26 Mar 2015 13:17:41 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/matlab-robotics-system-toolbox-and-ros/</guid>

					<description><![CDATA[<p>By Ilia Baranov Recently, Mathworks released a new toolbox for Matlab. This is exciting for a number of reasons: it includes everything from data analysis to coordination of multiple robots. In today&#8217;s post, we explore using this Robotics System Toolbox to connect to both real and virtual Jackal robots. The toolbox has made a number [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/blog/matlab-robotics-system-toolbox-and-ros/" data-wpel-link="external" target="_blank">MATLAB Robotics System Toolbox and ROS</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/" data-wpel-link="external" target="_blank">Clearpath Robotics Inc.</a>.</p>]]></description>
										<content:encoded><![CDATA[<img decoding="async" class="alignleft size-full wp-image-47557" src="http://robohub.org/wp-content/uploads/2015/03/Capture.jpg" alt="Capture" width="849" height="432" srcset="https://robohub.org/wp-content/uploads/2015/03/Capture.jpg 849w, https://robohub.org/wp-content/uploads/2015/03/Capture-425x216.jpg 425w, https://robohub.org/wp-content/uploads/2015/03/Capture-500x254.jpg 500w" sizes="(max-width: 849px) 100vw, 849px" />
<p><em>By Ilia Baranov</em></p>
<p>Recently, Mathworks released a new toolbox for Matlab. This is exciting for a number of reasons: it includes everything from data analysis to coordination of multiple robots. In today’s post, we explore using this Robotics System Toolbox to connect to both real and virtual Jackal robots.<span id="more-47539"></span></p>
<p>The toolbox has made a number of improvements since the “beta” version that we wrote <a title="Introducting Matlab for ROS" href="http://www.clearpathrobotics.com/blog/ros-for-matlab/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">a tutorial on a while ago</a>. Matlab now supports services, parameters, analyzing rosbag data, and has a very robust series of tutorials. They even support generating code in Matlab Simulink, and then having it run on a ROS robot, with no extra downloads needed. This should make development of control algorithms faster for robots, and enable fairly detailed testing outside of ROS.</p>
<p>The following video looks at running a Jackal in circles, in both real and virtual space. It also compares a simple obstacle avoidance program, using lidar, that wanders around the environment.</p>
<p>https://youtu.be/K8_wjMCHQMw</p>
<p>To run the obstacle avoidance sample on a Jackal, ensure that the Matlab Robotics System Toolbox is installed, and download this file: <a title="Jackal_New.m" href="https://s3.amazonaws.com/CPR_PUBLIC/Jackal_New.m" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Jackal_New.m</a></p>
<p>Change the first IP address to your Jackal (real or simulated) and the second to your own computer (the one running Matlab).</p>
<p>If you are ready to try analyzing bag data, download our sample file from the run shown in the video, and plot the laser data.</p>
<p><a title="laserAvoid_Real.bag" href="https://s3.amazonaws.com/CPR_PUBLIC/laserAvoid_Real.bag" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">laserAvoid_Real.bag</a> , <a title="scan_plot.m" href="https://s3.amazonaws.com/CPR_PUBLIC/scan_plot.m" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">scan_plot.m</a></p>
<p>Link to the toolbox:</p>
<p><a href="http://www.mathworks.com/products/robotics/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.mathworks.com/products/robotics/</a></p>
<p>Looking for other Clearpath tutorials? Check <a href="http://robohub.org/archives/authors/clearpath-robotics/" data-wpel-link="internal">these </a>out.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS101: Creating your own RQT Dashboard</title>
		<link>https://robohub.org/ros101-creating-your-own-rqt-dashboard/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Wed, 18 Mar 2015 11:54:23 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/ros101-creating-your-own-rqt-dashboard/</guid>

					<description><![CDATA[<p>By Martin Cote After working in the terminal, gazebo and RViz, it&#8217;s time for a change of pace. For this ROS101 tutorial we&#8217;ll be detailing the basics of creating your own rqt dashboard!&#160;A dashboard is a single rqt window with one or more plugins displayed in movable, re-sizable frames. Dashboards generally consist of a number [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/blog/ros101-creating-rqt-dashboard/" data-wpel-link="external" target="_blank">ROS101: Creating your own RQT Dashboard</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/" data-wpel-link="external" target="_blank">Clearpath Robotics Inc.</a>.</p>]]></description>
										<content:encoded><![CDATA[<a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal"><img decoding="async" class="size-full wp-image-26299" src="http://robohub.org/wp-content/uploads/2014/01/ROS101.jpg" alt="ROS101_Clearpath" width="520" height="260" srcset="https://robohub.org/wp-content/uploads/2014/01/ROS101.jpg 520w, https://robohub.org/wp-content/uploads/2014/01/ROS101-300x150.jpg 300w, https://robohub.org/wp-content/uploads/2014/01/ROS101-500x250.jpg 500w" sizes="(max-width: 520px) 100vw, 520px" /></a>
<p><em>By Martin Cote</em></p>
<p>After working in the terminal, gazebo and RViz, it’s time for a change of pace. For this <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">ROS101 tutorial</a> we’ll be detailing the basics of creating your own rqt dashboard! A dashboard is a single rqt window with one or more plugins displayed in movable, re-sizable frames. Dashboards generally consist of a number of plugins that, in combination, provide a suite of UI capabilities for working with robots and robot data.<span id="more-47342"></span></p>
<p>Dashboards can be populated and configured interactively in an rqt session. A preferred configuration can be saved as a “Perspective,” which saves the plugins loaded, their layout, where they are supported, their settings, and last-saved initial parameters (such as what topic we were last plotting). In this tutorial we’ll be working with the Husky simulation in ROS Indigo. To install ROS Indigo, please see <a title="ROS Wiki" href="http://wiki.ros.org/indigo/Installation/Ubuntu" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">these</a> instructions, and visit our <a title="Husky" href="http://wiki.ros.org/husky_gazebo/Tutorials/Simulating%20Husky" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Husky simulation page</a> to install the Husky simulation.</p>
<h2><strong>Getting Started</strong></h2>
<p>The first step is to install rqt! We’ll also be installing some common plugins to create our dashboard:</p>
<pre>sudo apt-get install ros-indigo-rqt ros-indigo-rqt-common-plugins ros-indigo-rqt-robot-plugins</pre>
<p>We can then launch RQT by simply using:</p>
<pre>rqt</pre>
<p>In the Plugins menu, select each plugin you want to load. You can change the layout by dragging and rescaling each plugin by its title bar or edges.</p>
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/1-Blank-1024x576.png" alt="1-Blank-1024x576" width="1024" height="576" class="alignnone size-full wp-image-47382" srcset="https://robohub.org/wp-content/uploads/2015/03/1-Blank-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/1-Blank-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/1-Blank-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<h2><strong>A practical example</strong></h2>
<p>We’ll now create a rqt dashboard with a few useful plugins and demonstrate a potential use case for this particular dashboard. For this tutorial we’ll be using our virtual Husky to simulate sensor data. Open Husky up in Gazebo using:</p>
<pre>roslaunch husky_gazebo husky_playpen.launch</pre>
<p>You can minimize Gazebo for now as we set up our rqt dashboard. Begin by opening the following plugin from the plugins drop down menu, and re size them as you like,</p>
<p><em>Rviz<br />
Plot x2<br />
Bag<br />
Robot Steering</em></p>
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/1-With-Plugins-1024x576.png" alt="1-With-Plugins-1024x576" width="1024" height="576" class="alignnone size-full wp-image-47383" srcset="https://robohub.org/wp-content/uploads/2015/03/1-With-Plugins-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/1-With-Plugins-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/1-With-Plugins-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p>Each plugin has their own uses and settings, for more information about a particular plugin, visit the <a href="http://wiki.ros.org/rqt/Plugins" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">rqt plugins</a> page of the ROS wiki</p>
<p>When you’re happy with a dashboard configuration, you can save the perspective by selecting Perspectives, Create Perspective, giving it a name, and asking it to clone the current perspective. These perspectives are saved locally and persist between sessions.</p>
<p>To export a perspective for closer management such as sharing or persisting to a repository, select Perspectives, Export and give it a name with the filename extension, .perspective</p>
<h2><strong>Loading a Perspective</strong></h2>
<p>A perspective can be loaded interactively in RQT by selecting Perspectives, import. However a more useful way is to launch them from the command-line, which allows us to wrap them in a script that can be rosrun or roslaunched:</p>
<pre>rqt --perspective-file "$(rospack find my_ros_rqt_package)/config/my_dashboard.perspective"</pre>
<p>Some plugins allow you to configure options that impact its installation and behavior. For example, the Python Console plugin allows you to choose which console implementation to use. You can access these options for any plugin by selecting the gear icon in its title bar. If no gear icon is present, the plugin has not been configured to provide an options menu.</p>
<p><span style="text-decoration: underline;">Rviz:</span> To load Husky into your Rviz plugin, select “open config” from the drop down menu, and navigate to /opt/ros/indigo/share/husky_viz/rviz/view_robot.rviz. You should now see a model of Husky loaded in Rviz! By default, this config file will include the simulated laser, and you can see the object in Husky’s path in the Gazebo environment.</p>
<p>&nbsp;</p>
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/3-load-config-rqt-1024x576.png" alt="3-load-config-rqt-1024x576" width="1024" height="576" class="alignnone size-full wp-image-47384" srcset="https://robohub.org/wp-content/uploads/2015/03/3-load-config-rqt-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/3-load-config-rqt-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/3-load-config-rqt-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/3-with-plugins-Gazebo-1024x576.png" alt="3-with-plugins-Gazebo-1024x576" width="1024" height="576" class="alignnone size-large wp-image-47385" srcset="https://robohub.org/wp-content/uploads/2015/03/3-with-plugins-Gazebo-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/3-with-plugins-Gazebo-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/3-with-plugins-Gazebo-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p><span style="text-decoration: underline;"><strong>Plot</strong>:</span> The Plot tool is very useful to plot a particular topic in real time, for this example we will be plotting the commanded odometery topic versus the simulated odometrey. In the input window on the top right of the plot plugin, add the follow topic in each plot.</p>
<p>/odometry/filtered/twist/twist/angular/z</p>
<p>and</p>
<p>/husky_velocity_controller/odom/twist/twist/angular/z</p>
<p><span style="text-decoration: underline;"><span class="wysiwyg-underline"><strong>Robot Steering</strong>:</span></span> The robot steering plugin provides us with a simple way to manually drive Husky, all that is required is to specify  the  topic which accepts the velocity commands to move your Robot, for virtual Husky, that topic is /cmd_vel.</p>
<p>It’s time to put it together! Try commanding Husky to turn in place using the robot steering plugin, and watch your Husky is RViz turn in place while it’s updating the laser scan! You should also see the commanded odometry in one of your plots, while the actual odometry lags slightly behind as it catches up to the desired value.</p>
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/4-graph-topics-1024x576.png" alt="4-graph-topics-1024x576" width="1024" height="576" class="alignnone size-full wp-image-47386" srcset="https://robohub.org/wp-content/uploads/2015/03/4-graph-topics-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/4-graph-topics-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/4-graph-topics-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p><span style="text-decoration: underline;"><span class="wysiwyg-underline"><strong>Rqt bag</strong>:</span></span> Rosbag is an extremely useful tool  for logging, and our support team may often ask for a bag file to take a closer look at your system. It’s possible to record a bag through the terminal, but using rqt is much simpler and more intuitive. Let’s record  a bag file of Husky driving around by clicking the record button, and selecting the topics you want to record. Once you’re happy with the data recorded, stop the recording.</p>
<p>Playing a bag file back is just as simple. Let’s go ahead and close rqt and Gazebo so ROS is no longer running, then start ROS again with just roscore:</p>
<pre>roscore</pre>
<p>And open rqt back up and load the ROS bag plugin again:</p>
<pre>rqt</pre>
<p>This time we are going to open up the bag file we just recorded by clicking the 2nd button. You’ll now see all the topics that were recorded, and when messages were sent over that topic. You can take a closer look at a particular ticket by right clicking and selecting to view either the values or plot a particular topic.</p>
<p>&nbsp;</p>
<img decoding="async" src="http://robohub.org/wp-content/uploads/2015/03/5-Bag-reply-1024x576.png" alt="5-Bag-reply-1024x576" width="1024" height="576" class="alignnone size-full wp-image-47387" srcset="https://robohub.org/wp-content/uploads/2015/03/5-Bag-reply-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/5-Bag-reply-1024x576-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/5-Bag-reply-1024x576-500x281.png 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p>For more information regarding rqt, please visit the<a href="http://wiki.ros.org/rqt" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"> ROS Wiki </a>page, if you have any questions regarding this particular tutorial, please don’t hesitate to contact us!</p>
<p>Looking for other Clearpath tutorials? <a title="Do more with Udev" href="http://robohub.org/do-more-with-udev/" data-wpel-link="internal">Here’s one</a> you might like! See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino for Makers #1: Setting up a development station</title>
		<link>https://robohub.org/arduino-for-makers-1-setting-up-a-development-station/</link>
		
		<dc:creator><![CDATA[Myke Predko]]></dc:creator>
		<pubDate>Mon, 09 Mar 2015 19:43:44 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[Arduino for Makers]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/arduino-for-makers-1-setting-up-a-development-station/</guid>

					<description><![CDATA[In this new tutorial series, robotics educator and author Myke Predko will introduce you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. Along the way, you will learn how to get the most out of electronics, how to create software that [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><em>In this new <a href="http://robohub.org/tag/arduino-for-makers/" data-wpel-link="internal">tutorial series</a>, robotics educator and author Myke Predko will introduce you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. Along the way, you will learn how to get the most out of electronics, how to create software that is easy to understand and debug, and you will develop the toolset you need to determine whether or not the Arduino is the right choice for your own project, and if so, how to implement it efficiently. The series is for anyone interested in Arduino, from high school students to professional engineers. As a follow up to his <a href="http://robohub.org/arduino-for-makers-0-introduction-to-the-series/" data-wpel-link="internal">introduction to the series</a>, in this tutorial Myke gives directions for setting up your own Arduino development station. Look for new lessons every 2-3 weeks.</em><br />
<span id="more-46942"></span></p>
<p><em> <img decoding="async" class="aligncenter size-full wp-image-46943" src="http://robohub.org/wp-content/uploads/2015/03/Figure-1-Basic-Development-Circuit.png" alt="Figure 1 - Basic Development Circuit" width="1280" height="720" srcset="https://robohub.org/wp-content/uploads/2015/03/Figure-1-Basic-Development-Circuit.png 1280w, https://robohub.org/wp-content/uploads/2015/03/Figure-1-Basic-Development-Circuit-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/Figure-1-Basic-Development-Circuit-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/Figure-1-Basic-Development-Circuit-500x281.png 500w" sizes="(max-width: 1280px) 100vw, 1280px" /></em></p>
<p>Most “getting started” Arduino tutorials start by getting to you build a flashing LED application. While the application I present here is similar, rather than just getting the Arduino’s built-in LED to flash as a “one off” application, we will be setting up the parts and tools for projects that we will implement in the future. While I provide you with the tools to create your first Arduino application, you’ll be preparing for creating your own Arduino-based robots down the line.</p>
<p>Before we get started, let’s talk about some basic electrical rules you will need to understand for this project. Chances are you already know them, but it never hurts to spend a minute and review:</p>
<ol>
<li>Current flows from positive voltage (marked with red) to negative voltage (marked with black, and often referred to as “ground” or “Gnd”).</li>
<li>Current flows through an LED in only one direction (which causes it to light) and the negative connection is normally marked with a flat on its package.</li>
</ol>
<p>As I go on with the article series, I will expand upon these electrical rules, but this is all you have to know for now. If you look at Figure 1 at the start of this article, you will see that positive voltage from the Arduino has a red connection, the negative (Gnd) has a black connection, and the LED has a flat side that indicates for the direction of current flow through the device.</p>
<p>The parts needed for this first iteration of your Arduino development station are:</p>
<ul>
<li><a href="http://www.amazon.com/gp/product/B006H06TVG/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B006H06TVG&amp;linkCode=as2&amp;tag=therobpod-20&amp;linkId=FIACLJYPVX45INUR" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Arduino Uno (R3 or R3 SMD)</a>. When you start out, I recommend that you use the “R3” version with the long rectangular chip in a socket rather than the small, flat square chip. The socketed chip can be replaced if it is ever damaged and it is about $5.00 cheaper.</li>
<li>Breadboard for quickly creating (and taking apart) your circuits.</li>
<li>5mm PTH red LED. This common LED consists of a red “bead” that lights when current passes through it. As noted above, current only flows through an LED in one direction with the negative connection marked with a flat on the side of the package.</li>
<li>100 Ohm, 1/4Watt resistor. This part reduces the current that will flow through the LED. While you can get a single 100 Ohm resistor, I recommend that you get a kit of resistors so that you have a stock of different values that can be applied in different circumstances.</li>
<li>22 gauge wire. This is for connections – it is worth purchasing a breadboard wiring kit with precut and stripped wires for the breadboard.</li>
</ul>
<p>There are many places where these parts can be bought. At the end of the article, I have provided pointers to <a href="https://www.sparkfun.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Sparkfun</a> and their part numbers for the components listed above. Sparkfun is an excellent supplier and one that I feel confident recommending – but I should point out that you may want to explore local electronics shops in your area. None of the components are hard to get and chances are you can buy the components locally for about the same price without having to wait for shipping.</p>
<img decoding="async" class="aligncenter size-full wp-image-46944" src="http://robohub.org/wp-content/uploads/2015/03/Figure-2-Breadboard-internals.png" alt="Figure 2 - Breadboard internals" width="1280" height="720" srcset="https://robohub.org/wp-content/uploads/2015/03/Figure-2-Breadboard-internals.png 1280w, https://robohub.org/wp-content/uploads/2015/03/Figure-2-Breadboard-internals-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/Figure-2-Breadboard-internals-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/Figure-2-Breadboard-internals-500x281.png 500w" sizes="(max-width: 1280px) 100vw, 1280px" />
<p>The “Breadboard” is a type of electronic circuit board in which wires and component leads can be pushed into (and pulled out of) to make simple circuits quickly. As can be seen in Figure 2, the middle holes are connected together vertically while the holes on the outside rows are connected horizontally. I place components in the central area and let the vertical connections connect components together while the horizontal connections are used for “power rails”. Note that I connect the ground power rails on both sides of the breadboard, but only provide power to one side; I will be discussing the reason for this in a future article.</p>
<p>The “5V” and “Gnd” connections from the Arduino to the Breadboard power rails are a convention that I will be using for future articles. This setup allows for fast wiring of application circuitry while allowing for high power devices to be supplied separately and not from the Arduino. Many Arduino applications use its power supply in ways that could lead to burning it out or worse. This wiring convention and reasons behind it will be discussed in future articles.</p>
<p>With the electronics parts together, there are a few tools that I recommend that you buy at this time:</p>
<ul>
<li>Plastic kit box to provide for quick clean up and transportation to other locations. This should have separate compartment for various parts and tools. I like the <a href="http://www.amazon.com/gp/product/B002RL9E16/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B002RL9E16&amp;linkCode=as2&amp;tag=therobpod-20&amp;linkId=PUNO4JWWZIGSFDMS" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Stanley Sortmaster</a> because the compartment separators can be set to allow storage of larger parts, and there is very little chance that the small parts in one compartment will find their way into another.</li>
<li>6’ A-B USB Cable.</li>
<li>Needle nose pliers.</li>
<li>Wire strippers. These can double as wire cutters.</li>
</ul>
<p>All these components can be purchased at a local dollar store. The USB Cable really doesn’t belong as a “tool”, but I wanted to make the point of looking for it at a dollar store – it will be considerably cheaper at a dollar store than at a specialty electronics store.</p>
<p>With the parts and tools available, you can now wire the circuit as shown in Figure 1. The circuit is quite simple: an LED with 100 Ohm resistor is connected to the “5V” output of the Arduino and the Arduino’s pin “3”. When pin “3” outputs a “LOW” voltage, current flows through the LED and it lights. When pin “3” outputs a “HIGH” voltage, current no longer flows through the LED and it no longer lights. This action can be tested by connecting the Arduino to your PC using the USB power (which provides power to the circuit) followed by disconnecting the wire from the Arduino’s pin 3 (the LED’s negative (flat) side) and connecting it to the 5V rail or one of the two Gnd rails on the breadboard.</p>
<p>As a side point, I highly recommend designing your circuits so they can be tested easily without requiring any Arduino software. I guarantee you that it will save hours of wondering why Arduino code doesn’t seem to be working when the real problem is that there is something wrong with the electrical circuit.</p>
<p>With the application built, you’re now ready to create the Arduino code to test everything out. At the end of the article, I have provided the download page for the Arduino software development environment (often called “Arduino Software”) (referred to here as the “Arduino Sketchpad”) and there are specific instructions for installing the software. It can be loaded into Windows PCs, Macs or Linux systems, and just takes a few minutes to install.</p>
<img decoding="async" class="aligncenter size-full wp-image-46945" src="http://robohub.org/wp-content/uploads/2015/03/Figure-3-Arduino-Sketchpad.png" alt="Figure 3 - Arduino Sketchpad" width="1280" height="720" srcset="https://robohub.org/wp-content/uploads/2015/03/Figure-3-Arduino-Sketchpad.png 1280w, https://robohub.org/wp-content/uploads/2015/03/Figure-3-Arduino-Sketchpad-425x239.png 425w, https://robohub.org/wp-content/uploads/2015/03/Figure-3-Arduino-Sketchpad-1024x576.png 1024w, https://robohub.org/wp-content/uploads/2015/03/Figure-3-Arduino-Sketchpad-500x281.png 500w" sizes="(max-width: 1280px) 100vw, 1280px" />
<p>The Arduino Sketchpad’s many options can be somewhat overwhelming to new users, and for that reason, I suggest that beginners focus on the five icons that are labeled in Figure 3; these are the only controls that will be required for quite a while.</p>
<p>When you have your Arduino Sketchpad up and running, cut and paste in the following program:</p>
<pre>// flash - Flash LED on Pin 3
//
// myke predko


void setup() {
 pinMode(3, OUTPUT); // Make Pin 3 an Output
}


void loop() {
 digitalWrite(3, HIGH); // Pin 3 is high voltage (LED off)
 delay(250); // Wait 1/4s
 digitalWrite(3, LOW); // Pin 3 is low voltage (LED ON)
 delay(250); // Wait 1/4s
}
</pre>
<p>Then, click the “Save Sketch” icon to save the Sketch (which is what the Arduino application is called), and then click on the “Transfer to Arduino” (aka “Upload”). After a few seconds, you will get the “Done uploading” message and the LED should start flashing (if it doesn’t then use the hint above for debugging the application – chances are you have the LED orientated the wrong way or the resistor connected to the wrong power rail).</p>
<p>Now, you have a working Arduino development station. I know it doesn’t seem like much right now, but in the coming weeks, we’ll look at using this as a base for learning more about Arduino and creating your own robots.</p>
<p><strong>Further Reading:</strong></p>
<ul>
<li><a href="http://arduino.cc/en/main/software" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/main/software</a> Arduino Software Download Page</li>
<li><a href="http://forum.arduino.cc/index.php?board=2.0" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://forum.arduino.cc/index.php?board=2.0</a> Arduino “Installation &amp; Troubleshoot” Forum</li>
<li><a href="http://www.ladyada.net/learn/arduino/lesson1.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.ladyada.net/learn/arduino/lesson1.html</a> First project tutorial</li>
<li><a href="http://electronicsclub.info/leds.htm" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://electronicsclub.info/leds.htm</a> Introduction to Light Emitting Diodes (LEDs)</li>
<li><a href="http://www.electronics-tutorials.ws/resistor/res_9.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.electronics-tutorials.ws/resistor/res_9.html</a> Resistor Tutorial and Summary</li>
</ul>
<p><strong>Parts:</strong></p>
<ul>
<li><a href="https://www.sparkfun.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/</a> for parts:
<ul>
<li><a href="https://www.sparkfun.com/products/11021" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/products/11021</a> Arduino Uno &#8211; R3</li>
<li><a href="https://www.sparkfun.com/products/9590" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/products/9590</a> LED &#8211; Basic Red 5mm</li>
<li><a href="https://www.sparkfun.com/products/10969" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/products/10969</a> 1/4W Resistor Kit</li>
<li><a href="https://www.sparkfun.com/products/9567" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/products/9567</a> Breadboard &#8211; Translucent</li>
<li><a href="https://www.sparkfun.com/products/124" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.sparkfun.com/products/124</a> Jumper Wire Kit</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<p><strong>Previous Article: </strong><a href="http://robohub.org/arduino-for-makers-0-introduction-to-the-series/" data-wpel-link="internal">Arduino for Makers #0: Introduction to the series</a><strong><br />
</strong><strong>Next Article:</strong> Arduino Programing deconstructed</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Selecting a camera and lens for your robot</title>
		<link>https://robohub.org/selecting-a-camera-and-lens-for-your-robot/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Thu, 26 Feb 2015 20:38:15 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Vision]]></category>
		<guid isPermaLink="false">http://robohub.org/selecting-a-camera-and-lens-for-your-robot/</guid>

					<description><![CDATA[<p>Choosing a camera can be confusing. It is important to determine your requirements and then figure out how to achieve that between the camera and the optics. The first thing that most people talk about is resolution. The classic resolution of a camera is based on pixels; such as 600 pixels x 400 pixels. The [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/camera-lens-selection/" data-wpel-link="external" target="_blank">Camera &#38; Lens Selection</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<div id="attachment_46597" style="width: 1034px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-46597" class="wp-image-46597 size-large" src="http://robohub.org/wp-content/uploads/2015/02/ids_usb3-1024x640.jpg" alt="IDS Imaging Development Systems - USB3 Vision industrial cameras" width="1024" height="640" srcset="https://robohub.org/wp-content/uploads/2015/02/ids_usb3-1024x640.jpg 1024w, https://robohub.org/wp-content/uploads/2015/02/ids_usb3-425x265.jpg 425w, https://robohub.org/wp-content/uploads/2015/02/ids_usb3-479x300.jpg 479w, https://robohub.org/wp-content/uploads/2015/02/ids_usb3.jpg 1100w" sizes="(max-width: 1024px) 100vw, 1024px" /><p id="caption-attachment-46597" class="wp-caption-text">IDS Imaging Development Systems &#8211; USB3 Vision industrial cameras</p></div>
<p>Choosing a camera can be confusing. It is important to determine your requirements, and then figure out how these can be achieved between the camera and the optics.<span id="more-46116"></span></p>
<p>The first thing that most people talk about is <b>resolution</b>. The classic resolution of a camera is based on pixels (e.g.600 pixels x 400 pixels). The other type of resolution we must talk about is the <b>spatial resolution</b>. The spatial resolution is how close the pixels are to each other; or how many pixels-per-inch (ppi) is on the sensor. In practice it is the spatial resolution that really controls how an image will look. Sometimes the spatial resolution is measured in micrometers. When we use a lens on the camera, this effective resolution can change.</p>
<p>After determining the resolution requirements you should look at the <strong>focal length</strong>. The focal length you choose depends on what zoom level you need. A larger focal length (such as 200) will be zoomed in, a focal length of 30-50 is about what we see with our eyes, and a smaller focal length (such as 10) will be zoomed out and you will see a larger picture (lenses with small focal lengths are often called a wide-angle lenses). An extreme example of a small focal length is a fish-eye lens that can see around 180° (with a fairly distorted image). If the focal length is specified as a range, it is probably an adjustable zoom lens.<br />
<a href="http://www.nikonusa.com/en/Learn-And-Explore/Article/g3cu6o2o/understanding-focal-length.html#!" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><img decoding="async" class="aligncenter size-full wp-image-3794" src="http://i1.wp.com/robotsforroboticists.com/wordpress/wp-content/uploads/2015/02/focal_length_nikon.jpg?resize=600%2C404" alt="focal length sequence" data-recalc-dims="1" /></a></p>
<p>The next thing to look at is the <b>Maximum Aperture</b> or <b>f number</b>. The f number is often specified as f/2.8 or F2.8. The larger the number, the less light that can enter into the aperture. If you need to take images in a low light condition you will want a small f number to avoid needing external lighting of the scene. The smaller the f number, the shallower the <b>depth of field</b> will be. The depth of field is the part of the image that appears in focus (and sharp).</p>
<div id="attachment_3793" style="width: 330px" class="wp-caption alignleft"><a href="http://i0.wp.com/robotsforroboticists.com/wordpress/wp-content/uploads/2015/02/320px-Aperture_diagram_wikipedia.png" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><img decoding="async" aria-describedby="caption-attachment-3793" class="wp-image-3793 size-full" src="http://i0.wp.com/robotsforroboticists.com/wordpress/wp-content/uploads/2015/02/320px-Aperture_diagram_wikipedia.png?resize=320%2C127" alt="f numbers and aperture size" width="320" height="127" data-recalc-dims="1" /></a><p id="caption-attachment-3793" class="wp-caption-text">F-numbers. Each step is allows half the light as the preceding step.</p></div>
<p>Arguably this should have been mentioned first, but you will also need to look at the <b>Field of View</b> or <b>FOV</b>. The FOV is the angular measurement window that can be seen by the lens. The FOV is usually specified with two numbers, such as 60° X 90°. In this case 60° is the horizontal FOV and 90° is the vertical FOV. Sometimes instead of giving 2 numbers people will just specify 1 number based on the diagonal. FOV can be related to the focal length of the lens.</p>
<p>We can compute the FOV by knowing the size of the camera imaging array (ie CCD) from the datasheet and the focal length of the lens.</p>
<div class="minitext" style="border: 2px solid #ccc; padding: 10px; color: #000;">
<img decoding="async" class="latex" title="FOV = 2 \, * \, arctan (\frac{CCD\, size}{focal\, length\, of\, lens})" src="http://s0.wp.com/latex.php?latex=FOV+%3D+2+%5C%2C+%2A+%5C%2C+arctan+%28%5Cfrac%7BCCD%5C%2C+size%7D%7Bfocal%5C%2C+length%5C%2C+of%5C%2C+lens%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="FOV = 2 \, * \, arctan (\frac{CCD\, size}{focal\, length\, of\, lens})" />
<p>So for a 36 X 24mm sensor size and a focal length of 50mm, we can get the following camera FOV’s:</p>
<p><img decoding="async" class="latex" title="X \,direction \,FOV:\, 39.6 = 2 \, * \, arctan (\frac{36}{50})" src="http://s0.wp.com/latex.php?latex=X+%5C%2Cdirection+%5C%2CFOV%3A%5C%2C+39.6+%3D+2+%5C%2C+%2A+%5C%2C+arctan+%28%5Cfrac%7B36%7D%7B50%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="X \,direction \,FOV:\, 39.6 = 2 \, * \, arctan (\frac{36}{50})" /><br />
<img decoding="async" class="latex" title="Y\, direction\, FOV:\, 27 = 2\, * \, arctan (\frac{24}{50})" src="http://s0.wp.com/latex.php?latex=Y%5C%2C+direction%5C%2C+FOV%3A%5C%2C+27+%3D+2%5C%2C+%2A+%5C%2C+arctan+%28%5Cfrac%7B24%7D%7B50%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Y\, direction\, FOV:\, 27 = 2\, * \, arctan (\frac{24}{50})" /></p>
</div>
<p>To calculate the image (or camera) resolution required based on a specific lens FOV to detect a certain size obstacle there is a simple equation.</p>
<div class="minitext" style="border: 2px solid #ccc; padding: 10px; color: #000;">
<img decoding="async" class="latex" title="Sensor\, Resolution = Image\, Resolution = 2 \,*\, \frac{Viewing\, Area}{Smallest\, Feature} " src="http://s0.wp.com/latex.php?latex=Sensor%5C%2C+Resolution+%3D+Image%5C%2C+Resolution+%3D+2+%5C%2C%2A%5C%2C+%5Cfrac%7BViewing%5C%2C+Area%7D%7BSmallest%5C%2C+Feature%7D+&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Sensor\, Resolution = Image\, Resolution = 2 \,*\, \frac{Viewing\, Area}{Smallest\, Feature} " />
</div>
<p>So for example if your lens has a FOV of 60°x90°, the working distance from the sensor (ie where the camera hits the target) is 2meters away, and the smallest obstacle that you need to be able to detect (with a minimum of 2 pixels on it) is 0.01meters:</p>
<div class="minitext" style="border: 2px solid #ccc; padding: 10px; color: #000;">
<p>First we need the size of the area viewed, on the plane at the working distance in each direction. Simply put, based on the FOV angle and a distance what is the length of the side opposite the lens.</p>
<p><img decoding="async" class="latex" title="Viewing\, Area = 2 \,*\, working \,distance \,*\, tan(\frac{FOV}{2})" src="http://s0.wp.com/latex.php?latex=Viewing%5C%2C+Area+%3D+2+%5C%2C%2A%5C%2C+working+%5C%2Cdistance+%5C%2C%2A%5C%2C+tan%28%5Cfrac%7BFOV%7D%7B2%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Viewing\, Area = 2 \,*\, working \,distance \,*\, tan(\frac{FOV}{2})" /><br />
<img decoding="async" class="latex" title="X\, direction\, viewing \,area: 2.3m = 2 \,*\, 2m \,*\, tan(\frac{60}{2})" src="http://s0.wp.com/latex.php?latex=X%5C%2C+direction%5C%2C+viewing+%5C%2Carea%3A+2.3m+%3D+2+%5C%2C%2A%5C%2C+2m+%5C%2C%2A%5C%2C+tan%28%5Cfrac%7B60%7D%7B2%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="X\, direction\, viewing \,area: 2.3m = 2 \,*\, 2m \,*\, tan(\frac{60}{2})" /><br />
<img decoding="async" class="latex" title="Y\, direction\, viewing\, area: 4m = 2 \,*\, 2m \,*\, tan(\frac{90}{2})" src="http://s0.wp.com/latex.php?latex=Y%5C%2C+direction%5C%2C+viewing%5C%2C+area%3A+4m+%3D+2+%5C%2C%2A%5C%2C+2m+%5C%2C%2A%5C%2C+tan%28%5Cfrac%7B90%7D%7B2%7D%29&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Y\, direction\, viewing\, area: 4m = 2 \,*\, 2m \,*\, tan(\frac{90}{2})" /></p>
<p>Now that we know the viewing area on our working plane, we can compute the sensor resolution:</p>
<p><img decoding="async" class="latex" title="Sensor\, Resolution = Image\, Resolution = 2 \,X\, \frac{Viewing\, Area}{Smallest\, Feature} " src="http://s0.wp.com/latex.php?latex=Sensor%5C%2C+Resolution+%3D+Image%5C%2C+Resolution+%3D+2+%5C%2CX%5C%2C+%5Cfrac%7BViewing%5C%2C+Area%7D%7BSmallest%5C%2C+Feature%7D+&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Sensor\, Resolution = Image\, Resolution = 2 \,X\, \frac{Viewing\, Area}{Smallest\, Feature} " /><br />
<img decoding="async" class="latex" title="X\, direction\, sensor\, resolution\, required:\, 460 = 2 \,*\, \frac{2.3m}{0.01m} " src="http://s0.wp.com/latex.php?latex=X%5C%2C+direction%5C%2C+sensor%5C%2C+resolution%5C%2C+required%3A%5C%2C+460+%3D+2+%5C%2C%2A%5C%2C+%5Cfrac%7B2.3m%7D%7B0.01m%7D+&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="X\, direction\, sensor\, resolution\, required:\, 460 = 2 \,*\, \frac{2.3m}{0.01m} " /><br />
<img decoding="async" class="latex" title="Y\, direction\, sensor\, resolution\, required:\, 800 = 2 \,*\, \frac{4m}{0.01m} " src="http://s0.wp.com/latex.php?latex=Y%5C%2C+direction%5C%2C+sensor%5C%2C+resolution%5C%2C+required%3A%5C%2C+800+%3D+2+%5C%2C%2A%5C%2C+%5Cfrac%7B4m%7D%7B0.01m%7D+&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Y\, direction\, sensor\, resolution\, required:\, 800 = 2 \,*\, \frac{4m}{0.01m} " /></p>
</div>
<p>So we now know that when we choose a camera it must have a minimum resolution of 460 X 800 to meet the requirement of seeing a 0.01m item from 2m away.</p>
<p>We can also look at the working distance and how that affects other camera/lens parameters.</p>
<div class="minitext" style="border: 2px solid #ccc; padding: 10px; color: #000;">
<img decoding="async" class="latex" title="Focal\, Length \,*\, Viewing\, Area = Sensor\, Size \,*\, Working\, Distance" src="http://s0.wp.com/latex.php?latex=Focal%5C%2C+Length+%5C%2C%2A%5C%2C+Viewing%5C%2C+Area+%3D+Sensor%5C%2C+Size+%5C%2C%2A%5C%2C+Working%5C%2C+Distance&amp;bg=ffffff&amp;%23038;fg=000&amp;%23038;s=0" alt="Focal\, Length \,*\, Viewing\, Area = Sensor\, Size \,*\, Working\, Distance" />
</div>
<p>In many cases the focal length and the sensor size are fixed. So we can then look at how changing the viewing area or changing the working distance affects each other. On other cameras the focal length is adjustable and we can also look at how changing that affects the other parameters.</p>
<div id="attachment_46601" style="width: 710px" class="wp-caption alignleft"><img decoding="async" aria-describedby="caption-attachment-46601" class="wp-image-46601 size-full" src="http://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia.jpg" alt="vignetting_wikipedia" width="700" height="705" srcset="https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia.jpg 700w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-421x425.jpg 421w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-100x100.jpg 100w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-297x300.jpg 297w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-32x32.jpg 32w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-64x64.jpg 64w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-96x96.jpg 96w, https://robohub.org/wp-content/uploads/2015/02/vignetting_wikipedia-128x128.jpg 128w" sizes="(max-width: 700px) 100vw, 700px" /><p id="caption-attachment-46601" class="wp-caption-text">Note the vignetting at the corners of the image.</p></div>
<p>With all lenses, and particularly with cheaper (&lt;$150) lenses, distortion and vignetting can be a big problem. Common distortion modes are where the X or Y axis appears to no longer be straight and perpendicular with each other (rectilinear). Often you will see an image look wavy or bulging. With vignetting the edges and particularly the corners become darkened. You can often reverse the effects of warping by using a <a href="http://en.wikipedia.org/wiki/Image_rectification" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">homography for image rectification</a>.</p>
<p>With any lens and camera system you need to check the mount types. There are many different styles for mounting a lens to a camera. Wikipedia has a long list of mounts that can be found <a href="http://en.wikipedia.org/wiki/Lens_mount" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">here</a>. The most common mount that I have seen for computer vision cameras (ie. no viewfinder and designed for machine vision applications) is the <b>C</b> mount. Choose a lens that you can lock into place. Not only should you be able to lock the lens into place you should be able to lock any rotating knobs into place (such as for zoom and focus). This is usually accomplished with set screws. I am not that familiar with them but I will note that there are many different filters that can be attached to your lens for things such as polarization and blocking certain parts of the spectrum (such as IR). Your iPhone camera typically has a built in IR filter in the lens to remove IR components from your images.</p>
<div class=" "><iframe title="Understanding Camera Mounting Interfaces" width="500" height="281" src="https://www.youtube-nocookie.com/embed/QlSULbRSai8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p></p>
<p>Another semi-obvious thing to look into is whether you need a black and white (often expressed as B&amp;W, BW, or B/W) or color camera. In many cases B/W cameras will be easier for your algorithms to process. However having color can give you more channels for humans to look at and for algorithms to learn from. In addition to black and white, there are hyper spectral cameras that let you see various frequency bands. Some of the common spectral ranges that you might want are ultra-violet (UV), near-infrared (NIR), visible near-infrared (VisNIR), and infrared (IR). You will also want to pay attention to the <b>Dynamic Range</b> of the camera. The larger the dynamic range, the greater the light difference that can be handled within an image. If the robot is operating outdoors in sun and shade you might want to consider a <b>high dynamic range (HDR)</b> camera.</p>
<img decoding="async" class="aligncenter size-large wp-image-3799" src="http://i0.wp.com/robotsforroboticists.com/wordpress/wp-content/uploads/2015/02/EM_spectrum_wikipedia.png" alt="light spectrum" data-recalc-dims="1" />
<p>You will also want to consider the interface you have to the camera &#8211; both the electrical and software interface. On the electrical side, the common camera protocols are camera-link, USB2.0, USB3, firewire (IEEE1394), and gigabit ethernet (GigE). GigE cameras are nice since they just plug into an ethernet port making wiring easy. Many of them can use power-over-ethernet (PoE) so the power goes over the ethernet cable and you only have one cable to run. The downside of GigE is the latency and non deterministic nature of ethernet. The other interfaces might be better if latency is a problem. Also, you generally can only send full video over GigE with a wired connection, and not from a wireless connection. This is because you need to set the ethernet port to use jumbo packets, which can not be done on a standard wireless connection. Probably the most common reason I see GigE cameras not working properly is that the ethernet port on the computer is not configured for jumbo packets. For software, you want to make sure that your camera has an SDK that will be easy for you to use. If you are using ROS or OpenCV, you will want to verify that the drivers are good. You will also want to check what format the image is supplied back to you from the camera: will it be a <a href="http://en.wikipedia.org/wiki/Raw_image_format" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">raw image format</a>? or will it be a file format such as png of jpg?</p>
<p>If you are doing stereo vision, you want to make sure the cameras have a <b>triggering</b> method, so that when you issue an image capture command you get images from both cameras simultaneously. The triggering can be in software or hardware, but hardware is typically better and faster. If you are having problems with your stereo algorithm this can be the source of the problem, especially if you are moving fast.</p>
<p>Finally, if you are looking for video, you also need to look out for the <b>Frame Rate</b> typically specified in <b>Frames per Second (fps)</b>. This refers to how many images the camera can take in a second. We can then call that sequence of images a video.</p>
<p>Hope this helps. If you have camera experiences you would like to share &#8211; especially related to good/bad SDKs and what works/doesn&#8217;t-work with ROS &#8211; please share in the comments below.</p>
<div class="divideronpost"></div>
<p>While writing this post I saw <a href="http://en.wikipedia.org/wiki/Machine_vision" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span class="s1">Wikipedia</span></a> said “MV is related to, though distinct from, computer vision.” This surprised me as I always viewed machine vision and computer vision to be similar fields, just different terms used in different industries. So I followed the references and found an interesting article from <i>Bruce Batchelor</i> <a href="http://ece631web.groups.et.byu.net/References/Machine-Computer%20Vision.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span class="s1">here</span></a>. After reading his article I am still not sure if I agree. I think there are people who are theorists that only care about the vision aspects, there are integrator’s who only care about the system and don’t know much about the vision aspects. However there is also a large segment in the middle, such as roboticists, that care about both sides of the problem. Working in robotics you need to care about the real world applications while also understanding the vision problems and develop new vision methods and techniques.</p>
<p>As roboticists are we doing both? are we only doing computer vision? only machine vision? What do you think? Leave your comments below.</p>
<div class="divideronpost"></div>
<p>For optics and some good technical notes you can visit <a href="http://www.edmundoptics.com/technical-resources-center/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span class="s1">Edmund Optics</span></a>. They have a large supply of everything optics related.</p>
<div class="divideronpost"></div>
<p>Sources:</p>
<ul>
<li><a href="http://www.gizmag.com/camera-lens-buying-guide/29141/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.gizmag.com/camera-lens-buying-guide/29141/</a></li>
<li><a href="http://vitaleartconservation.com/PDF/affects_of_lens_quality_on_image_resolution_v3a_draft.pdf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://vitaleartconservation.com/PDF/affects_of_lens_quality_on_image_resolution_v3a_draft.pdf</a></li>
<li><a href="http://www.gizmag.com/camera-lens-buying-guide/29141/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.gizmag.com/camera-lens-buying-guide/29141/</a></li>
<li><a href="http://digital.ni.com/public.nsf/allkb/1948AE3264ECF42E86257D00007305D5" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://digital.ni.com/public.nsf/allkb/1948AE3264ECF42E86257D00007305D5</a></li>
<li><a href="http://www.nikonusa.com/en/Learn-And-Explore/Article/g3cu6o2o/understanding-focal-length.html#!" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.nikonusa.com/en/Learn-And-Explore/Article/g3cu6o2o/understanding-focal-length.html#!</a></li>
<li><a href="http://en.wikipedia.org/wiki/Angle_of_view" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://en.wikipedia.org/wiki/Angle_of_view</a></li>
</ul>
<div class="divideronpost"></div>
<p><em><em>If you liked this article, you may also be interested in:</em></em></p>
<ul>
<li><a title="Permanent Link: Things to think about when transporting your robot" href="http://robohub.org/things-to-think-about-when-transporting-your-robot/" rel="bookmark" data-wpel-link="internal">Things to think about when transporting your robot</a></li>
<li><a title="Permanent Link: Controlling a brushless DC motor with no encoders" href="http://robohub.org/controlling-a-brushless-dc-motor-with-no-encoders/" rel="bookmark" data-wpel-link="internal">Controlling a brushless DC motor with no encoders</a></li>
<li><a title="UMich team works on perception and localization using cameras" href="http://robohub.org/umich-team-works-on-perception-and-localization-using-cameras/" rel="bookmark" data-wpel-link="internal">UMich team works on perception and localization using cameras</a></li>
<li><a title="Multi-viewpoint robotic camera system creates real ‘bullet time’ slow motion replays" href="http://robohub.org/multi-viewpoint-robotic-camera-system-creates-real-bullet-time-slow-motion-replays/" rel="bookmark" data-wpel-link="internal">Multi-viewpoint robotic camera system creates real ‘bullet time’ slow motion replays</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino for Makers #0: Introduction to the series</title>
		<link>https://robohub.org/arduino-for-makers-0-introduction-to-the-series/</link>
		
		<dc:creator><![CDATA[Myke Predko]]></dc:creator>
		<pubDate>Wed, 25 Feb 2015 21:06:14 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[Arduino for Makers]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/arduino-for-makers-0-introduction-to-the-series/</guid>

					<description><![CDATA[In this new tutorial series, robotics educator and author Myke Predko will introduce you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. Along the way, you will learn how to get the most out of electronics, how to create software that [&#8230;]]]></description>
										<content:encoded><![CDATA[<div id="attachment_46551" style="width: 854px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-46551" class="wp-image-46551 size-full" src="http://robohub.org/wp-content/uploads/2015/02/Arduino_pinouts.jpg" alt="Arduino_pinouts" width="844" height="546" srcset="https://robohub.org/wp-content/uploads/2015/02/Arduino_pinouts.jpg 844w, https://robohub.org/wp-content/uploads/2015/02/Arduino_pinouts-425x274.jpg 425w, https://robohub.org/wp-content/uploads/2015/02/Arduino_pinouts-463x300.jpg 463w" sizes="(max-width: 844px) 100vw, 844px" /><p id="caption-attachment-46551" class="wp-caption-text">Arduinio Pinouts</p></div>
<p><em>In this new tutorial series, robotics educator and author Myke Predko will introduce you to the basics of Arduino with simple projects that can be created in just a few minutes with inexpensive and easy-to-obtain parts. Along the way, you will learn how to get the most out of electronics, how to create software that is easy to understand and debug, and you will develop the toolset you need to determine whether or not the Arduino is the right choice for your own project, and if so, how to implement it efficiently. </em></p>
<p><em>The series is for anyone interested in Arduino, from high school students to professional engineers. In this introduction, Myke gives an overview of the benefits – and limitations – of using Arduino for your project. Look for new tutorials every 2-3 weeks. </em><span id="more-46549"></span></p>
<p>People who know me know that I have a love-hate relationship with Arduino.</p>
<p>The Arduino concept is brilliant: it’s a very low-cost open source and open hardware platform that is quick and easy to connect to. Arduino is very flexible: software applications use “C” syntax for commonality and are easy to enhance with “libraries” for specific interfaces and Input/Output (IO) devices. The development tools are available for just about every system out there and they do provide extension paths for the development tools. There are a number of different Arduino devices, each with different features that optimize them for different applications as well as a plethora of “shields” that allow users to hook up various devices quickly and (for the most part) easily.</p>
<p>These core features and philosophies have resulted in Arduino becoming the <em>de facto</em> standard for intelligent projects – there are so many well-documented Arduino projects out there that if you’re not comfortable with programming, chances are you will be able to find a project that uses the exact same (or at least very similar and easily changeable) devices as the ones you would like to use. Nobody could ever fault you for starting your project with an Arduino.</p>
<p>On the other side of the equation, there are some things I dislike about Arduino, however: its 8-bit processor, its schizophrenic design tools, its inability to do meaningful application debug, and the expectation on the part of many new developers that using Arduino means they are 80% of the way towards having a product ready for market.</p>
<p>To expand on these issues:</p>
<ol>
<li>In 2015, <strong>nothing</strong> should be controlled by an 8-bit processor. If you take a quick look at <a href="http://www.digikey.com/catalog/en" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Digi-Key</a>, you will find 32-bit Cortex M series processors from a variety of manufacturers that have more memory and peripherals while running a considerably faster speeds for the same cost (or less) than the ATmega used in the Arduino. I’m pointing out the Cortex processors (that, I should point out, are being used in the Arduino Duo board) because code can be passed between devices, giving a lot more freedom when choosing devices for a given application (which would extend the “open source”, “open hardware” concept even further).</li>
<li>The standard Arduino development tool was designed for both the new user as well as the experienced one, and I don’t think it is well suited for anybody. I believe that a new developer should have as simple a development tool as possible, with only the required controls in front of them. As an experienced programmer, I revel in using Eclipsed-based development tools where I have 500+ options at my disposal.</li>
<li>Going with my comment regarding the widespread availability of 32-bit processors, I also feel that the lack of a source code level debugger with stepping and breakpoints is a serious deficiency in the Arduino. These are features that I have been working with for more than thirty years, and I consider this to be a major oversight. In this tutorial series, I will share techniques that will help you understand and debug your Arduino applications.</li>
<li>Just about every Arduino presentation I have ever seen has stated that one of its advantages is that it can be used in commercial products. To test out this assertion, I googled “<a href="https://www.google.ca/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=Arduino+used+in+commercial+products" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Arduino used in commercial products</a>,” and much to my surprise, I discovered that almost all the top ranked websites focused on why Arduino <strong>isn’t </strong>used in commercial products. <br /><BR>There is one notable exception to Arduino’s not being used in commercial products “as is” – and that is 3D printers. There are many shields available that make the interfacing to the different components of a 3D printer (the extruder, filament feed and movement motors) very easy, and it is the mechanical components where the primary differentiators lie (most use the same types of electrical components and standard, open source software). Along with the large (and generally boxy) shape of 3D printers, it doesn’t make sense to use anything else to control them.</li>
</ol>
<p>There are currently 24 Arduino boards to choose from, each with a different processor running at a different speed, having varying memory and unique input/output (IO) pin configurations. The range is quite remarkable, with many boards providing the basic socket connections of the original Arduino “Uno” layout shown in the image at the start of this article. Other Arduino boards provide different built-in IO connections or physical layout (the LilyPad Arduino is designed to be stitched into clothing). In the list of reference websites below, I’ve included the Arduino page listing all the different types of “standard” Arduinos that are available.</p>
<div id="attachment_46552" style="width: 810px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-46552" class="wp-image-46552 size-full" src="http://robohub.org/wp-content/uploads/2015/02/Arduino_Shields.jpg" alt="Arduino_Shields" width="800" height="751" srcset="https://robohub.org/wp-content/uploads/2015/02/Arduino_Shields.jpg 800w, https://robohub.org/wp-content/uploads/2015/02/Arduino_Shields-425x398.jpg 425w, https://robohub.org/wp-content/uploads/2015/02/Arduino_Shields-319x300.jpg 319w" sizes="(max-width: 800px) 100vw, 800px" /><p id="caption-attachment-46552" class="wp-caption-text">Arduino shields</p></div>
<p>One aspect that makes Arduino very exciting for me is the many different “shields” that are available for it. An Arduino “shield” is simply a PCB that is designed to plug into the Arduino Uno sockets and access specific pins for specific purposes. The different shields enhance the IO capabilities of the Arduino, and make creating an application a lot easier and faster. Unfortunately there is a downside: the need to allocate the IO pins used in order to ensure that multiple shields don’t use the same IO pins for the same functions. I’ll discuss this issue more in future posts.</p>
<p>I’ve numbered this first tutorial #0 for a reason: I want to set the stage (and some boundaries) for this series and share my own personal philosophies that will guide the materials and projects we will cover together. The Arduino is a great product with a large mass of resources and people behind it, but I want to get you to think about the Arduino as a <em>part</em> of your introduction to programming, electronics and robotics, so that you can understand its limitations and, hopefully, some day look beyond it create your own “big idea”.</p>
<p>One thing that has always really annoyed me are projects that require specialized parts that are limited in availability (usually because the author has a bunch of them he wants to sell). All the projects here will use standard parts available from reputable distributors. While I know I’ll be doing some junkbox applications, I’ll make sure that the descriptions of the parts that I use will be sufficient that you will be able to go out and find your own sources for the components and assemblies that I reference.</p>
<p>In the end, however, my goal is to have fun and to get you to try things with Arduino that haven’t been done before. And since a big part of having fun is to be able to do things quickly, the projects that we will undertake together will take just a few minutes to wire and program.</p>
<p>I hope that you will share your suggestions for tutorials and projects in comments section below. Don’t be afraid of being too outlandish; while I probably won’t go do a tutorial on building a remote trigger pull on a 12-gauge shotgun as part of a home-grown burglar deterrent/elimination system, your crazy idea could spur me onto something interesting. Let’s get some of those ideas going and see where they lead.</p>
<p><strong>Next Article:</strong> Setting up your own Arduino development station.</p>
<p><strong>Resources &amp; Further Reading:</strong></p>
<ul>
<li><a href="https://www.youtube.com/watch?v=UoBUXOOdLXY" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://www.youtube.com/watch?v=UoBUXOOdLXY</a> Massimo Banzi: How Arduino is open-sourcing imagination</li>
<li><a href="http://arduino.cc/en/Products.Compare" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://arduino.cc/en/Products.Compare</a> Different Arduino Boards</li>
<li><a href="http://shieldlist.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://shieldlist.org/</a> Arduino Shield List</li>
<li><a href="http://www.instructables.com/id/Intro-to-Arduino/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">http://www.instructables.com/id/Intro-to-Arduino/</a></li>
<li><a href="https://learn.sparkfun.com/tutorials/what-is-an-arduino" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">https://learn.sparkfun.com/tutorials/what-is-an-arduino</a></li>
</ul>
<p><em>Myke welcomes feedback, and you can email him at <a href="mailto:myke.predko@mimetics.ca">myke.predko@mimetics.ca</a> or leave a comment below.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Things to think about when transporting your robot</title>
		<link>https://robohub.org/things-to-think-about-when-transporting-your-robot/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Thu, 05 Feb 2015 19:20:42 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/things-to-think-about-when-transporting-your-robot/</guid>

					<description><![CDATA[<p>Throughout my career I have had to ship different robots to different locations around the world. Here is a little bit about what I have learnt about transportation. The 3 basic ways for a robot to travel are by land, by air, and by sea. Typically by truck (I guess there are also trains, but [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/transporting-robot/" data-wpel-link="external" target="_blank">Transporting your Robot</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://robotsforroboticists.com/" data-wpel-link="external" target="_blank">Robots For Roboticists</a>.</p>]]></description>
										<content:encoded><![CDATA[<div id="attachment_45590" style="width: 810px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-45590" class="size-full wp-image-45590" src="http://robohub.org/wp-content/uploads/2015/01/Shipping_Containers_at_the_terminal_at_Port_Elizabeth_New_Jersey_-_NOAA.jpg" alt="Source: Wikipedia." width="800" height="533" srcset="https://robohub.org/wp-content/uploads/2015/01/Shipping_Containers_at_the_terminal_at_Port_Elizabeth_New_Jersey_-_NOAA.jpg 800w, https://robohub.org/wp-content/uploads/2015/01/Shipping_Containers_at_the_terminal_at_Port_Elizabeth_New_Jersey_-_NOAA-425x283.jpg 425w, https://robohub.org/wp-content/uploads/2015/01/Shipping_Containers_at_the_terminal_at_Port_Elizabeth_New_Jersey_-_NOAA-450x300.jpg 450w" sizes="(max-width: 800px) 100vw, 800px" /><p id="caption-attachment-45590" class="wp-caption-text">Source: Wikipedia.</p></div>
<p>Throughout my career I have had to ship various robots to different locations around the world. Here is a little bit about what I have learned about transporting robots.<span id="more-45517"></span></p>
<p>The three basic ways for a robot to travel are by land, by air, and by sea.</p>
<p>Typically, shipping over land is the easiest option. You can find a trucking company (or train, though I have never used one) that will transport your robot. When you get a truck you can sometimes get a partial truck where you are given a certain volume to use, or you can get a full truck where the entire truck is dedicated to your payload. The nice thing with a truck is you provide them with a time, date, and location, and the driver will bring your stuff to you. Ground transportation generally is the least restrictive. You will need to follow Department of Transportation (DOT) restrictions (and other rules) for things such as max width and height of your load.</p>
<p>Transporting by air is good when you need to get something somewhere fast. This is especially true when you need to cross oceans. The downside is that this is also an expensive way to travel. Putting a large robot with support equipment on a plane can be pricey. You are also limited in what you can put on the plane &#8230; an airline might refuse to ship a gas/petrol powered robot or lithium batteries, for example.</p>
<p>Shipping by sea is a nice way to transport your robot across oceans (or long distances around a coast) if you have lots of time on your hands … Sending a shipping container (which is easy to pack, almost like a truck) from the North America to South America by boat can take an easy month. A big benefit is that you can ship lithium batteries across oceans this way. And shipping by sea is often cheaper than doing so by land or by air.</p>
<p>Often you will need multiple shipping companies. For example, you might have: a local truck to the port, the ship/boat company, a truck from the destination port to a large city, and then another smaller truck to your location. There are shipping agents that can help you arrange all of that. Also, for smaller robots (where small is relative) don’t forget about UPS and FedEx to ship your freight. You can look in your local yellow pages or on Google to find shipping companies and shipping agents near you.</p>
<h2>Types of Trucks</h2>
<p>When you are planning to ship by truck, you will need to consider the different types of trucks to choose from. Within each of these types there are also different lengths of trucks that you can request. You should be aware that truck drivers will usually want to inspect the loads to make sure they are secure. With many types of trucks, the truck driver will be the one that secures the load, and not you. When you have a truck come to your loading area, you should find out in advance how long it is to make sure the truck will be able to drive in and out of your area.</p>
<div class="divideronpost"></div>
<p><b>Pickup + Trailer</b> – This is just a standard pickup truck that you can also get a trailer to tow behind it. This is the smallest and simplest type of truck mentioned here.</p>
<div class="divideronpost"></div>
<p><b>Tow Truck</b> – These are the standard trucks that haul cars. It is easy and inexpensive to get a local tow truck and driver to help you move a robot. You will usually want to request a tow truck with a flat-bed and not one that drags a car behind it. Keep in mind that the driver from the tow company will be the one operating/driving the truck, and that the truck will usually have an open top, so your cargo will not be protected from the elements.</p>
<div class="divideronpost"></div>
<div id="attachment_45693" style="width: 435px" class="wp-caption alignleft"><img decoding="async" aria-describedby="caption-attachment-45693" class="size-medium wp-image-45693" src="http://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-425x425.jpg" alt="Box truck. Source: Wikipedia" width="425" height="425" srcset="https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-425x425.jpg 425w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-290x290.jpg 290w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-100x100.jpg 100w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-220x220.jpg 220w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-300x300.jpg 300w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-32x32.jpg 32w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-64x64.jpg 64w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-96x96.jpg 96w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia-128x128.jpg 128w, https://robohub.org/wp-content/uploads/2015/01/boxtruck_wikipedia.jpg 512w" sizes="(max-width: 425px) 100vw, 425px" /><p id="caption-attachment-45693" class="wp-caption-text">Box truck. Source: Wikipedia</p></div>
<p><b>Panel Truck or Box Truck</b> – This is another easy to get truck. You have probably seen large versions of these trucks on the highway, or smaller versions in the city; they have a metal box in the back for transporting goods.</p>
<p>The small and medium sized versions of these trucks are easy to rent and you can drive them your self (as opposed to getting a truck with a driver). This is the type of truck I use most because I can rent and use them on my own schedule.</p>
<div class="divideronpost"></div>
<div id="attachment_45694" style="width: 410px" class="wp-caption alignleft"><img decoding="async" aria-describedby="caption-attachment-45694" class="size-full wp-image-45694" src="http://robohub.org/wp-content/uploads/2015/01/flatbed_wikipedia.jpg" alt="Flatbed truck. Source: Wikipedia" width="400" height="297" /><p id="caption-attachment-45694" class="wp-caption-text">Flatbed truck. Source: Wikipedia</p></div>
<p><b>Flat Bed</b> – A flat-bed is a truck has a flat platform instead of a box. These are good for carrying large loads and being able to get a forklift in from all sides. The downside is that your robot is not protected from the elements and is exposed (but of course you can use a tarp).</p>
<div class="divideronpost"></div>
<div id="attachment_45692" style="width: 435px" class="wp-caption alignleft"><img decoding="async" aria-describedby="caption-attachment-45692" class="size-medium wp-image-45692" src="http://robohub.org/wp-content/uploads/2015/01/lowboy_wikipedia-425x195.jpg" alt="Low Boy truck. Source: Wikipedia" width="425" height="195" srcset="https://robohub.org/wp-content/uploads/2015/01/lowboy_wikipedia-425x195.jpg 425w, https://robohub.org/wp-content/uploads/2015/01/lowboy_wikipedia-500x230.jpg 500w, https://robohub.org/wp-content/uploads/2015/01/lowboy_wikipedia.jpg 1000w" sizes="(max-width: 425px) 100vw, 425px" /><p id="caption-attachment-45692" class="wp-caption-text">Low Boy truck. Source: Wikipedia</p></div>
<p><b>Low Boy</b> – The carrying surface of a Low Boy truck is close to the ground, and it offers better clearance when transporting tall/large payloads. Low Boys can come apart in various ways that allow you to drive a robot onto them.</p>
<div class="divideronpost"></div>
<p><strong>Tip</strong></p>
<p>When doing a roundtrip shipment, a truck driver might hang around town waiting for you, and may try to get a few local hauls while waiting. It can often be helpful to pay the driver a little extra for them to help you in the field, even with non-trucking tasks. Many of the truckers I have met are good at solving field logistic issues and improvising to fix mechanical items. We have even asked truck drivers to help record video!</p>
<h2>Crates</h2>
<p>A good crate can make all the difference when shipping items. You generally want a crate that is elevated by multiple blocks so that it can be lifted by a pallet jack (or fork lift) from any of its sides. A common mistake people make is to build a crate with just a few slats that only allow forks to enter from one side.</p>
<p>When you build your crate, you will want to use stamped wood that is certified to be pest free so that countries will allow your wood/crate across their borders. There are many places (such as Hawaii’s Dept. of Agriculture) that will insist on inspecting the crate for foreign infestations.</p>
<p>You will also want to think about how to seal the crate. For this, there are various methods ranging from screws to latches, clips and climps. Ask yourself if you will have access to tools at your destination, or if will they all be in the crate that you need to open. Using climps or latches can be an easy way to secure a crate shut; these can be bought online from packaging and shipping suppliers.</p>
<div class=" "><iframe title="Climp installation demo" width="500" height="375" src="https://www.youtube-nocookie.com/embed/aDrIAn24c_s?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p></p>
<p>There are professional crate makers that can do a beautiful job building crates. They often build crates for companies that ship to exhibits, and can help walk you through exactly what you need and make a crate that fits your robot perfectly. They will also have different supplies you can purchase, such as stamped wood for international shipping, foam sheets, various ways to seal the crate, and ways to secure your load in the crates.</p>
<p>Once your robot is in its crate, you will want to tie it down so that it is secure. I will often use wheel chocks or 2×4 lumber to help hold a robot&#8217;s wheels in place, and then use some screw-in eye bolts to help tie the rest of the robot down. Heavy items like batteries can often be removed from the robot and secured to the base of the crate. This will help prevent a heavy battery from coming loose inside your robot.</p>
<p>You may also want to label all sides of your crate &#8220;FRAGILE&#8221; and note the direction that the crate should face (&#8220;THIS SIDE UP&#8221;).</p>
<h2>Batteries in the Air</h2>
<p>If you plan on shipping batteries by air (especially lithium-ion) you need to plan in advance, because airlines are concerned about batteries exploding and catching on fire mid-flight.</p>
<p>If you built your own battery pack, then you have little chance of getting it approved to fly. It is possible to get prototype batteries certified to fly, but it is not easy or fun. If each cell or individual battery is certified to fly you might be able to take your pack apart and then ship it. If you have batteries that are safe to fly, you should attach documentation directly to the battery pack so that anyone inspecting has proof of their safety.</p>
<h2>International Shipping</h2>
<p>Shipping your robot internationally can be complicated. You may want to work with a shipping agent that has experience in international shipping. You will need to generate your manifest weeks or months in advance so that it can be approved &#8211; this will minimize problems with customs and shipping. Taxes and regulations vary from country to country.</p>
<p>There is something called a <em>carnet </em>that allows you to declare that the items you are bringing into a country will be taken back out with you when you leave. A carnet can help you to get through customs and avoid paying taxes. The downside is that it costs money to prepare the carnet. They are also not foolproof: once I tried to use a carnet to get my robot through customs at the airport and none of the officials there knew what it was &#8230; it took lots of people lots of time to figure it out.</p>
<p>If you want to avoid packing your robot, you should build flying robots! Just don&#8217;t let the FAA find out! (Note: For everyone who did not figure it out my bad attempt at humor. I do not endorse tricking the FAA.)</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS, Arduino, and a Husky simulation</title>
		<link>https://robohub.org/ros-arduino-and-a-husky-simulation/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Fri, 23 Jan 2015 18:21:54 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Husky]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/ros-arduino-and-a-husky-simulation/</guid>

					<description><![CDATA[<p>By Martin Cote The Arduino family of micro controllers has quickly become a go-to board for hobbyists due to its ease of use. Often times roboticists must create communication protocols to allow their embedded hardware to communicate with a computer. One of the most powerful aspects of ROS is that it can communicate with a [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/blog/arduino-ros/" data-wpel-link="external" target="_blank">ROS, Arduino, and a Husky Simulation</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/" data-wpel-link="external" target="_blank">Clearpath Robotics Inc.</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><em>By Martin Cote</em></p>
<p>The Arduino family of micro controllers has quickly become a go-to board for hobbyists due to its ease of use. Often times roboticists must create communication protocols to allow their embedded hardware to communicate with a computer. One of the most powerful aspects of ROS is that it can communicate with a large variety of hardware. That’s where rosserial comes in! Rosserial is a general protocol for sending ROS messages over a serial interface, such as the UART on Arduino. This allows you to easily interface any sensors attached to Arduino into your ROS environment. Read on to learn more!<span id="more-45252"></span></p>
<p>This tutorial will get you started  by setting up the Arduino IDE and installing the rosserial libraries. Then, we’ll test it out by driving the Husky simulation using a neat trick with the Arduino board. It should goes without saying you’ll need an Arduino to complete this tutorial. We’ll also be using a Husky simulator, so make sure to run through our “Drive a Husky” tutorial if you haven’t done so yet.</p>
<h2><span class="wysiwyg-font-size-large">Setup</span></h2>
<p>The first step is to set up your Arduino environment, begin by installing the Arduino IDE and rosserial using:</p>
<pre>sudo apt-get install arduino arduino-core ros-hydro-rosserial ros-hydro-rosserial-arduino</pre>
<p>Once you open up the Arduino IDE for the first time, a directory named “sketchbook” will be created in your home directory. Now we need to import the rosserial library into your arduino IDE. If your sketchbook directory is empty, you may need to create a directory named “libraries” inside of it.</p>
<pre>mkdir ~/sketchbook/libraries
cd ~/sketchbook/libraries
rosrun rosserial_arduino make_libraries.py .</pre>
<p>Restart your Arduino IDE and you should see the ros_lib part of your libraries!</p>
<img decoding="async" class="aligncenter size-full wp-image-45325" src="http://robohub.org/wp-content/uploads/2015/01/ros_lib-check.png" alt="ros_lib-check" width="645" height="774" srcset="https://robohub.org/wp-content/uploads/2015/01/ros_lib-check.png 645w, https://robohub.org/wp-content/uploads/2015/01/ros_lib-check-354x425.png 354w, https://robohub.org/wp-content/uploads/2015/01/ros_lib-check-250x300.png 250w" sizes="(max-width: 645px) 100vw, 645px" />
<p>&nbsp;</p>
<p>You’ll want to ensure that your Ubuntu user is part of the “Dailout” group, which grants you access to serial ports. You can check by using</p>
<pre>groups "username”</pre>
<p>If you don’t see “dailout”, you can easily add yourself using</p>
<pre>sudo gpasswd --add "username" dialout</pre>
<p>One last step to make our lives easier will be to create udev rules so your Arduino is  recognized when plugged in and the correct permissions are set. For more information on udev rules check out ou<a href="https://support.clearpathrobotics.com/hc/en-us/articles/203252569-Udev-Rules" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">r udev article </a>. Begin by plugging in your Arduino.</p>
<p><strong><strong>NOTE:</strong></strong>If you are using a virtual machine, you will have to connect Arduino to the virtual machine after plugging it in.</p>
<img decoding="async" class="aligncenter size-full wp-image-45324" src="http://robohub.org/wp-content/uploads/2015/01/attaching-device-1024x571.jpg" alt="attaching-device-1024x571" width="1024" height="571" srcset="https://robohub.org/wp-content/uploads/2015/01/attaching-device-1024x571.jpg 1024w, https://robohub.org/wp-content/uploads/2015/01/attaching-device-1024x571-425x236.jpg 425w, https://robohub.org/wp-content/uploads/2015/01/attaching-device-1024x571-500x278.jpg 500w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p>You can confirm your system is actually connected to Arduino by running</p>
<pre>ls -l /dev</pre>
<p>Depending on your specific Arduino board, you should either see a line with ttyAMC# or ttyUSB#, where # is a number. This will also tell you the current <a href="https://help.ubuntu.com/community/FilePermissions" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">permissions</a> for your Arduino. Chances are you wouldn’t be able to upload code to your Arduino at the moment because you don’t sufficient permissions, but we will soon solve that by creating a new udev rule!</p>
<p>The udev rule will require the product and vendor ID to be able to identify when our arduino is connected which you can easily find using</p>
<pre>lsusb</pre>
<p>You should see a line similar to</p>
<pre>Bus 002 Device 005: ID 2341:0043</pre>
<p>To confirm this is indeed your Arduino, disconnect it and run the command again, taking note which entry has disappeared. Remember the ID numbers, in this case, 2341 is the vendor ID and 0043 is the product ID. Now venture over to your udev rules at:</p>
<pre>cd /etc/udev/rules.d/</pre>
<p>and create our new rules file, the naming conventions for rules files follows “##-name.rules”. Chose a number that isn’t in use!</p>
<pre>sudo gedit 97-arduino.rules</pre>
<p>Copy the following into your new rules file, replacing #### with your product ID and vendor ID. For more information about what these tags mean, check out our <a href="https://support.clearpathrobotics.com/hc/en-us/articles/203252569-Udev-Rules" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">article</a> on udev rules.</p>
<pre>SUBSYSTEMS=="usb", ATTRS{idProduct}=="###", ATTRS{idVendor}=="####", SYMLINK+="arduino",MODE="0777",</pre>
<p>All that is left is to update your udev rules and reboot your system</p>
<pre>udevadm trigger
sudo reboot</pre>
<p>You should now see “arduino” as an entry in <code class="western">ls -l /dev</code> with full permissions! (rwxrwxrwx)</p>
<h2><strong><span class="wysiwyg-font-size-large">Code</span></strong></h2>
<p>We’re now set to upload our code to Arduino! The code is fairly straight forward, however if you have any difficulties following along, check out our <a href="https://support.clearpathrobotics.com/hc/en-us/articles/201644249-Creating-a-workspace-package-and-publisher" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">“Creating a publisher” tutorial.</a> Copy the following code into the Arduino IDE and click upload. If your udev rules were set correctly you should be able to upload without any errors.</p>
<p><em>If you encounter any errors, verify your arduino is coming up as “arduino” in a ls -l /dev and proper permissions are set. You may also have to point the Arduino IDE towards the correct USB port in tools -&gt; serial port.</em></p>
<pre>#include &lt;ArduinoHardware.h&gt;
#include &lt;ros.h&gt;
#include &lt;geometry_msgs/Twist.h&gt;

ros::NodeHandle nh;

geometry_msgs::Twist msg;

ros::Publisher pub("husky/cmd_vel", &amp;msg);

void setup()
{
 nh.initNode();
 nh.advertise(pub);
} void loop()
{
 if(digitalRead(8)==1)
 msg.linear.x=-0.25;
 
 else if (digitalRead(4)==1)
 msg.linear.x=0.25;
 
 else if (digitalRead(8)==0 &amp;&amp; digitalRead(4)==0)
 msg.linear.x=0;
 
 pub.publish(&amp;msg);
 nh.spinOnce();
 }</pre>
<h2><span class="wysiwyg-font-size-medium">Driving Husky</span></h2>
<p>Now that Arduino is loaded with our code and publishing velocity commands, we can pass these messages along into our ROS environment. We’ll start by launching a Husky simulation:</p>
<pre>roslaunch husky_gazebo husky_empty_world.launch</pre>
<p>All that’s left is to attach the Arduino into our ROS environment using:</p>
<pre>rosrun rosserial_python serial_node.py _port:=/dev/arduino</pre>
<p>We’re ready to try it out! Go ahead and touch the digital pin 8 and you should see Husky drive forward! Similarly if you touch digital pin 4 Husky will drive backwards.</p>
<img decoding="async" class="aligncenter size-full wp-image-45323" src="http://robohub.org/wp-content/uploads/2015/01/ArduinoUno_r2_front450px.jpg" alt="ArduinoUno_r2_front450px" width="450" height="315" srcset="https://robohub.org/wp-content/uploads/2015/01/ArduinoUno_r2_front450px.jpg 450w, https://robohub.org/wp-content/uploads/2015/01/ArduinoUno_r2_front450px-425x297.jpg 425w, https://robohub.org/wp-content/uploads/2015/01/ArduinoUno_r2_front450px-428x300.jpg 428w" sizes="(max-width: 450px) 100vw, 450px" />
<p>This trick is made possible by a phenomenon known as <a href="http://en.wikipedia.org/wiki/Parasitic_capacitance" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">parasitic capacitance</a>, which is usually an unwanted effect in electronics design, but serves nicely for the purpose of our example. That being said, this isn’t the most reliable method, and is intended to provide a simple example with minimal equipment.  If you are having difficulties moving your simulated Husky, try using <code class="western">rostopic echo /husky/cmd_vel</code> to verify some commands are in fact being sent to Husky when you touch the pins.</p>
<p>Be sure to go through the rest of our ROS tutorials on our <a href="http://support.clearpathrobotics.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">knowledge base</a>. If you want to learn more about rosserial, be sure to visit the rosserial page of the <a href="http://wiki.ros.org/rosserial" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">ROS wiki</a>.</p>
<p>Looking for other Clearpath tutorials? You might like <a href="http://robohub.org/archives/authors/clearpath-robotics/" data-wpel-link="internal">these ones</a>! Or visit <a title="support" href="http://www.support.clearpathrobotics.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">www.support.clearpathrobotics.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Incremental encoder selection</title>
		<link>https://robohub.org/incremental-encoder-selection/</link>
		
		<dc:creator><![CDATA[Robots for Roboticists]]></dc:creator>
		<pubDate>Mon, 22 Dec 2014 18:31:47 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/incremental-encoder-selection/</guid>

					<description><![CDATA[We would like to welcome our newest Robohub contributor, David Kohanbash, whose blog &#8211; Robots for Roboticists &#8211; covers a broad range of technical topics that is sure to interest makers and practitioners. We hope you enjoy! Incremental encoders are good for speed control and can be used for position control when we have a homing routine [&#8230;]]]></description>
										<content:encoded><![CDATA[<div id="attachment_44222" style="width: 930px" class="wp-caption alignnone"><img decoding="async" aria-describedby="caption-attachment-44222" class="size-full wp-image-44222" src="http://robohub.org/wp-content/uploads/2014/12/quadrature_franksworkshop_x.png" alt="www.franksworkshop.com.au/Electronics/Photoplotter/Photoplotter.htm" width="920" height="400" srcset="https://robohub.org/wp-content/uploads/2014/12/quadrature_franksworkshop_x.png 920w, https://robohub.org/wp-content/uploads/2014/12/quadrature_franksworkshop_x-425x184.png 425w, https://robohub.org/wp-content/uploads/2014/12/quadrature_franksworkshop_x-500x217.png 500w" sizes="(max-width: 920px) 100vw, 920px" /><p id="caption-attachment-44222" class="wp-caption-text">www.franksworkshop.com.au/Electronics/Photoplotter/Photoplotter.htm</p></div>
<p><i>We would like to welcome our newest Robohub contributor, David Kohanbash, whose blog &#8211; Robots for Roboticists &#8211; covers a broad range of technical topics that is sure to interest makers and practitioners. We hope you enjoy!</i></p>
<p>Incremental encoders are good for speed control and can be used for position control when we have a homing routine to get absolute position, or the system is constrained to less than one rotation. <span id="more-44214"></span>One way an incremental encoder can also be an absolute encoder is if it is single turn. Usually an encoder on the back-shaft of a motor will be multi-turn, however if you have the encoder on the output shaft (or if it is a secondary position encoder) it can be single-turn.</p>
<p>Throughout this post I am focusing on digital/analog optical quadrature encoders. While there are other types of incremental encoders (with all sorts of fancy output options) these are probably the most common. These come as a standard option for many motors as well as in kits that you can snap onto a motor.</p>
<p>Quadrature encoders have at minimum 4 wires:<br />
– Power (often +5V)<br />
– Ground<br />
– A+<br />
– B+</p>
<p>A+ and B+ are the signal lines that generate the pulses that we use for determining position. There are several other signal lines that are often seen with encoders:<br />
– I+ (or sometimes Z+)<br />
– I- (or sometimes Z-)<br />
– A-<br />
– B-</p>
<p>I+ is known as the index pulse. For every full rotation of the encoder shaft there is one index pulse to help give an absolute reference in the rotation. This is often useful when homing a motor you can look for the index pulse.</p>
<p>The A-, B-, and I- are the inverse of the + versions of those signals. This is useful when operating in a high noise environment or where signal integrity is an issue.</p>
<p>If signal integrity is a concern (or an active issue) you can add a line driver to improve the signal.</p>
<p>In design reviews and in practice I often see people purchasing the highest resolution encoder that they can get. Often the cost of the encoder wheel does not change much based on the resolution.</p>
<p>Incremental quadrature encoders typically range from 100-1000 counts/rotation, however you can find encoders with many thousands of counts/rotation. Since they are quadrature and there are 4 state changes per each set of A &amp; B phases, the resolution is 4 times the counts/turn.</p>
<p>In theory if you need 1degree of resolution per rotation, you need an encoder with 360 counts. Using a quadrature encoder this can be reduced to only 90 counts in the encoder wheel! If you have gearing on the motor this can be further improved to limit the number of encoder ticks required.</p>
<p>When you pick an encoder it can be tempting to select the highest resolution available, but you should stop and think first. Some controllers will have a hard time tracking position if the motor is spinning fast and there are too many encoder ticks per unit time. On the flip side if you have a slow-moving motor you might need the high-resolution so that you can see the change in motor position during a given time step in your controller.</p>
<p>Some other things that you need to consider are operating conditions and mounting. Operating conditions is fairly straight forward; can the encoder survive the temperature, vibration, shock, water, etc.. that it will need to endure. Mounting can be a bit more interesting. There are all sorts of options for encoder mounts. Some of the mounting options are hollow shafts, solid shafts, recessed shafts, collars, etc.. Often when ordering a motor if you can get one with a backshaft that will be the easiest way to connect the encoder (assuming you dont have the manufacturer adding it for you). If you are using a brake on the motor, the brake might need to connect to the backshaft, and you will need to be creative or get a pass-through on the brake to add the encoder.</p>
<p>In closing when selecting an encoder you should check the following:<br />
1. Is an incremental (ie non-absolute) encoder good for this application?<br />
2. Does your controller interface to the output format of the encoder?<br />
3. What resolution is needed?<br />
4. What environment will the encoder be operated in?<br />
5. Mechanical fit &amp; mounting.<br />
6. How the electrical noise is (so you can get the differential channels)?<br />
7. How long should the cable be (assuming it is attached and not just a connector)?</p>
<p>A final piece of advice is to use shielded cables for your encoder signals. This is especially important for long cable runs (where you might need a driver) and noisy environments.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS101: Creating a subscriber using GitHub</title>
		<link>https://robohub.org/ros101-creating-a-subscriber-using-git-hub/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Fri, 12 Dec 2014 17:44:55 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/ros101-creating-a-subscriber-using-git-hub/</guid>

					<description><![CDATA[<p>By Martin Cote We previously learned how to write&#160;a publisher node to move Husky randomly. BUT! What good is publishing all these messages if no one is there to read it? In this tutorial we&#8217;ll write a subscriber that reads Husky&#8217;s position from the odom topic, and graph its movements. Instead of just copy-pasting code [&#8230;]</p>
<p>The post <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/blog/ros101-subscriber-using-github/" data-wpel-link="external" target="_blank">ROS101: Creating a Subscriber Using Git Hub</a> appeared first on <a rel="nofollow external noopener noreferrer" href="http://www.clearpathrobotics.com/" data-wpel-link="external" target="_blank">Clearpath Robotics Inc.</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><em><img decoding="async" class="aligncenter wp-image-26319 size-full" src="http://robohub.org/wp-content/uploads/2014/01/ROS101_logo.gif" alt="ROS101_logo" width="701" height="417" />By Martin Cote</em></p>
<p>We previously learned how to write a <a title="ROS 101 Publisher Node" href="http://robohub.org/ros-101-creating-a-publisher-node/" data-wpel-link="internal">publisher node to move Husky randomly</a>. BUT: what good is publishing all these messages if no one is there to read it? In this tutorial we’ll write a subscriber that reads Husky’s position from the odom topic, and graph its movements. Instead of just copy-pasting code into a text file, we’ll pull the required packages from <a title="GitHub" href="https://github.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">GitHub</a>, a very common practice among developers.<span id="more-43693"></span><span id="more-3714"></span></p>
<p>Before we begin, install Git to pull packages from GitHub, and pygame, to provide us with the tools to map out Husky’s movements:</p>
<pre>sudo apt-get install git
sudo apt-get install python-pygame</pre>
<h2><strong>Pulling from GitHub</strong></h2>
<p>GitHub is a popular tool among developers due to its use of version control – most ROS software has an associated GitHub repository. Users are able to “pull” files from the GitHub servers, make changes, then “push” these changes back to the server. In this tutorial we will be using GitHub to pull the ROS packages that we’ll be using. The first step is to make a new directory to pull the packages:</p>
<pre>mkdir ~/catkin_ws/src/ros101
cd ~/catkin_ws/src/ros101
git init</pre>
<p>Since we now know the URL that hosts the repositories, we’ll easily be able to pull the packages from GitHub. Access the repositories using the following command:</p>
<pre>git pull https://github.com/mcoteCPR/ROS101.git</pre>
<p>That’s it! You should see an src and launch folder, as well as a CMakelist.txt and package.xml in your ros101 folder. You now have the package “ros101″, which includes the nodes “random_driver.cpp” and “odom_graph.py”.</p>
<h2><strong>Writing the subscriber</strong></h2>
<p>We’ve already gone through the random_driver C++ code in the last tutorial, so this time we’ll go over the python code for odom_graph.py. This node uses the Pygame library to track Husky’s movement. Pygame is a set of modules intended to create video games in python; however, we’ll focus on the ROS portion of this code. More information on Pygame can be found on <a title="Pygame">their website</a>. The code for the odom_graph node can be found at:</p>
<pre>gedit -p ~/catkin_ws/src/ros101/src/odom_graph.py</pre>
<p>Let’s take a look at this code line by line:</p>
<pre>import rospy
from nav_msgs.msg import Odometry</pre>
<p>Much like the C++ publisher code, this includes the rospy library and imports the Odometry message type from nav_msgs.msg. To learn more about a specific message type, you can visit <a href="http://docs.ros.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span style="color: #551a8b;">http://docs.ros.org</span></a> to see it’s definition, for example, we are using <a href="http://docs.ros.org/api/nav_msgs/html/msg/Odometry.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span style="color: #551a8b;">http://docs.ros.org/api/nav_msgs/html/msg/Odometry.html</span></a> . The next block of code imports the pygame libraries and sets up the initial conditions for our display.</p>
<pre>def odomCB(msg)</pre>
<p>This is the odometry call back function, which is called every time our subscriber receives a message. The content of this function simply draws a line on our display between the last coordinates read from the odometry position message. This function will continually be called in our main loop.</p>
<pre>def listener():</pre>
<p>The following line starts the ROS node, anonymous=True means multiples of the same node can run at the same time:</p>
<pre>rospy.init_node('odom_graph', anonymous=True)</pre>
<p>Subscriber sets up the node to read messages from the “odom” topic, which are of the type Odometry, and calls the odomCB functions when it receives a message:</p>
<pre>rospy.Subscriber("odom", Odometry, odomCB)</pre>
<p>The last line of this function keeps the node active until it’s shut down:</p>
<pre>rospy.spin()</pre>
<h2><strong>Putting it all together</strong></h2>
<p>Now it’s time to test it out! Go ahead and close the odom_graph.py file and build your workspace using the catkin_make function in your workspace directory.</p>
<pre>cd ~/catkin_ws
catkin_make</pre>
<p>The next step is to launch our Husky simulation to start up ROS and all the Husky related nodes</p>
<pre>roslaunch husky_gazebo husky_emepty_world.launch</pre>
<p>In this tutorial we have provided a launch file that will start the random_driver and odom_graph node. The launch file is located in ~/ros101/src/launch and is called odom_graph_test.launch. If you want to learn more about launch files, check out our launch file article on our <a href="https://support.clearpathrobotics.com/hc/en-us/categories/200165835-ROS" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><span style="color: #551a8b;">support knowledge base</span></a>. We will now source our workspace and launch both nodes with the launch file in a new terminal window.</p>
<pre>source ~/catkin_ws/devel/setup.bash
roslaunch ros101 odom_graph_test.launch</pre>
<img decoding="async" class="aligncenter wp-image-43752 size-full" src="http://robohub.org/wp-content/uploads/2014/12/ROS101-GitHub1-1024x767.png" alt="ROS101-GitHub1-1024x767" width="1024" height="767" srcset="https://robohub.org/wp-content/uploads/2014/12/ROS101-GitHub1-1024x767.png 1024w, https://robohub.org/wp-content/uploads/2014/12/ROS101-GitHub1-1024x767-425x318.png 425w, https://robohub.org/wp-content/uploads/2014/12/ROS101-GitHub1-1024x767-400x300.png 400w" sizes="(max-width: 1024px) 100vw, 1024px" />
<p>There you have it! Our subscriber is now listening to messages on the odom topic, and graphing out Husky’s path.</p>
<p>&nbsp;</p>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS 101: Creating a publisher node</title>
		<link>https://robohub.org/ros-101-creating-a-publisher-node/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Tue, 23 Sep 2014 17:02:08 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/ros-101-creating-a-publisher-node/</guid>

					<description><![CDATA[By Martin Cote
In our previous post, we graduated from driving a Husky, to taking on a Grizzly! Now it&#8217;s time to get down and dirty with what ROS is really made of, nodes! We will first be creating a workspace to work from, then we will write ...]]></description>
										<content:encoded><![CDATA[<img decoding="async" class="size-full wp-image-26319" alt="ROS101_logo" src="http://robohub.org/wp-content/uploads/2014/01/ROS101_logo.gif" width="701" height="417" />
<p><em>By Martin Cote</em></p>
<p>In our <a title="ROS 101: DRIVE A GRIZZLY" href="http:///http://www.clearpathrobotics.com/blog/ros-101-drive-grizzly/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">previous post</a>, we graduated from driving a Husky to taking on a Grizzly! Now it’s time to get down and dirty with what ROS is really made of: nodes! We will first be creating a workspace to work from, then we will write a simple publisher that will make our virtual Husky drive around randomly. If this is your first time visiting a Clearpath Robotics ROS 101 blog, get started <a href="http://robohub.org/ros-101-intro-to-the-robot-operating-system/" data-wpel-link="internal">here</a>.<span id="more-38292"></span></p>
<h2>Creating a workspace and package</h2>
<p>Before we begin writing a node, we need to create a workspace and a package. Workspaces are simply directories to store all of your packages. First we will need to create a new directory.</p>
<pre><code class="sh">mkdir ~/ros101</code></pre>
<p>This created a directory in your home folder, which we will use as a workspace directory. We now need to create a subdirectory in your workspace directory to store all your source code for your packages.</p>
<pre><code class="sh">mkdir ~/ros101/src</code></pre>
<p>The last step to creating the workspace will be to initialize the workspace with catkin_init_workspace.</p>
<pre><code class="sh">cd ~/ros101/src
catkin_init_workspace</code></pre>
<p>Now that our workspace has been created, we will create a package in the src directory we just created. This can be done by navigating to the ~/ros101/src directory, which you should have already done in the last step, and using the catkin_create_pkg command  followed by what we want the package to be named, and then followed by what other packages our package will be dependent on; this command creates another directory for your new package, and two new configuration files inside that directory with some default settings.</p>
<pre><code class="sh">catkin_create_pkg random_husky_driver roscpp std_msgs</code></pre>
<p>You can see that this created CMakeLists.txt and package.xml inside the random_husky_driver directory; this is also where you will store all your source code for your packages. The roscpp and std_msgs  dependencies were added into the CMakeLIst.txt and package.xml.</p>
<h2>Writing the publisher</h2>
<p>As mentioned in our <a href="http://robohub.org/ros-101-drive-a-grizzly-2/" data-wpel-link="internal">previous post</a>, a publisher publishes messages to a particular topic. For this tutorial, we will be publishing random commands to the /husky/cmd_vel topic to make your Husky visualization drive itself. Start by creating a file in your ~/ros101/src/random_husky_driver directory called random_driver.cpp, and copy the following code.</p>
<pre><code class="sh">#include &lt;ros/ros.h&gt;
#include &lt;geometry_msgs/Twist.h&gt; 
#include &lt;stdlib.h&gt; 

int main(int argc, char **argv) {
     //Initializes ROS, and sets up a node
     ros::init(argc, argv, "random_husky_commands");
     ros::NodeHandle nh;

     //Ceates the publisher, and tells it to publish
     //to the husky/cmd_vel topic, with a queue size of 100
     ros::Publisher pub=nh.advertise&lt;geometry_msgs::Twist&gt;("husky/cmd_vel", 100);

     //Sets up the random number generator
     srand(time(0));

     //Sets the loop to publish at a rate of 10Hz
     ros::Rate rate(10);

       while(ros::ok()) {
            //Declares the message to be sent
            geometry_msgs::Twist msg;
           //Random x value between -2 and 2
           msg.linear.x=4*double(rand())/double(RAND_MAX)-2;
           //Random y value between -3 and 3
           msg.angular.z=6*double(rand())/double(RAND_MAX)-3;
           //Publish the message
           pub.publish(msg);

          //Delays untill it is time to send another message
          rate.sleep();
         }
}
</code></pre>
<p>Let’s break down this code line by line:</p>
<pre><code class="sh">#include &lt;ros/ros.h&gt;
#include &lt;geometry_msgs/Twist.h&gt; </code></pre>
<p>These lines includes the headers that we are going to need. The &lt;ros/ros.h&gt; header is required for ROS functionality and the &lt;geometry_msgs/Twist.h&gt; is added so that we can create a message of that type.</p>
<pre><code class="sh">ros::init(argc, argv, "random_husky_commands");
ros::NodeHandle nh;</code></pre>
<p>The first line, ros::init,  is used to initialize the ROS node, and name it “random_husky_commands”, while ros:NodeHandle starts the node.</p>
<pre><code class="sh">ros::Publisher pub=nh.advertise&lt;geometry_msgs::Twist&gt;("husky/cmd_vel", 100);</code></pre>
<p>Publishing a message is done using ros:Publisher pub=nh.advertise, followed by the message type that we are going to be sending, in this case it is a geometry_msga::Twist, and the topic that we are going to be sending it too, which for us is husky/cmd_vel.</p>
<p>The 100 is the message queue size; that is, if you are publishing message faster than what roscpp can send, 100 messages will be saved in the queue to be sent. The larger the queue, the more delay in robot movement in case of buffering.</p>
<p>Therefore in a real life example, you will want to have a smaller queue in the case of robot movement, where delay in movement commands are undesirable and even dangerous, but dropped messages are acceptable. In the case of sensors, it is recommended to use a larger queue, since delay is acceptable to ensure no data is lost.</p>
<pre><code class="sh">ros::Rate rate(10)
...
rate.sleep()</code></pre>
<p>ROS is able to control the loop frequency  using ros:Rate to dictate how rapidly the loop will run in Hz. rate.sleep will delay a variable amount of time such that your loop cycles at the desired frequency. This accounts for time consumed by other parts of the loop. All Clearpath robots require a minimum loop rate of 10Hz.</p>
<pre><code class="sh">while(ros::ok())</code></pre>
<p>The ros::ok function will return true unless it receives a command to shut down, either by using the rosnode kill command, or by the user pusing Ctrl-C in a terminal.</p>
<pre><code class="sh">geometry_msgs::Twist msg;</code></pre>
<p>This creates the message we are going to send, msg, of the type geometry_msgs:Twist<br />
msg.linear.x=4*double(rand())/double(RAND_MAX)-2;<br />
msg.angular.z=6*double(rand())/double(RAND_MAX)-3;</p>
<img decoding="async" class="size-full wp-image-38297 " alt="Screen-Shot-2014-09-19-at-10.16.36-AM-300x151" src="http://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-09-19-at-10.16.36-AM-300x151.png" width="300" height="151" />
<p>These lines calculate the random linear x and angular z values that will be sent to Husky.</p>
<pre><code class="sh">pub.publish(msg)</code></pre>
<p>We are finally ready to publish the message! The pub.publish adds msg to the publisher queue to be sent.</p>
<h2>Compiling the random Husky driver</h2>
<p>Compilation in ROS in handled by the catkin build system. The first step would usually be to set up our package dependencies in the CMakeLists.txt and package.xml. However this has already been done for us when we created the package and specified our dependencies. The next step is then to declare our new node as a executable, this is done by adding the following two lines to the CMakeLists.txt files in ~/ros101/src/random_husky_driver</p>
<pre><code class="sh">add_executable(random_driver random_driver.cpp)
target_link_libraries(random_driver ${catkin_LIBRARIES})</code></pre>
<p>The first line creates the executable called random_driver, and directs ROS to its source files. The second lines specifies what libraries will be used. Now we need to build our workspace using the catkin_make command in the workspace directory</p>
<pre>cd ~/ros101
catkin_make</pre>
<p>Let’s bring up the husky visualization as we did in a previous blog post.</p>
<pre>roslaunch husky_gazebo husky_empty_world.launch</pre>
<p>The final step is to source your setup.bash file in the workspace you have created. This script allows ROS to find the packages that are contained in your workspace. <strong>Don&#8217;t forget this process will have to be done on every new terminal instance!</strong></p>
<pre>source ~/ros101/devel/setup.bash</pre>
<p>It’s now time to test it out! Make sure you have a instance of roscore running in a separate terminal, then start the node.</p>
<pre>rosrun random_husky_driver random_driver</pre>
<p>You should now see Husky drive around! In a new terminal window, we can make sure that our node is publishing to the /husky/cmd_vel topic by echoing all messages on this topic.</p>
<pre>rostopic echo /husky/cmd_vel

<img decoding="async" class="size-full wp-image-38298 " alt="Screen-Shot-2014-08-27-at-1.11.36-PM-300x300" src="http://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300.png" width="300" height="300" srcset="https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300.png 300w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-290x290.png 290w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-100x100.png 100w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-220x220.png 220w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-32x32.png 32w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-64x64.png 64w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-96x96.png 96w, https://robohub.org/wp-content/uploads/2014/09/Screen-Shot-2014-08-27-at-1.11.36-PM-300x300-128x128.png 128w" sizes="(max-width: 300px) 100vw, 300px" /></pre>
<p>You should now see a stream of random linear x and angular z values.</p>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS 101: Drive a Grizzly!</title>
		<link>https://robohub.org/ros-101-drive-a-grizzly-2/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Thu, 03 Jul 2014 19:42:42 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[Clearpath Robotics]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=34048</guid>

					<description><![CDATA[So you have had a taste of driving a virtual Husky in our previous tutorial, but now want to try something a little bigger? How about 2000 lbs bigger? Read on to learn how to drive a (virtual) Grizzly, Clearpath Robotic’s largest and meanest platform. If you are totally new to ROS, be sure to check [&#8230;]]]></description>
										<content:encoded><![CDATA[<img decoding="async" class="size-full wp-image-26319" alt="ROS101_logo" src="http://robohub.org/wp-content/uploads/2014/01/ROS101_logo.gif" width="701" height="417" />
<p>So you have had a taste of driving a virtual Husky in our <a title="ROS 101: Drive a Husky!" href="http://robohub.org/ros-101-drive-a-husky/" target="_blank" data-wpel-link="internal">previous tutorial</a>, but now want to try something a little bigger? How about 2000 lbs bigger?</p>
<p><span id="more-34048"></span>Read on to learn how to drive a (virtual) Grizzly, Clearpath Robotic’s largest and meanest platform. If you are totally new to ROS, be sure to check out our tutorial series starting <a title="ROS 101: Intro to the Robot Operating System" href="http://robohub.org/ros-101-intro-to-the-robot-operating-system/" target="_blank" data-wpel-link="internal">here</a> and the <a title="ROS Cheat Sheet" href="http://www.clearpathrobotics.com/ros-cheat-sheet" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">ROS Cheat Sheet</a>. Here is your next ROS 101 dose.</p>
<p>An updated version of the Learn_ROS disk is available here:</p>
<p><a title="Public Learn ROS Disk" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk.gz" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk</a><br />
<a title="Public Learn ROS ovf" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf</a></p>
<p>Login (username): user<br />
Password: learn</p>
<h2><strong>Updating the Virtual Machine</strong></h2>
<p>Open a terminal window (Ctrl + Alt + T), and enter the following:</p>
<pre><code>sudo apt-get update
sudo apt-get install ros-hydro-grizzly-simulator 
</code><code>sudo apt-get install </code>ros-hydro-grizzly-desktop 
<code>sudo apt-get install </code>ros-hydro-grizzly-navigation</pre>
<h2><strong>Running a virtual Grizzly</strong></h2>
<p>Open a terminal window, and enter:</p>
<pre>roslaunch grizzly_gazebo grizzly_empty_world.launch</pre>
<p>Open another terminal window, and enter:</p>
<pre>roslaunch grizzly_viz view_robot.launch</pre>
<p>You should be given two windows, both showing a yellow, rugged robot (the Grizzly!). The left one shown is Gazebo. This is where we get a realistic simulation of our robot, including wheel slippage, skidding, and inertia. We can add objects to this simulation, or even entire maps of real places.</p>
<img decoding="async" class="size-full wp-image-34055" alt="Grizzly_gazebo-2" src="http://robohub.org/wp-content/uploads/2014/07/Grizzly_gazebo-2.png" width="1275" height="776" srcset="https://robohub.org/wp-content/uploads/2014/07/Grizzly_gazebo-2.png 1275w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_gazebo-2-425x258.png 425w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_gazebo-2-1024x623.png 1024w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_gazebo-2-492x300.png 492w" sizes="(max-width: 1275px) 100vw, 1275px" />
<div class="minitext">Grizzly RUV in simulation</div>
<div style="clear: both;"></div>
<p>The right window is RViz. This tool allows us to see sensor data from a robot, and give it commands (in a future post). RViz is a more simplified simulation in the interest of speed.</p>
<img decoding="async" class="size-full wp-image-34056" alt="Grizzly_rviz" src="http://robohub.org/wp-content/uploads/2014/07/Grizzly_rviz.png" width="1300" height="689" srcset="https://robohub.org/wp-content/uploads/2014/07/Grizzly_rviz.png 1300w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_rviz-425x225.png 425w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_rviz-1024x542.png 1024w, https://robohub.org/wp-content/uploads/2014/07/Grizzly_rviz-500x265.png 500w" sizes="(max-width: 1300px) 100vw, 1300px" />
<div class="minitext">RViz – sensor data</div>
<div style="clear: both;"></div>
<p>We can now command the robot to go forwards. Open a terminal window, and enter:</p>
<pre><code>rostopic pub /cmd_vel geometry_msgs/Twist -r 100 '[0.5,0,0]' '[0,0,0]'</code></pre>
<p>In the above command, we publish to the cmd_vel topic, of topic type geometry_msgs/Twist, at a rate of 100Hz. The data we publish tells the simulated Grizzly to go forwards at 0.5m/s, without any rotation. You should see your Grizzly move forwards. In the gazebo window, you might also notice simulated wheel slip, and skidding. Enjoy and stay tuned for more soon!</p>
<p>&nbsp;</p>
<div class="divideronpost"></div>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS: Getting started</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a title="" href="http://eepurl.com/t-UEf" target="_blank" rel="external nofollow noopener noreferrer" data-wpel-link="external">sign up for our weekly newsletter</a>.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS 101: Drive a Husky!</title>
		<link>https://robohub.org/ros-101-drive-a-husky/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Fri, 21 Mar 2014 15:08:00 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[Clearpath Robotics]]></category>
		<category><![CDATA[Husky]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[Simulation]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=29235</guid>

					<description><![CDATA[In the previous ROS 101 post, we showed how easy it is to get ROS going inside a virtual machine, publish topics and subscribe to them. If you haven’t had a chance to check the out all the previous ROS 101 tutorials, you may want to do so before we go on. In this post, we’re [&#8230;]]]></description>
										<content:encoded><![CDATA[<img decoding="async" src="http://robohub.org/wp-content/uploads/2014/01/ROS101.jpg" alt="ROS101_Clearpath" width="520" height="260" class="alignnone size-full wp-image-26299" srcset="https://robohub.org/wp-content/uploads/2014/01/ROS101.jpg 520w, https://robohub.org/wp-content/uploads/2014/01/ROS101-300x150.jpg 300w, https://robohub.org/wp-content/uploads/2014/01/ROS101-500x250.jpg 500w" sizes="(max-width: 520px) 100vw, 520px" />
<p>In<a href="http://robohub.org/ros-101-a-practical-example/" target="_blank" data-wpel-link="internal"> the previous ROS 101 post</a>, we showed how easy it is to get ROS going inside a virtual machine, publish topics and subscribe to them. If you haven’t had a chance to check the out all the previous <a href="http://robohub.org/tag/ros101-tutorial/" target="_blank" data-wpel-link="internal">ROS 101</a> tutorials, you may want to do so before we go on. In this post, we’re going to drive a Husky in a virtual environment, and examine how ROS passes topics around.<br />
<span id="more-29235"></span></p>
<p>An updated version of the Learn_ROS disk is available here:</p>
<p><a title="Public Learn ROS Disk" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk.gz" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk</a><br />
<a title="Public Learn ROS ovf" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf</a></p>
<p>Login (username): user<br />
Password: learn</p>
<p>If you just downloaded the updated version above, please skip the next section. If you have already downloaded it, or are starting from a base install of ROS, please follow the next section.</p>
<h2><strong>Updating the Virtual Machine</strong></h2>
<p>Open a terminal window (Ctrl + Alt + T), and enter the following:</p>
<pre><code>sudo apt-get update
sudo apt-get install ros-hydro-husky-desktop</code></pre>
<h2><strong>Running a virtual Husky</strong></h2>
<p>Open a terminal window, and enter:</p>
<pre><code>roslaunch husky_gazebo husky_empty_world.launch</code></pre>
<p>Open another terminal window, and enter:</p>
<pre><code>roslaunch husky_viz view_robot.launch</code></pre>
<p>You should be given two windows, both showing a yellow, rugged robot (the Husky!)</p>
<a href="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30.png" data-wpel-link="internal"><img decoding="async" class="wp-image-29240" alt="Screenshot-from-2014-03-14-07_34_30" src="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30.png" width="1534" height="797" srcset="https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30.png 1534w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30-425x220.png 425w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30-1024x532.png 1024w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_34_30-500x259.png 500w" sizes="(max-width: 1534px) 100vw, 1534px" /><br /></a>
<p>&nbsp;</p>
<p>The first window shown is Gazebo. This is where we get a realistic simulation of our robot, including wheel slippage, skidding, and inertia. We can add objects to this simulation, such as the cube above, or even entire maps of real places.</p>
<a href="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36.png" data-wpel-link="internal"><img decoding="async" class="wp-image-29239" alt="Screenshot-from-2014-03-14-07_35_36" src="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36.png" width="1537" height="905" srcset="https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36.png 1537w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36-425x250.png 425w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36-1024x602.png 1024w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-07_35_36-500x294.png 500w" sizes="(max-width: 1537px) 100vw, 1537px" />
<p></a></p>
<p>The second window is RViz. This tool allows us to see sensor data from a robot, and give it commands (We&#8217;ll talk about how to do this in a future post). RViz is a more simplified simulation in the interest of speed.</p>
<p>We can now command the robot to go forwards. Open a terminal window, and enter:</p>
<pre><code>rostopic pub /husky/cmd_vel geometry_msgs/Twist -r 100 '[0.5,0,0]' '[0,0,0]'</code></pre>
<p>In the above command, we publish to the /husky/cmd_vel topic, of topic type geometry_msgs/Twist, at a rate of 100Hz. The data we publish tells the simulated Husky to go forwards at 0.5m/s, without any rotation. You should see your Husky move forwards. In the gazebo window, you might notice simulated wheel slip, and skidding.</p>
<h2><strong>Using rqt_graph</strong></h2>
<p>We can also see the structure of how topics are passed around the system. Leave the publishing window running, and open a terminal window. Type in:</p>
<pre><code>rosrun rqt_graph rqt_graph</code></pre>
<p>This command generates a representation of how the nodes and topics running on the current ROS Master are related. You should get something similar to the following:</p>
<a href="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25.png" data-wpel-link="internal"><img decoding="async" class="wp-image-29238" alt="Screenshot-from-2014-03-14-08_10_25" src="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25.png" width="1426" height="645" srcset="https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25.png 1426w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25-425x192.png 425w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25-1024x463.png 1024w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-14-08_10_25-500x226.png 500w" sizes="(max-width: 1426px) 100vw, 1426px" />
<p></a></p>
<p>&nbsp;</p>
<p>The highlighted node and arrow show the topic that you are publishing to the simulated Husky. This Husky then goes on to update the gazebo virtual environment, which takes care of movement of the joints (wheels) and the physics of the robot. The rqt_graph command is very handy to use, when you are unsure who is publishing to what in ROS. Once you figure out what topic you are interested in, you can see the content of the topic using rostopic echo.</p>
<h2><strong>Using tf</strong></h2>
<p>In Ros, tf is a special topic that keeps track of coordinate frames, and how they relate to each other. So, our simulated Husky starts at (0,0,0) in the world coordinate frame. When the Husky moves, it’s own coordinate frame changes. Each wheel has a coordinate frame that tracks how it is rotating, and where it is. Generally, anything on the robot that is not fixed in space, will have a tf describing it. In the rqt_graph section, you can see that the /tf topic is published to and subscribed from by many different nodes.</p>
<p>One intuitive way to see how the tf topic is structured for a robot is to use the view_frames tool provided by ROS. Open a terminal window. Type in:</p>
<pre><code>rosrun tf2_tools view_frames.py
</code></pre>
<p>Wait for this to complete, and then type in:</p>
<pre><code>evince frames.pdf</code></pre>
<p>This will bring up the following image.</p>
<p><a href="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59.png" data-wpel-link="internal"><img decoding="async" class="wp-image-29237" alt="Screenshot-from-2014-03-18-12_20_59" src="http://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59.png" width="1664" height="571" srcset="https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59.png 1664w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59-425x145.png 425w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59-1024x351.png 1024w, https://robohub.org/wp-content/uploads/2014/03/Screenshot-from-2014-03-18-12_20_59-500x171.png 500w" sizes="(max-width: 1664px) 100vw, 1664px" /></a>Here we can see that all four wheel are referenced to the base_link, which is referenced from the base_frootprint. (Toe bone connected to the foot bone, the foot bone….). We also see that the odom topic is driving the reference of the whole robot. This means that if you write to the odom topic (IE, when you publish to the /cmd_vel topic) then the whole robot will move.</p>
<div>
<div></div>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS: Getting started</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a title="" href="http://eepurl.com/t-UEf" target="_blank" rel="external nofollow noopener noreferrer" data-wpel-link="external">sign up for our weekly newsletter</a>.</em></p>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS 101: A practical example</title>
		<link>https://robohub.org/ros-101-a-practical-example/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Wed, 05 Feb 2014 21:30:20 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=26465</guid>

					<description><![CDATA[In the previous ROS 101 post, we provided a quick introduction to ROS to answer questions like What is ROS? and How do I get started? Now that you understand the basics, here’s how they can apply to a practical example. Follow along to see how we actually ‘do’ all of these things … First, you will need to run Ubuntu, [&#8230;]]]></description>
										<content:encoded><![CDATA[<img decoding="async" src="http://robohub.org/wp-content/uploads/2014/01/ROS101.jpg" alt="ROS101_Clearpath" width="520" height="260" class="alignnone size-full wp-image-26299" srcset="https://robohub.org/wp-content/uploads/2014/01/ROS101.jpg 520w, https://robohub.org/wp-content/uploads/2014/01/ROS101-300x150.jpg 300w, https://robohub.org/wp-content/uploads/2014/01/ROS101-500x250.jpg 500w" sizes="(max-width: 520px) 100vw, 520px" />
<p>In the previous <a title="ROS 101: How to Guide" href="http://robohub.org/ros-101-intro-to-the-robot-operating-system/" target="_blank" data-wpel-link="internal">ROS 101 post</a>, we provided a quick introduction to ROS to answer questions like <em>What is ROS? </em>and <em>How do I get started? </em>Now that you understand the basics, here’s how they can apply to a practical example. Follow along to see how we actually ‘do’ all of these things …<span id="more-26465"></span></p>
<p>First, you will need to run Ubuntu, and have ROS installed on it. For your convenience, you can download our easy-to-use image here:</p>
<p><a title="Public Learn ROS Disk" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk.gz" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS-disk1.vmdk</a><br />
<a title="Public Learn ROS ovf" href="https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/Learn_ROS.ovf</a></p>
<p>Login (username): user<br />
Password: learn</p>
<p>Get VMWare Player, and use the virtual disk above. If you don’t want to use the provided image, follow the tutorial here (after installing Ubuntu 12.04):</p>
<p><a title="Ubunto Installation" href="http://wiki.ros.org/hydro/Installation/Ubuntu" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">http://wiki.ros.org/hydro/Installation/Ubuntu</a></p>
<p>Throughout the rest of the tutorials, we will be referencing the <a title="ROS Cheat Sheet" href="http://www.clearpathrobotics.com/ros-cheat-sheet" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">ROS cheatsheet available here</a>.<em><br />
</em></p>
<p>Open a new Terminal Window (Ctrl + Alt + T).<br />
In the new terminal, type roscore (And press enter).<br />
This should produce something similar to the below.</p>
<img decoding="async" class="size-full wp-image-26466" alt="ROSpic1" src="http://robohub.org/wp-content/uploads/2014/02/ROSpic1.png" width="724" height="553" srcset="https://robohub.org/wp-content/uploads/2014/02/ROSpic1.png 724w, https://robohub.org/wp-content/uploads/2014/02/ROSpic1-300x229.png 300w, https://robohub.org/wp-content/uploads/2014/02/ROSpic1-392x300.png 392w" sizes="(max-width: 724px) 100vw, 724px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 1</div>
<p>What you have just done is started the ROS Master as we described above. We can now experiment with some ROS commands.<br />
Open a new Terminal, and type in rostopic. This will give you a list of all the options that the rostopic command can do. For now, we are interested in rostopic list<br />
Type in rostopic list. (And press enter). This should give you a window like the following:</p>
<img decoding="async" class="size-full wp-image-26467" alt="rospic2" src="http://robohub.org/wp-content/uploads/2014/02/rospic2.png" width="553" height="337" srcset="https://robohub.org/wp-content/uploads/2014/02/rospic2.png 553w, https://robohub.org/wp-content/uploads/2014/02/rospic2-300x182.png 300w, https://robohub.org/wp-content/uploads/2014/02/rospic2-492x300.png 492w" sizes="(max-width: 553px) 100vw, 553px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 2</div>
<p>The two entries listed above are ROS’s built in way of reporting and aggregating debug messages in the system. What we want to do is publish and subscribe to a message.<br />
You can open a new Terminal again, or open a new tab on the same terminal window (Ctrl + Shift + T).<br />
In the new Terminal, type in: rostopic pub /hello std_msgs/String “Hello Robot”</p>
<img decoding="async" class="size-full wp-image-26468" alt="ROSpic3" src="http://robohub.org/wp-content/uploads/2014/02/ROSpic3.png" width="642" height="369" srcset="https://robohub.org/wp-content/uploads/2014/02/ROSpic3.png 642w, https://robohub.org/wp-content/uploads/2014/02/ROSpic3-300x172.png 300w, https://robohub.org/wp-content/uploads/2014/02/ROSpic3-500x287.png 500w" sizes="(max-width: 642px) 100vw, 642px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 3</div>
<p>Let’s break down the parts of that command.<br />
rostopic pub – This commands ROS to publish a new topic.<br />
/hello – This is the name of the new topic. (Can be whatever you want)<br />
std_msgs/String – This is the topic type. We want to publish a string topic. In our overview examples above, it was an image data type.<br />
“Hello Robot” – This is the actual data contained by the topic. I.E. the message itself.<br />
Going back to the previous Terminal, we can execute rostopic list again.<br />
We now have a new topic listed! We can also echo the topic to see the message. rostopic echo /hello</p>
<img decoding="async" class="size-full wp-image-26469" alt="rospic4" src="http://robohub.org/wp-content/uploads/2014/02/rospic4.png" width="642" height="369" srcset="https://robohub.org/wp-content/uploads/2014/02/rospic4.png 642w, https://robohub.org/wp-content/uploads/2014/02/rospic4-300x172.png 300w, https://robohub.org/wp-content/uploads/2014/02/rospic4-500x287.png 500w" sizes="(max-width: 642px) 100vw, 642px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 4</div>
<p>We have now successfully published a topic with a message, and received that message.<br />
Type Ctrl + C to stop echoing the /hello topic.<br />
We can also look into the node that is publishing the message. Type in rosnode list. You will get a list similar to the one below. (The exact numbers beside the rostopic node may be different)</p>
<img decoding="async" class="size-full wp-image-26470" alt="rospic5" src="http://robohub.org/wp-content/uploads/2014/02/rospic5.png" width="642" height="477" srcset="https://robohub.org/wp-content/uploads/2014/02/rospic5.png 642w, https://robohub.org/wp-content/uploads/2014/02/rospic5-300x222.png 300w, https://robohub.org/wp-content/uploads/2014/02/rospic5-403x300.png 403w" sizes="(max-width: 642px) 100vw, 642px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 5</div>
<p>Because we asked rostopic to publish the /hello topic for us, ROS went ahead and created a node to do so. We can look into details of by typing rosnode info /rostopic_…..(whatever numbers)<br />
TIP: In ROS, and in Linux in general, whenever you start typing something, you can press the Tab key to auto-complete it. If there is more than one entry, double tap Tab to get the list. In the above example, all I typed was rosnode info /rost(TAB)</p>
<img decoding="async" class=" size-full wp-image-26471" alt="rospic6" src="http://robohub.org/wp-content/uploads/2014/02/orspic6.png" width="642" height="477" srcset="https://robohub.org/wp-content/uploads/2014/02/orspic6.png 642w, https://robohub.org/wp-content/uploads/2014/02/orspic6-300x222.png 300w, https://robohub.org/wp-content/uploads/2014/02/orspic6-403x300.png 403w" sizes="(max-width: 642px) 100vw, 642px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 6</div>
<p>We can get info on our topic the same way, by typing rostopic info /hello.</p>
<img decoding="async" class="size-full wp-image-26472" alt="rospic7" src="http://robohub.org/wp-content/uploads/2014/02/rospic7.png" width="642" height="477" srcset="https://robohub.org/wp-content/uploads/2014/02/rospic7.png 642w, https://robohub.org/wp-content/uploads/2014/02/rospic7-300x222.png 300w, https://robohub.org/wp-content/uploads/2014/02/rospic7-403x300.png 403w" sizes="(max-width: 642px) 100vw, 642px" />
<div style="clear: both;"></div>
<div class="minitext">ROS Figure 7</div>
<p>You will notice that the node listed under “Publishers:” is the same node we requested info about.</p>
<p>Up till now, we have covered the fundamentals of ROS, how to use rostopic, rosnode.</p>
<p>Next time, we will compile a short example program, and try it out.</p>
<p>&nbsp;</p>
<div class="divideronpost"></div>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS: Getting started</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ROS 101: Intro to the Robot Operating System</title>
		<link>https://robohub.org/ros-101-intro-to-the-robot-operating-system/</link>
		
		<dc:creator><![CDATA[Clearpath Robotics]]></dc:creator>
		<pubDate>Wed, 29 Jan 2014 16:15:22 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[ROS101 Tutorial]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=26290</guid>

					<description><![CDATA[Clearpath Robotics brings us a new tutorial series on ROS! Since we practically live in the Robot Operating System (ROS), we thought it was time to share some tips on how to get started with ROS. We’ll answer questions like where do I begin? How do I get started? What terminology should I brush up on? Keep [&#8230;]]]></description>
										<content:encoded><![CDATA[<img decoding="async" src="http://robohub.org/wp-content/uploads/2014/01/ROS101.jpg" alt="ROS101_Clearpath" width="520" height="260" class="alignnone size-full wp-image-26299" srcset="https://robohub.org/wp-content/uploads/2014/01/ROS101.jpg 520w, https://robohub.org/wp-content/uploads/2014/01/ROS101-300x150.jpg 300w, https://robohub.org/wp-content/uploads/2014/01/ROS101-500x250.jpg 500w" sizes="(max-width: 520px) 100vw, 520px" />
<p><em><a href="http://www.clearpathrobotics.com" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Clearpath Robotics</a> brings us a new tutorial series on ROS!</em></p>
<p>Since we practically live in the Robot Operating System (ROS), we thought it was time to share some tips on how to get started with ROS. We’ll answer questions like <em>where do I begin? How do I get started? What terminology should I brush up on?</em> Keep an eye out for this ongoing ROS 101 blog series that will provide you with a top to bottom view of ROS that will focus on introducing basic concepts simply, cleanly and at a reasonable pace. This guide is meant as a groundwork for new users, which can then be used to jump into in-depth data at <a title="ROS Wiki" href="http://wiki.ros.org/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">wiki.ros.org</a>. If you are totally unfamiliar with ROS, Linux, or both, this is the place for you!<span id="more-26290"></span></p>
<h2><strong>The ROS Cheat Sheet</strong></h2>
<p>This ROS Cheat Sheet is filled with tips and tricks to help you get started and to continue using once you’re a true ROS user. This version is written for ROS Hydro Medusa. <a title="ROS Cheat Sheet-Hydrov1" href="http://www.clearpathrobotics.com/ros-cheat-sheet" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Download the ROS Cheat Sheet here</a>.</p>
<h2><strong>What is ROS?</strong></h2>
<p><a title="ROS.org" href="http://www.ros.org/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">ROS (Robot Operating System)</a> is a BSD-licensed system for controlling robotic components from a PC. A ROS system is comprised of a number of independent nodes, each of which communicates with the other nodes using a publish/subscribe messaging model. For example, a particular sensor’s driver might be implemented as a node, which publishes sensor data in a stream of messages. These messages could be consumed by any number of other nodes, including filters, loggers, and also higher-level systems such as guidance, pathfinding, etc.</p>
<h2><strong>Why ROS?</strong></h2>
<p>Note that nodes in ROS do not have to be on the same system (multiple computers) or even of the same architecture! You could have a Arduino publishing messages, a laptop subscribing to them, and an Android phone driving motors. This makes ROS really flexible and adaptable to the needs of the user. ROS is also open source, maintained by many people.</p>
<h2><strong>General Concepts</strong></h2>
<p>Let’s look at the ROS system from a very high level view. No need to worry how any of the following works, we will cover that later.</p>
<p>ROS starts with the ROS Master. The Master allows all other ROS pieces of software (Nodes) to find and talk to each other. That way, we do not have to ever specifically state “Send this sensor data to that computer at 127.0.0.1. We can simply tell Node 1 to send messages to Node 2.</p>
<img decoding="async" class="size-full wp-image-26294" alt="ros101-1" src="http://robohub.org/wp-content/uploads/2014/01/ros101-1.png" width="853" height="534" srcset="https://robohub.org/wp-content/uploads/2014/01/ros101-1.png 853w, https://robohub.org/wp-content/uploads/2014/01/ros101-1-300x187.png 300w, https://robohub.org/wp-content/uploads/2014/01/ros101-1-479x300.png 479w" sizes="(max-width: 853px) 100vw, 853px" />
<div class="minitext">Figure 1</div>
<p>How do Nodes do this? By publishing and subscribing to Topics.</p>
<p>Let’s say we have a camera on our Robot. We want to be able to see the images from the camera, both on the Robot itself, and on another laptop.</p>
<p>In our example, we have a Camera Node that takes care of communication with the camera, a Image Processing Node on the robot that process image data, and a Image Display Node that displays images on a screen. To start with, all Nodes have registered with the Master. Think of the Master as a lookup table where all the nodes go to find where exactly to send messages.</p>
<img decoding="async" class="size-full wp-image-26295" alt="ros101-2" src="http://robohub.org/wp-content/uploads/2014/01/ros101-2.png" width="965" height="673" srcset="https://robohub.org/wp-content/uploads/2014/01/ros101-2.png 965w, https://robohub.org/wp-content/uploads/2014/01/ros101-2-300x209.png 300w, https://robohub.org/wp-content/uploads/2014/01/ros101-2-430x300.png 430w" sizes="(max-width: 965px) 100vw, 965px" />
<div class="minitext">Figure 2</div>
<p>In registering with the ROS Master, the Camera Node states that it will Publish a Topic called /image_data (for example). Both of the other Nodes register that they are Subscribed to the Topic /image_data.</p>
<p>Thus, once the Camera Node receives some data from the Camera, it sends the /image_data message directly to the other two nodes. (Through what is essentially TCP/IP)</p>
<img decoding="async" class="size-full wp-image-26296" alt="ros101-3" src="http://robohub.org/wp-content/uploads/2014/01/ros101-3.png" width="965" height="693" srcset="https://robohub.org/wp-content/uploads/2014/01/ros101-3.png 965w, https://robohub.org/wp-content/uploads/2014/01/ros101-3-300x215.png 300w, https://robohub.org/wp-content/uploads/2014/01/ros101-3-417x300.png 417w" sizes="(max-width: 965px) 100vw, 965px" />
<div class="minitext">Figure 3</div>
<p>Now you may be thinking, what if I want the Image Processing Node to request data from the Camera Node at a specific time? To do this, ROS implements Services.</p>
<p>A Node can register a specific service with the ROS Master, just as it registers its messages. In the below example, the Image Processing Node first requests /image_data, the Camera Node gathers data from the Camera, and then sends the reply.</p>
<img decoding="async" class="size-full wp-image-26297" alt="ros101-4" src="http://robohub.org/wp-content/uploads/2014/01/ros101-4.png" width="927" height="658" srcset="https://robohub.org/wp-content/uploads/2014/01/ros101-4.png 927w, https://robohub.org/wp-content/uploads/2014/01/ros101-4-300x212.png 300w, https://robohub.org/wp-content/uploads/2014/01/ros101-4-422x300.png 422w" sizes="(max-width: 927px) 100vw, 927px" />
<div class="minitext">Figure 4</div>
<p>We will have another tutorial &#8220;ROS 101 &#8211; Practical Example&#8221; next week.</p>
<p>&nbsp;</p>
<div class="divideronpost"></div>
<p><em>See all the ROS101 tutorials <a href="http://robohub.org/tag/ros101-tutorial/" data-wpel-link="internal">here</a>. If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS: Getting started</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
<p><em> </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Up and flying with the AR.Drone and ROS: Handling feedback</title>
		<link>https://robohub.org/up-and-flying-with-the-ar-drone-and-ros-handling-feedback/</link>
		
		<dc:creator><![CDATA[Mike Hamer]]></dc:creator>
		<pubDate>Mon, 01 Jul 2013 14:14:19 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[AR Drone]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[UAVs & drones]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=16026</guid>

					<description><![CDATA[This is the third tutorial in the Up and flying with the AR.Drone and ROS series. In this tutorial we will: Learn about the AR.Drone&#8217;s state feedback (and how it is handled by ROS) Learn about the AR.Drone&#8217;s tag detection Program our first ROS nodes: A subscriber and a publisher In the previous tutorials we: Installed ROS, the AR.Drone driver [&#8230;]]]></description>
										<content:encoded><![CDATA[<link href="syntax_highlight.css" rel="stylesheet" media="all" type="text/css" />
<style type="text/css"><!--
.maintext p {
	margin-top: 1em !important;
	margin-bottom: 1em !important;
}
.maintext pre {
	margin-top: 1em !important;
	margin-bottom: 1em !important;
}
.maintext v {
	font-family:monospace !important;
	/*background-color:#EEE;*/
}
.maintext ol li {
	margin-top: 1em !important;
}
.maintext ol li ul {
	margin: 0px !important;
	padding: 0px !important;
}
.maintext ol li ul li{
	margin: 0.5em !important;
}
--></style>
<a href="https://github.com/mikehamer/ardrone_tutorials" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><img decoding="async" class="size-full wp-image-16027" alt="ARDroneSubscribingFeedback" src="http://robohub.org/wp-content/uploads/2013/07/ARDroneHandlingFeedback900400.png" width="216" height="166" /></a>
<div style="clear: both;"></div>
<p>This is the third tutorial in the <em>Up and flying with the AR.Drone and ROS</em> series.</p>
<p>In this tutorial we will:</p>
<ol>
<li>Learn about the AR.Drone&#8217;s state feedback (and how it is handled by ROS)</li>
<li>Learn about the AR.Drone&#8217;s tag detection</li>
<li>Program our first ROS nodes: A subscriber and a publisher</li>
</ol>
<p><span id="more-16026"></span></p>
<p>In the previous tutorials we:</p>
<ol>
<li>Installed ROS, the AR.Drone driver and AR.Drone keyboard controller then flew the AR.Drone using the provided keyboard controller (<a href="/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">link</a>)</li>
<li>Learned about ROS communication, setup and then flew the AR.Drone using a joystick (<a href="/up-and-flying-with-the-ar-drone-and-ros-joystick-control/" data-wpel-link="internal">link</a>)</li>
</ol>
<p>In the next tutorials, we will:</p>
<ul>
<li>Write a controller to enable tag following</li>
<li>Write a controller for the drone which allows us to control drone velocity, rather than body angle</li>
</ul>
<h2><strong>What you&#8217;ll need for the tutorial</strong></h2>
<ol>
<li>An AR.Drone!</li>
<li>A computer or laptop with WiFi</li>
<li>Linux, either the ARDroneUbuntu virtual machine, or a custom installation</li>
<li>Either the keyboard or joystick controller from the previous tutorials</li>
</ol>
<p>I also assume that you&#8217;ve completed either the <a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">keyboard</a> or <a href="http://http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-joystick-control/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">joystick</a> tutorial, which detail how to setup the software, connect to the drone, etc, and provide a method of controlling the AR.Drone from your computer.</p>
<div class="aligncenter" style="background-color: #eee; padding: 5px; margin: 10px; margin-top: 4em; border: 1px solid #666; width: 90%;">
<p style="text-align: center; margin-top: 0; padding-top: 0;"><strong>Warning!</strong></p>
<p>In this tutorial, we will be flying the AR.Drone. <strong>Flying inside can be dangerous</strong>. When flying inside, you should always use the propeller-guard and fly in the largest possible area, making sure to stay away from walls and delicate objects. Even when hovering, the drone tends to drift, so always land the drone if not being flown.</p>
<p style="margin: 0px;">I accept no responsibility for damages or injuries that result from flying the drone.</p>
</div>
<h2><strong>Updating</strong></h2>
<h3>If you have not completed the <a href="http://http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-joystick-control/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">joystick</a> tutorial:</h3>
<p>Please go back and update your installation according to the instructions listed there.</p>
<h3>If you downloaded the ARDroneUbuntu virtual machine:</h3>
<p>To update your installation for this tutorial, click the &#8220;Update Tutorials&#8221; button in the ARDroneUbuntu Virtual Machine</p>
<h3>If you use a custom installation:</h3>
<p>At the terminal, enter the following:</p>
<pre>$ roscd ardrone_autonomy
$ git pull
$ roscd ardrone_tutorials
$ git pull
$ roscd
$ rosmake ardrone_tutorials</pre>
<h2><strong>AR.Drone State Feedback &#8211; A First Look</strong></h2>
<h3>Preparation:</h3>
<ol>
<li>Find the Orange-[Green|Yellow|Blue]-Orange tag that came with the AR.Drone.</li>
<li>In your ARDroneUbunutu virtual machine (or custom installation), open a new terminal window and type:
<pre>$ roscd ardrone_tutorials/launch</pre>
</li>
<li>If you intend to fly with the keyboard, type:
<pre>$ geany keyboard_controller_with_tags.launch</pre>
<p>Otherwise, if you intend to fly with the joystick:</p>
<pre>$ geany joystick_controller.launch</pre>
</li>
<li>Now find the line:
<pre>&lt;param name="enemy_colors" value="3" /&gt;</pre>
</li>
<li>And change the value to &#8220;1&#8221;, &#8220;2&#8221;, or &#8220;3&#8221;, depending on whether your tags are Orange-Green-Orange, Orange-Yellow-Orange or Orange-Blue-Orange respectively.</li>
</ol>
<h3>Tag Detection and Feedback Data</h3>
<ol>
<li>Run the system (but don&#8217;t takeoff with the drone!) using either the <a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">keyboard_controller</a>:
<pre>$ roslaunch ardrone_tutorials keyboard_controller_with_tags.launch</pre>
<p>or the <a href="http://http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-joystick-control/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">joystick_controller</a>:</p>
<pre>$ roslaunch ardrone_tutorials joystick_controller.launch</pre>
</li>
<li>Open a new terminal window and type:
<pre>$ rostopic list</pre>
<ul>
<li>This list shows all the active ROS &#8220;topics&#8221; used for communication to and from the AR.Drone</li>
</ul>
</li>
<li>In the same terminal window, type:
<pre>$ rostopic echo /ardrone/navdata</pre>
<ul>
<li>This echoes the AR.Drone&#8217;s feedback data into the terminal window.</li>
<li>Note that many items will be zero because the AR.Drone is not yet flying</li>
</ul>
</li>
<li>Move the Orange-Color-Orange tag in front of the AR.Drone&#8217;s front camera. It should be detected, and the console output (from the previous step), should update to reflect this detection.
<ul>
<li>Note the tags_xc and tags_yc values. These represent the x/y location of the tag within the image.</li>
<li>The video display window will show a dot at these coordinates, and the distance measurement above the dot</li>
</ul>
</li>
<li>Now place the tag somewhere that can be seen by the flying drone. After this is done, take off with the drone.</li>
<li>Watch the console output. What happens if you fly forwards? sideways? What variable changes if you rotate the drone?</li>
</ol>
<h3>Plotting the AR.Drone&#8217;s State</h3>
<ol>
<li>A more intuitive way of representing this feedback data is using a plot. PressCtrl-C to terminate the echo process from the last stage, and then type:
<pre>$ rxplot /ardrone/navdata/rotX,/ardrone/navdata/rotY</pre>
<ul>
<li>This launches a plotting window showing the AR.Drone&#8217;s estimated roll (rotX) and pitch (rotY).</li>
<li>Similar plots could, for example, be generated for yaw (rotZ), x and y velocity (vx and vy), altitude (altd), etc.</li>
</ul>
</li>
<li>Similarly to displaying the AR.Drone&#8217;s feedback data, we can use the plotting method to investigate how we are controlling the drone:
<pre>$ rxplot /cmd_vel/linear/y,/cmd_vel/linear/x</pre>
<ul>
<li>This plots the roll (linear/y) and pitch (linear/x) commands.</li>
<li>Note that these are scaled with a value of $\pm1$ being the maximum commandable angle (set by the euler_angle_max in the launch file).</li>
<li>Note also that the direction of AR.Drone movement is commanded (ie. move <em>along</em> the x-axis = /cmd_vel/linear/x = commanded pitch), whereas the AR.Drone&#8217;s feedback data is named with reference to axis of rotation (ie. tilt <em>around</em> y-axis = /ardrone/navdata/rotY = feedback pitch).</li>
</ul>
</li>
</ol>
<h3>Logging Data</h3>
<ol>
<li>To log data, we can use the inbuilt ROS command <a href="http://www.ros.org/wiki/rosbag/Tutorials/Recording%20and%20playing%20back%20data" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">rosbag</a>:
<pre>$ rosbag record -O ARDroneFlight.bag /ardrone/navdata /cmd_vel</pre>
<ul>
<li>This will record the topics /ardrone/navdata and /cmd_vel to a &#8220;bag-file&#8221;, stamped with the current date and time.</li>
<li>Leave this process running for a few seconds, fly the AR.Drone around, and when finished press Ctrl-C to terminate.</li>
<li>Recording all topics is possible with rosbag record -a, however this also records the AR.Drone&#8217;s HD video stream, thus bag-files will quickly become very large</li>
<li>The advantage of using rosbag to log data, is that bag-files can be replayed at a later time, and interact very nicely with the existing ROS infrastructure.</li>
</ul>
</li>
<li>Land the AR.Drone and close any windows / terminate any processes relating to the controller. Now, into the terminal window that ran the AR.Drone controller, type:
<pre>$ roscore</pre>
<p>Now open a new terminal window and type:</p>
<pre>$ rxplot /cmd_vel/linear/y,/cmd_vel/linear/x</pre>
<p>Now finally (ignoring the warning from the previous step), switch back to the terminal window that you used to run the rosbag command and type:</p>
<pre>$ rosbag play ARDroneFlight.bag</pre>
<p>Does the flight look familiar? It should! This is the flight you recorded in the last step! Use Ctrl-C to terminate the above processes.</li>
</ol>
<h2><strong>Custom Data Handling</strong></h2>
<p>In the last section, we investigated the AR.Drone&#8217;s feedback data by using ROS&#8217;s inbuilt plotting (rxplot) and logging (rosbag) commands. In this section, you will learn how we get this feedback data into your own application by writing a custom ROS Node. This node will be used to compare the commanded roll and pitch angles with the AR.Drone&#8217;s roll and pitch estimates, thus laying the foundations for the next tutorial, where we will use this feedback data to programmatically control the AR.Drone.</p>
<h3>Messages, Topics and Nodes</h3>
<p>In ROS terminology, a program is known as a <em>Node</em>. To interact with other nodes (for example the AR.Drone driver), each node will have some <em>subscribers</em>, which listen for information messages on a specific <em>topic</em> (communications channel); and some <em>publishers</em>, which send messages to a specific <em>topic</em>.</p>
<p>These messages can be anything. An example that we saw in the previous section was the <em>Navdata</em> message, which is sent over the /ardrone/navdata topic and contains feedback data from the AR.Drone.</p>
<p>We will now investigate this message a little further. Open up a new terminal window and type</p>
<pre>rosmsg show ardrone_autonomy/Navdata</pre>
<p>You should be presented with the following output:</p>
<pre>$ rosmsg show ardrone_autonomy/Navdata
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
float32 batteryPercent
uint32 state
int32 magX
int32 magY
int32 magZ
int32 pressure
int32 temp
float32 wind_speed
float32 wind_angle
float32 wind_comp_angle
float32 rotX
float32 rotY
float32 rotZ
int32 altd
float32 vx
float32 vy
float32 vz
float32 ax
float32 ay
float32 az
uint32 tags_count
uint32[] tags_type
uint32[] tags_xc
uint32[] tags_yc
uint32[] tags_width
uint32[] tags_height
float32[] tags_orientation
float32[] tags_distance
float32 tm</pre>
<p>This listing shows us the various members of the Navdata message, including their datatypes. Note that the Navdata message has a header, which includes the time the message is sent.</p>
<h3>Minimum Viable Subscriber</h3>
<p>Open up a new terminal window and type:</p>
<pre>$ roscd ardrone_tutorials
$ geany src/minimum_viable_subscriber.py</pre>
<p>Up will pop a geany window, ready for your to edit the new file. Enter the following into the new geany window, then save and close the file:</p>
<pre><code data-language="python">import roslib
import rospy

roslib.load_manifest('ardrone_tutorials')

from ardrone_autonomy.msg import Navdata

def ReceiveData(data):
  print '[{0:.3f}] Pitch: {1:.3f}'.format(data.header.stamp.to_sec(), data.rotY)

rospy.init_node('minimum_viable_subscriber')
sub_Navdata = rospy.Subscriber('/ardrone/navdata', Navdata, ReceiveData)

while not rospy.is_shutdown():
  pass</code></pre>
<p>We will now use the previously recorded bag-file to test the node that we&#8217;ve just written.</p>
<ol>
<li>In one terminal window, enter:
<pre>$ roscore</pre>
<p>Which begins the roscore process, which coordinates the interactions between nodes.</li>
<li>Now in a new terminal window type:
<pre>$ roscd ardrone_tutorials
$ python src/minimum_viable_subscriber.py</pre>
<p>This will launch the node that we&#8217;ve just programmed.</li>
<li>Finally, in a third terminal window, begin the bag-file playback with:
<pre>$ rosbag play ARDroneFlight.bag</pre>
<ul>
<li>Note you must be in the same directory as the bag-file for the above command to work</li>
</ul>
</li>
<li>If you switch back to the terminal window in which our new node is running, you should see a stream of time-stamped printouts with the drone&#8217;s pitch, for example:
<pre>[1353596639.491] Pitch: 4.375
[1353596639.511] Pitch: 4.128
[1353596639.531] Pitch: 3.750
[1353596639.552] Pitch: 3.304
[1353596639.571] Pitch: 3.063</pre>
</li>
</ol>
<h3>Minimum Viable Subscriber: A Closer Look</h3>
<p>If you made it through the previous section, congratulations, you have successfully written and tested a ROS node, which listens for Navdata measurements from the AR.Drone (or equivalently: a recorded flight) and outputs a time-stamped pitch measurement. But how does it all work?</p>
<p>Lets take a look at the source-code from the previous section, line by line:</p>
<pre><code data-language="python">import roslib
import rospy</code></pre>
<p>With these two lines, we import the standard ROS packages, required for every ROS node.</p>
<pre><code data-language="python">roslib.load_manifest('ardrone_tutorials')</code></pre>
<p>Once the required packages are imported, load the <a href="http://ros.org/wiki/Manifest" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><em>manifest</em> file</a>. This file details the dependencies of the current project (for example, that ardrone_tutorials is dependent on the AR.Drone driver, ardrone_autonomy), which through the above command are loaded into the path.</p>
<pre><code data-language="python">from ardrone_autonomy.msg import Navdata</code></pre>
<p>Once the project dependencies have been loaded, we can import those which are needed by the current node. In the above case, we load the Navdata message definition from the ardrone_autonomy package.</p>
<pre><code data-language="python">def ReceiveData(data):
  print '[{0:.3f}] Pitch: {1:.3f}'.format(data.header.stamp.to_sec(), data.rotY)</code></pre>
<p>Here we define a callback function to handle the Navdata messages. This function prints a formatted string containing the message&#8217;s timestamp and the AR.Drone&#8217;s pitch angle. This callback function will be used later in the program.</p>
<pre><code data-language="python">rospy.init_node('minimum_viable_subscriber')</code></pre>
<p>Before issuing any commands to the rospy package, we need to initialize a ROS node.</p>
<pre><code data-language="python">sub_Navdata = rospy.Subscriber('/ardrone/navdata', Navdata, ReceiveData)</code></pre>
<p>We can now subscribe the node to various topics. Above we subscribe the node to the /ardrone/navdata topic, which carries Navdata messages. Received messages should then be handled by the previously-defined ReceiveData function.</p>
<pre><code data-language="python">while not rospy.is_shutdown():
  pass</code></pre>
<p>Because our program is relying on callbacks for data processing, we need to stop the program from terminating. The above defines a loop that runs until the node is shut down (for example with Ctrl-C). In most situations the above loop would perform some sort of processing, however in our example, we simply pass (do nothing).</p>
<h2>Publishing Data</h2>
<p>In this section we will introduce the concept of publishing data to a topic (the opposite of subscribing). We will be using this more extensively in the next tutorial, where we will be programmatically controlling the AR.Drone by publishing messages to the /cmd_vel topic.</p>
<h3>Minimum Viable Publisher</h3>
<p>The goal of this section is to create a minimum_viable_publisher.py file such that Navdata messages are averaged over a second and the average pitch published to the (new) /ardrone/average_pitch topic. Modify the file as follows:</p>
<pre><code data-language="python">import roslib
import rospy

roslib.load_manifest('ardrone_tutorials')

from ardrone_autonomy.msg import Navdata
from std_msgs.msg import String

messages = []

def ReceiveData(data):
  messages.append(data)

rospy.init_node('minimum_viable_publisher')
sub_Navdata = rospy.Subscriber('/ardrone/navdata', Navdata, ReceiveData)
pub_Average = rospy.Publisher('/ardrone/average_pitch', String)

r = rospy.Rate(1)
while not rospy.is_shutdown():
  if len(messages)&gt;0:
    avg = sum([m.rotY for m in messages])/len(messages)
    messages = []

    avgmsg = String()
    avgmsg.data = 'Average Pitch: {0:.3f}'.format(avg)
    pub_Average.publish(avgmsg)
  r.sleep()</code></pre>
<p>You can run the program using the following series of commands:</p>
<ol>
<li>In one terminal, run:
<pre>$ roscore</pre>
</li>
<li>In the next terminal, run the new program
<pre>$ roscd ardrone_tutorials
$ python src/minimum_viable_publisher.py</pre>
</li>
<li>We now echo the published data to the topic we&#8217;ve created:
<pre>$ rostopic echo /ardrone/average_pitch</pre>
</li>
<li>And finally, like we&#8217;ve done twice before, we begin the playback of our recorded flight
<pre>$ rosbag play ARDroneFlight.bag</pre>
</li>
<li>Switching back to the terminal in which we ranrostopic echo, you should see a new message with the average pitch appearing once a second:
<pre>data: Average Pitch: 0.649
---
data: Average Pitch: 1.078
---
data: Average Pitch: 3.781
---
data: Average Pitch: 3.285
---</pre>
</li>
</ol>
<h3>Minimum Viable Publisher: A Closer Look</h3>
<p>Comparing minimum_viable_publisher.py to minimum_viable_subscriber.py from the last section, we can see many similarities:</p>
<pre><code data-language="python">from ardrone_autonomy.msg import Navdata
from std_msgs.msg import String</code></pre>
<p>We additionally import the String message, required for our new topic.</p>
<pre><code data-language="python">messages = []
def ReceiveData(data):
  messages.append(data)</code></pre>
<p>We have updated the navdata callback function to save the messages in a queue, rather than process them straight away.</p>
<p><strong>Note:</strong> because we&#8217;re accessing the messages list in both a callback function and the main loop, we should be using Python&#8217;s threading.Lock to control access to the list and prevent race conditions. See ardrone_tutorials/src/drone_video_display.py for an example.</p>
<pre><code data-language="python">pub_Average = rospy.Publisher('/ardrone/average_pitch', String)</code></pre>
<p>We create a new publisher, responsible for publishing messages of the String type to the /ardrone/average_pitch topic. Note that we do not need to explicitly initialize this topic, it will be initialized automatically on first usage.</p>
<p>The biggest change is in the program&#8217;s main loop, which I will now cover in a little more detail:</p>
<pre><code data-language="python">r = rospy.Rate(1)</code></pre>
<p>Firstly we define a Rate object. We use this to control the frequency of the main processing loop. In our case, we want to print a message every second, thus we want a frequency of $1 \text{Hz}$.</p>
<pre><code data-language="python">while not rospy.is_shutdown():
  if len(messages)&gt;0:
    avg = sum([m.rotY for m in messages])/len(messages)
    messages = []

    avgmsg = String()
    avgmsg.data = 'Average Pitch: {0:.3f}'.format(avg)
    pub_Average.publish(avgmsg)</code></pre>
<p>If messages have been received, we calculate the average pitch using a python list comprehension to extract the pitch (.rotY) from every Navdata message. We then empty the messages queue.</p>
<p>We then construct a new String message and set its data property, before publishing it to the topic we previously created.</p>
<pre><code data-language="python">r.sleep()</code></pre>
<p>Finally, we tell the rate object to sleep. This command will calculate how long it needs to sleep, such that the desired loop frequency is achieved.</p>
<h2>Conclusions</h2>
<p>I hope you&#8217;ve enjoyed working through this tutorial and learning about data flow in the ROS environment. In the next tutorial, which I will release in a month&#8217;s time, we will use what we have learned today to programmatically control the AR.Drone, while at the same time learning about PID control.</p>
<p>If you have any questions about the tutorial, please leave me a comment below and I will get back to you as soon as possible!</p>
<p>You can see all the tutorials in here: <a href="http://robohub.org/tag/parrot-ar-drone-tutorial/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS</a>.</p>
<p><em>If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Classroom robotics: Motivating independent learning and discovery" href="http://robohub.org/classroom-robotics-motivating-independent-learning-and-discovery/" rel="bookmark" data-wpel-link="internal">Classroom robotics: Motivating independent learning and discovery</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
<p><em> </em></p>
<p><script type="text/x-mathjax-config">// <![CDATA[
MathJax.Hub.Config({
  TeX: { equationNumbers: { autoNumber: "AMS" } }
});
// ]]&gt;</script></p>
<p><script type="text/x-mathjax-config">// <![CDATA[
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
      processEscapes: true
    },
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
// ]]&gt;</script></p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Up and flying with the AR.Drone and ROS: Joystick control</title>
		<link>https://robohub.org/up-and-flying-with-the-ar-drone-and-ros-joystick-control/</link>
		
		<dc:creator><![CDATA[Mike Hamer]]></dc:creator>
		<pubDate>Sat, 05 Jan 2013 04:47:10 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[AR Drone]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[UAVs & drones]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=7071</guid>

					<description><![CDATA[This is the second tutorial in the Up and flying with the AR.Drone and ROS series. In this tutorial we will: Talk about the ROS communication hierarchy Setup a joystick to work with ROS Fly the AR.Drone with a joystick In the previous tutorial we: Installed ROS, the AR.Drone driver and AR.Drone keyboard controller then flew the AR.Drone using the [&#8230;]]]></description>
										<content:encoded><![CDATA[<style type="text/css"><!--
#fstxfloat * {   line-height: 1.5em } #fstxfloat p {   margin-top: 1em;   margin-bottom: 1em; } #fstxfloat pre {   margin-top: 1em;   margin-bottom: 1em; } #fstxfloat ol, #fstxfloat ul {   margin: 10px !important;   padding: 0px !important;   padding-left: 15px !important; } #fstxfloat h2 {   margin-top:2.5em;   font-weight:bold;   font-size:16px; }
--></style>
<a href="https://github.com/mikehamer/ardrone_tutorials" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer"><img decoding="async" class="aligncenter size-full wp-image-6626" title="ARDroneKeyboardControl" alt="" src="http://robohub.org/wp-content/uploads/2013/01/ARDroneJoystickControl.png" width="323" height="216" /></a>
<div style="clear: both;"></div>
<p>This is the second tutorial in the <em>Up and flying with the AR.Drone and ROS</em> series.</p>
<p>In this tutorial we will:</p>
<ol>
<li>Talk about the ROS communication hierarchy</li>
<li>Setup a joystick to work with ROS</li>
<li>Fly the AR.Drone with a joystick</li>
</ol>
<p><span id="more-7071"></span></p>
<p>In the <a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">previous tutorial</a> we:</p>
<ol>
<li>Installed ROS, the AR.Drone driver and AR.Drone keyboard controller then flew the AR.Drone using the provided keyboard controller (<a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">link</a>)</li>
</ol>
<p>In the next tutorials, we will:</p>
<ul>
<li>Look more closely at the data sent back from the drone and play with the on-board tag detection (<a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-handling-feedback/" data-wpel-link="internal">link</a>)</li>
<li>Write a controller for the drone to enable tag following</li>
<li>Write a controller for the drone which allows us to control drone velocity, rather than body angle</li>
</ul>
<h2><strong>What you&#8217;ll need for the tutorial</strong></h2>
<p>To complete this tutorial you will need:</p>
<ol>
<li>An AR.Drone!</li>
<li>A computer or laptop with WiFi</li>
<li>Linux, either the ARDroneUbuntu virtual machine, or a custom installation</li>
<li>A  (linux compatible) USB joystick or control pad</li>
</ol>
<p>I also assume that you&#8217;ve completed the <a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/" data-wpel-link="internal">previous tutorial</a>, which details how to setup the software, connect to the drone, etc.</p>
<div class="aligncenter" style="background-color: #eee; padding: 5px; margin: 10px; margin-top: 4em; border: 1px solid #666; width: 90%;">
<p style="text-align: center; margin-top: 0; padding-top: 0;"><strong>Warning!</strong></p>
<p>In this tutorial, we will be flying the AR.Drone. <strong>Flying inside can be dangerous</strong>. When flying inside, you should always use the propellor-guard and fly in the largest possible area, making sure to stay away from walls and delicate objects. Even when hovering, the drone tends to drift, so always land the drone if not being flown.</p>
<p style="margin: 0px;">I accept no responsibility for damages or injuries that result from flying the drone.</p>
</div>
<h2><strong>Updating</strong></h2>
<p>It has been three weeks since the launch of the first tutorial and I am very happy with the response so far. The tutorial has been viewed over 720 times and ARDroneUbuntu downloaded over 50 times. I was also given the honor of partaking in <a href="http://www.robotgarden.org/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">RobotGarden&#8217;s</a> very first Quadrocoptor Workshop, where we worked through the tutorial (and ironed out the bugs) together.</p>
<p>This response has taught me a few things about how to structure a tutorial series, and how to release a virtual machine. Based on what I have learned, I will be restructuring the source-code for the following tutorials. I will also be updating the virtual machine to reflect these changes.</p>
<p>When writing the first tutorial, I thought it would be better to have a separate repository for each tutorial to keep everything atomic and isolated to ensure the addition of a new tutorial would not affect anything in the past – However having learned from the video-hangout with RobotGarden, I realize this could cause an update nightmare down the track. For this reason, I have decided to operate from a <a href="https://github.com/mikehamer/ardrone_tutorials" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">single repository</a> and will maintain a stable branch for each tutorial, with the master branch always synchronized with the stable version of the latest tutorial. The source-code for each tutorial will also contain all source-code required to run the previous tutorials.</p>
<h2><strong>What this means for you:</strong></h2>
<ul>
<li><strong>If you downloaded the ARDroneUbuntu virtual machine before the release of this tutorial</strong>, you will need to click the &#8220;Update Tutorials&#8221; button <strong>twice</strong>. After this, your virtual machine will be updated to reflect the new changes.</li>
<li><strong>If you installed the tutorials manually</strong>, you will need to run the following at the terminal:
<pre># roscd
# rm -rf ardrone_tutorials_getting_started
# git clone https://github.com/mikehamer/ardrone_tutorials</pre>
</li>
<li><strong>If you have not yet downloaded the VM</strong>, no problems! I have released an up-to-date version that you can download <a href="http://bit.ly/VqtDql" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">from here</a></li>
</ul>
<p>Sorry for any hassle caused by the above, I hope this new structure will allow me to more easily deliver the next tutorials!</p>
<h2><strong>So without further ado, lets check out some data!</strong></h2>
<ol>
<li>Connect to the AR.Drone as detailed in the first tutorial (remembering to disconnect other network adaptors if they use the 192.168.1.x address range)</li>
<li>From within your Linux installation, launch two terminal windows (ARDroneUbuntu users, refer to the first tutorial if you&#8217;re not sure what I mean)</li>
<li>In the first window, launch the KeyboardController from the first tutorial, using the command:
<pre>$ roslaunch ardrone_tutorials keyboard_controller.launch</pre>
</li>
<li>Wait for everything to load and the video display to become active, then in the second terminal window enter the command:
<pre>$ rostopic list</pre>
<p>This command lists all active &#8220;topics&#8221;, the communication channels through which ROS programs (called &#8220;nodes&#8221;) communicate.</li>
<li>To view the currently running ROS Nodes, type:
<pre>$ rxgraph</pre>
<p>The window that appears will show a network of nodes, and how they are connected through the topics that we saw in the previous step.</li>
<li>When you&#8217;re ready, close this window. We&#8217;re now going to have a look at the messages that are being sent between nodes. At the terminal, type:
<pre>$ rostopic echo /ardrone/navdata</pre>
<p>The navdata message is published by the AR.Drone driver at a rate of 50Hz.</li>
<li>Press Ctrl-C to stop echoing the navdata message then switch to the other terminal window and press Ctrl-C again, to stop the roscore program</li>
</ol>
<h2><strong>So what are we setting up today?</strong></h2>
<p>After that whirlwind tour of the ROS communication hierarchy, lets take a look at what we&#8217;ll be building today:</p>
<a href="http://robohub.org/wp-content/uploads/2013/01/ROSCommunication.png" data-wpel-link="internal"><img decoding="async" class="aligncenter size-full wp-image-7336" title="ROSCommunication" alt="" src="http://robohub.org/wp-content/uploads/2013/01/ROSCommunication.png" width="800" height="278" srcset="https://robohub.org/wp-content/uploads/2013/01/ROSCommunication.png 800w, https://robohub.org/wp-content/uploads/2013/01/ROSCommunication-300x104.png 300w, https://robohub.org/wp-content/uploads/2013/01/ROSCommunication-500x173.png 500w" sizes="(max-width: 800px) 100vw, 800px" /></a>
<div style="clear: both;"></div>
<p>As shown above, today we&#8217;ll be setting up the joy_node (a standard ROS package) to listen for input from a joystick or control-pad. This input will be converted into a ROS message, then sent to our controller over the <em>joy</em> topic.</p>
<p>Our controller subscribes to the <em>joy</em> topic and reacts to the received messages by translating joystick movement into drone movement commands, which are then published to the <em>cmd_vel</em> topic; and button presses to takeoff, land, or emergency commands, which are each published to a respective channel.</p>
<p>The ardrone_driver receives these various commands and then sends them via the wireless network to the physical drone, which in turn sends back a video stream. This video stream is published by the ardrone_driver onto the <em>/ardrone/image_raw</em> topic, from where it is received and subsequently displayed by our controller.</p>
<h2><strong>Setting up a joystick</strong></h2>
<p>Firstly, we need to connect the joystick and set it up to work with ROS.</p>
<ol>
<li>Open a terminal window (or reuse one from before), then type:
<pre>$ ls /dev/input</pre>
</li>
<li>Take note of the <strong>jsX</strong> devices (where X is a number). These are not your joystick.</li>
<li>Now connect your joystick to the computer and again type:
<pre>$ ls /dev/input</pre>
</li>
<li>If you see a new <strong>jsX</strong> device appear, congratulations, you&#8217;ve successfully connected the joystick, take note of which device this is, then progress to the next section of the tutorial</li>
<li>If no new jsX device appears when you connect the joystick, you&#8217;re most likely using a virtual machine and may need to add the USB device manually.</li>
<li>If you are using the ARDroneUbuntu virtual machine, open the Machine &gt; Settings window, then the Ports &gt; USB tab. With the joystick plugged in, add a new USB device. Your joystick should appear in the dropdown list.</li>
<li>Click OK, then unplug the joystick from the computer</li>
<li>Repeat steps 3 and 4, plugging the joystick into a different USB port if it is not detected in step 4.</li>
</ol>
<h2><strong>Testing the joystick</strong></h2>
<p>Now that we have the joystick installed, let&#8217;s check to make sure everything is working. Type the following at a terminal, substituting <strong>jsX</strong> for the joystick device you previously identified:</p>
<pre>$ jstest /dev/input/jsX</pre>
<p>If you are greeted with a &#8220;jstest: Permission denied&#8221; error, type:</p>
<pre>$ sudo chmod a+r /dev/input/jsX</pre>
<p>Which enables all users to read the joystick device (ARDroneUbuntu users, the password is: <em>ardrone</em>). After running <em>jstest</em>, moving the joystick should cause the numbers on the screen to update, if not, try running <em>jstest</em> for the other jsX devices. Congratulations, your joystick device is working! Press Ctrl-C to exit.</p>
<h2><strong>Using the joystick with ROS</strong></h2>
<p>Now we&#8217;re ready to integrate the joystick device with the ROS ecosystem using ROS&#8217;s &#8220;Joy&#8221; package.</p>
<ol>
<li>Open up three terminal windows. In the first, launch roscore:
<pre>$ roscore</pre>
</li>
<li>In the second, we launch ROS&#8217;s joystick launcher, replacing jsX with the joystick device you previously identified:
<pre>$ rosparam set joy_node/dev "/dev/input/jsX"
$ rosrun joy joy_node</pre>
</li>
<li>Now in the third terminal window, we echo the Joy messages, sent out by the joy_node that we just launched:
<pre>$ rostopic echo joy</pre>
</li>
<li>If all is working, you should see a Joy message print on the console whenever the joystick is moved (or a button is pressed).</li>
</ol>
<h2><strong>Identifying Control Buttons &amp; Axes</strong></h2>
<p>We now have the task of identifying the various axis and buttons used to fly the drone. All in all, you will need to identify axes to control the AR.Drone&#8217;s roll, pitch, yaw-velocity and z-velocity; and buttons to trigger an emergency, command a takeoff, and command a landing.</p>
<p>To identify the emergency button for example, press the button you would like to trigger an emergency, and watch the terminal to see which button is enabled. In my case, I use the joystick&#8217;s trigger button for emergency (being able to react quickly to an emergency is very important). With the button pressed, the following is printed in the terminal window:</p>
<pre>axes: [-0.0, -0.0, -0.0, -0.0, 0.0, 0.0]
buttons: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</pre>
<p>From this I can identify that: <em>Emergency = Button 0</em> (note that indexing starts from zero). The process follows similarly for identifying an axis:</p>
<ol>
<li>Press the joystick fully left. The axis that changes  (the first number in the list is axis 0) is the <em>roll axis,</em> the number if changes to is your <em>roll scale </em>(usually + or -1)</li>
<li>Press the joystick fully forward. The axis that changes is your <em>pitch axis</em>, and the number it changes to is the <em>pitch scale </em>(usually + or -1)</li>
<li>Rotate your joystick fully counter clockwise, the axis that changes is your <em>yaw axis</em> and the number it changes to is the <em>yaw scale </em>(usually + or -1)</li>
<li>Push your throttle stick fully forwards. The axis that changes is your <em>z-axis</em> and the number it changes to is the <em>z-scale</em> (usually + or -1).</li>
</ol>
<div>A quick example, I push my joystick fully left and see</div>
<pre>axes: [1.0, -0.0, -0.0, -0.0, 0.0, 0.0]
buttons: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</pre>
<p>From this I identify that the <em>Roll Axis = 0 </em>and <em>Roll Scale = 1</em>.</p>
<p>After you have identified all axes and buttons, press Ctrl-C in all terminal windows to stop the processes.</p>
<h2><strong>Configuring the Joystick Controller</strong></h2>
<p>In ROS, a &#8220;Launch File&#8221; is used to configure and launch a set of nodes. We&#8217;ve already seen this in the first tutorial (and at the beginning of this one), where we typed:</p>
<pre>$ roslaunch ardrone_tutorials keyboard_controller.launch</pre>
<p>In this command, <em>keyboard_controller.launch</em> configures the ARDrone driver for indoor flight, then launches both the driver and keyboard controller. Similarly in this tutorial, we will be launching the joystick controller (and related nodes) using a launch file.</p>
<p>Go ahead and open a terminal window, then type:</p>
<pre>$ roscd ardrone_tutorials
$ geany launch/joystick_controller.launchtemplate</pre>
<p>This will open the<em> joystick_controller.launch </em>file in the text editor (non ARDroneUbuntu users can use a text editor of choice). You will need to customize this file for your setup.</p>
<ul>
<li>Update line 21 to reflect your joystick device (the /dev/input/jsX that you identified earlier).</li>
<li>Update lines 27-29 to reflect your button mapping</li>
<li>Update lines 32-35 to reflect your axis mapping</li>
<li>Update lines 38-41 to reflect your scales (usually either 1 or -1)<br />
These scaling factors determine for example the drone roll direction when the joystick is tilted along the roll axis. If your drone does the opposite of what you expect, change the sign on the relevant scaling factor (eg 1 becomes -1)</li>
</ul>
<p>Feel free to have a look at some of the parameters used on the drone. The drone&#8217;s control parameters can potentially be increased to allow for more aggressive flight.</p>
<p>Once you&#8217;re happy with the settings, <strong>save this file as joystick_controller.launch</strong>, then close the geany application.</p>
<h2><strong>Finally flying!</strong></h2>
<p>So, after that rather long endeavor (which you should only need to do once), lets fly!</p>
<p>Connect to the drone, disconnect other network devices, then open a terminal and type:</p>
<pre>$ roslaunch ardrone_tutorials joystick_controller.launch</pre>
<p>This will launch the nodes as you configured in launch file. If all goes well, you should now be able to fly the drone using your joystick.</p>
<p>Before commanding the drone to take-off, you should first check that your emergency button works. With the drone still landed, press the emergency button once. All onboard LEDs should turn red. Pushing the button again will reset the drone, and the LEDs will once again turn green. In addition to this, whenever a (mapped) button is pressed, the joystick_controller will print a message to the terminal, such as &#8220;Emergency Button Pressed&#8221;. This is a further indication that things are working!</p>
<p>You&#8217;re now ready to take off. Have fun!</p>
<h2>Going Further</h2>
<p>The above child&#8217;s play? Heres some ideas for exploring the ROS and ARDrone environment:</p>
<ul>
<li>While the joystick controller is running, open a new terminal window and type:
<pre>$ rxgraph</pre>
<p>This will display the node communication diagram that we investigated at the start of the post</li>
<li>Take a look at the data being sent back from the drone:
<pre>$ rostopic echo /ardrone/navdata</pre>
</li>
<li>Plot your flight speeds (or any other data of interest) with:
<pre>$ rxplot /ardrone/navdata/vx,/ardrone/navdata/vy</pre>
</li>
<li>Adjust drone parameters in the joystick_controller.launch file to fly more aggressively</li>
</ul>
<h2><strong>Troubleshooting</strong></h2>
<ul>
<li><strong>The joystick doesn&#8217;t do anything<br />
</strong>Check that the joystick device you configured in the launch file corresponds to your joystick. To do this, repeat the section &#8220;Testing the Joystick&#8221;</li>
<li><strong>My joystick device is correct, but the joystick doesn&#8217;t do anything<br />
</strong>Assuming you&#8217;ve gone through the &#8220;Testing the Joystick&#8221; section successfully, launch the joystick controller again and in a separate terminal, type:</li>
</ul>
<pre>$ rostopic echo joy</pre>
<p>Assuming everything is configured correctly, this will print joystick messages to the terminal when the joystick is removed.</p>
<ul>
<li>If nothing is printed, check to make sure you&#8217;ve configured the correct joystick device in the launch file, and that the joystick permissions are correct (see &#8220;Testing the Joystick&#8221;).</li>
<li>If something is printed, check to make sure your axis and button mappings in the launch file are correct. If this is the case, leave a comment to this tutorial and I will be happy to help!</li>
</ul>
<p>&nbsp;</p>
<ul>
<li><strong>The drone does the opposite of what I expect<br />
</strong>For example flying backwards when the joystick is tilted forwards. To solve this, determine the axes that respond counterintuitively then invert the sign of the respective scaling factors in the launch file. For example, if the pitch axis (forward-backward) is the opposite of what you would expect, the ScalePitch parameter would change from 1 to -1.</li>
<li><strong>I cannot connect to the drone<br />
</strong>Check that your computer is connected to the drone via wireless, and that all other network devices are disconnected</li>
<li><strong>The drone will not take off</strong></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Are all the onboard LEDs red? If so, try pressing the emergency button. Do they toggle to green? Perfect &#8211; you&#8217;re ready to fly!</li>
<li>If the LEDs are green and the drone still won&#8217;t take off, check that your button mapping is correct in the launch file</li>
</ul>
<p>&nbsp;</p>
<ul>
<li><strong>Other issues?<br />
</strong>If you have any questions, or comments about what you would like to see in the next tutorials, please send me a message or leave a comment to this post!</li>
</ul>
<p>You can see all the tutorials in here: <a href="http://robohub.org/tag/parrot-ar-drone-tutorial/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS</a>.</p>
<p><em>If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Classroom robotics: Motivating independent learning and discovery" href="http://robohub.org/classroom-robotics-motivating-independent-learning-and-discovery/" rel="bookmark" data-wpel-link="internal">Classroom robotics: Motivating independent learning and discovery</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
<p><em> </em></p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Up and flying with the AR.Drone and ROS: Getting started</title>
		<link>https://robohub.org/up-and-flying-with-the-ar-drone-and-ros-getting-started/</link>
		
		<dc:creator><![CDATA[Mike Hamer]]></dc:creator>
		<pubDate>Mon, 10 Dec 2012 21:49:29 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[AR Drone]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[UAVs & drones]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=6625</guid>

					<description><![CDATA[Updated December 17th. In this tutorial (#1) we will: Install ROS, the AR.Drone driver and AR.Drone keyboard controller Fly the AR.Drone using the provided keyboard controller In tutorials 2-5, we will: Modify the keyboard controller to work with a joystick or control pad, giving much finer control (link) Look more closely at the data sent [&#8230;]]]></description>
										<content:encoded><![CDATA[<style type="text/css"><!--
#fstxfloat * { line-height: 1.5em } #fstxfloat p { margin-top: 1em; margin-bottom: 1em; } #fstxfloat pre { margin-top: 1em; margin-bottom: 1em; } #fstxfloat ol, #fstxfloat ul { margin: 10px !important; padding: 0px !important; padding-left: 15px !important; } #fstxfloat h2 { margin-top:2.5em; font-weight:bold; font-size:16px; }
--></style>
<a href="http://robohub.org/wp-content/uploads/2012/12/ARDroneKeyboardControl.png" data-wpel-link="internal"><img decoding="async" class="size-full wp-image-6626" title="ARDroneKeyboardControl" alt="" src="http://robohub.org/wp-content/uploads/2012/12/ARDroneKeyboardControl.png" width="323" height="216" srcset="https://robohub.org/wp-content/uploads/2012/12/ARDroneKeyboardControl.png 323w, https://robohub.org/wp-content/uploads/2012/12/ARDroneKeyboardControl-300x200.png 300w" sizes="(max-width: 323px) 100vw, 323px" /></a>
<div style="clear: both;"><span style="color: #ff0000;">Updated December 17th.</span></div>
<p>In this tutorial (#1) we will:</p>
<ol>
<li>Install ROS, the AR.Drone driver and AR.Drone keyboard controller</li>
<li>Fly the AR.Drone using the provided keyboard controller<span id="more-6625"></span></li>
</ol>
<p>In tutorials 2-5, we will:</p>
<ol start="2">
<li>Modify the keyboard controller to work with a joystick or control pad, giving much finer control (<a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-joystick-control/" data-wpel-link="internal">link</a>)</li>
<li>Look more closely at the data sent back from the drone and play with the onboard tag detection (<a href="http://robohub.org/up-and-flying-with-the-ar-drone-and-ros-handling-feedback/" data-wpel-link="internal">link</a>)</li>
<li>Write a controller for the drone to enable tag following</li>
<li>Write a controller for the drone which allows us to control drone velocity, rather than body angle</li>
</ol>
<h2><strong><span style="color: #ff0000;">Updates:</span></strong></h2>
<p>Based on feedback I received from a video hangout with <a href="http://www.robotgarden.org/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Robot Garden</a> (cofounded by fellow Robohub author, Andra Keay), I have made a few updates to the tutorial, summarized below and highlighted throughout the tutorial in red:</p>
<ol>
<li><strong>Fixed permissions problem which caused the keyboard button on the launch bar to do nothing</strong></li>
<li>Added keyboard_controller_with_tags.launch file, which enables the drone&#8217;s tag detection feature</li>
<li>Updated tutorial with command-line equivalent commands, for all graphical actions</li>
<li>Included a &#8220;Going Further&#8221; section at the end of the tutorial</li>
</ol>
<p>If you are running the ARDroneUbuntu virtual machine, updating the tutorial will download the above updates and fixes.</p>
<pre>Command-line equivalent (updating the tutorial):
$ roscd ardrone_tutorials
$ git pull</pre>
<h2><strong>What is the AR.Drone?</strong></h2>
<p>The <a href="http://ardrone2.parrot.com" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">AR.Drone</a> is a quadrotor that can be flown from any WiFi enabled device with an appropriate application &#8211; most commonly an iPhone or Android phone.</p>
<p>Unlike other quadrotors, which can be difficult to fly manually, the AR.Drone is equipped with onboard sensors and controllers that stabilize the vehicle while flying and give it the ability to hover on a spot and await the next command. Because of this onboard stabilization, the AR.Drone is becoming very popular as both a toy (it can be flown by even the most inexperienced pilots), and as a research platform for computer vision and robotic exploration (researchers can focus on their algorithms without worrying that the drone will crash).</p>
<h2><strong>And what is ROS?</strong></h2>
<p><a href="http://www.ros.org" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">ROS</a>, the &#8220;Robot Operating System&#8221;, is a software framework that enables the development of robotic applications &#8211; applications that control and interact with robots. A large number of groups using the AR.Drone for research purposes, use ROS to control the drone, which is why we are focusing on it here.</p>
<h2><strong>What you&#8217;ll need for the tutorial</strong></h2>
<p>To complete this tutorial you will need:</p>
<ol>
<li>An AR.Drone!</li>
<li>A computer or laptop with WiFi</li>
</ol>
<p>For future tutorials, you will need:</p>
<ol>
<li>USB Joystick or control pad  (linux compatible)</li>
</ol>
<h2><strong>Getting started</strong></h2>
<p>For these tutorials, we will be running the ROS software and AR.Drone controllers using the Linux operating system.</p>
<p><strong><em>If you don&#8217;t have Linux, want to get flying quickly or don&#8217;t know what I&#8217;m talking about:</em></strong></p>
<p>To get started, we&#8217;ll be downloading an &#8220;Xubuntu Virtual Machine&#8221;, which has been created especially for these tutorials. This virtual machine package contains everything that you need to get up and flying &#8211; fast!</p>
<p>To run the virtual machine package, you will first need to download and install the free <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Virtual Box software</a>. You will also want to download the <a href="http://bit.ly/VqtDql" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">ARDroneUbuntu</a> virtual machine package.</p>
<p>Once you have Virtual Box installed, double click the <em>ARDroneUbuntu.ova</em> file that you downloaded. This will open it in the Virtual Box program.</p>
<p>A settings/import dialog should open. You should leave these settings as they are, unless you know what you&#8217;re doing.</p>
<p>After completing the import process, click start in the Virtual Box program to begin running ARDroneUbuntu.</p>
<p>Congratulations, you&#8217;re now running Xubuntu 12.04 (<strong>username</strong>: ardrone, <strong>password</strong>: ardrone)!  This has been preconfigured with all the software required for this series of tutorials, so you&#8217;re now good to go!</p>
<p>Once the virtual machine is running, you will be brought to the desktop. At the bottom of the screen you will see the launch bar:</p>
<a href="http://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png" data-wpel-link="internal"><img decoding="async" class="size-full wp-image-6627" title="VM Launchbar" alt="" src="http://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png" width="506" height="80" srcset="https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png 506w, https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar-300x47.png 300w, https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar-500x79.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></a>
<div style="clear: both;"></div>
<p>The launch bar contains a number of icons, which I will be referring to throughout the tutorial:</p>
<ol>
<li><strong>Terminal</strong> &#8211; in this program, you run text-based programs and commands</li>
<li><strong>Text Editor </strong>&#8211; we will be using this in future tutorials to write some basic programs</li>
<li><strong>Keyboard Controller</strong> &#8211; this launches the keyboard controller</li>
<li><strong>Update Tutorials </strong>&#8211; this will update the AR.Drone driver and tutorial source code, it will also install new tutorials once they have been released.</li>
<li><strong>Quick Command Box</strong> &#8211; this is like the terminal and can be used for sending a quick command to the operating system</li>
</ol>
<p>Great, now that you&#8217;re up and running, lets update the tutorial files. Click the Update Tutorials (#4) button in the launch bar. This will launch a terminal window in which it will download and install any required software updates. You should be connected to the internet for this step.</p>
<pre>Command-line equivalent (updating the driver):
$ roscd ardrone_autonomy
$ git pull
$ rosmake ardrone_autonomy</pre>
<pre>Command-line equivalent (updating the tutorial):
$ roscd ardrone_tutorials
$ git pull
$ rosmake ardrone_tutorials</pre>
<p>Now you&#8217;re ready to fly and can skip the next section of the tutorial.</p>
<p><em><strong>If you have Linux (skip this section if you just downloaded the virtual machine):</strong></em></p>
<p>I&#8217;ll assume you understand enough about linux to follow the <a href="http://www.ros.org/wiki/fuerte/Installation/Ubuntu" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">ROS installation instructions</a> (summarized <a href="http://nootrix.com/2012/05/ros-installation/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">here</a>). I also assume you are running Ubuntu (or a deviant). If not, you should modify the apt-get commands to suit your system.</p>
<p>In addition to the summarized ROS installation instructions above, you will need to run:</p>
<pre>$ sudo rosdep init
$ rosdep update
$ sudo apt-get install ros-fuerte-joystick-drivers
$ rosdep install joy</pre>
<p>This will install the joystick drivers which are used in a future tutorial.</p>
<p>Now to install the AR.Drone driver&#8217;s prerequisites:</p>
<pre>$ sudo apt-get install daemontools libudev-dev libiw-dev</pre>
<p>Next, we will download the <a href="https://github.com/AutonomyLab/ardrone_autonomy" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">AR.Drone driver</a> (full disclosure: I am a regular contributor to the driver) and the keyboard controller used for this tutorial:</p>
<pre>$ roscd
$ pwd
~/ros_workspace
$ git clone https://github.com/AutonomyLab/ardrone_autonomy.git
$ git clone https://github.com/mikehamer/ardrone_tutorials.git
$ ls
...  ardrone_autonomy  ardrone_tutorials  ...
$ rospack profile</pre>
<p>And now to compile the packages:</p>
<pre>$ roscd ardrone_auto&lt;TAB should autocomplete&gt;
$ ./build_sdk.sh
$ rosmake -a</pre>
<p>If TAB does not autocomplete the above-indicated command, or if rosmake reports any failures, you may have a problem with your installation. If this is the case, you should check the installation guide linked above.</p>
<p>If you&#8217;ve completed all of the above successfully, you&#8217;re ready to move on!</p>
<h2><strong>Warning!</strong></h2>
<p>We are now going to fly the drone. <strong>Flying inside can be dangerous</strong>. When flying inside, you should always use the propellor-guard and fly in the largest possible area, making sure to stay away from walls and delicate objects. Even when hovering, the drone tends to drift, so always land the drone if not being flown.</p>
<p>I accept no responsibility for damages or injuries that result from flying the drone.</p>
<p>If you have a laptop and are thus able to fly outside, check the last section of this tutorial for instructions on reconfiguring the drone.</p>
<h2><strong>First connection</strong></h2>
<p>Great, we&#8217;ve got the software, now lets have some fun!</p>
<p>Turn on the drone and wait until the propellors vibrate, indicating that the drone is ready.</p>
<p>Now connect your computer&#8217;s wireless to the AR.Drone&#8217;s network, just like you would connect to a normal wireless network. The network will be called <strong>ardrone&lt;something&gt;</strong>.</p>
<p>If your computer is also connected to a network via ethernet (or any other network adaptor), disconnect it. We only want the wireless network to be running*</p>
<p><em>* Advanced users: The drone acts as a wireless server and assigns itself (via its DHCP server) a fixed IP address of 192.168.1.1 and your wireless card an address from 192.168.1.2-255. For this reason, there can be routing issues if your ethernet card is also in the 192.168.1.0 subnet.</em></p>
<h2><strong>Running the keyboard controller</strong></h2>
<p><em><strong>If you&#8217;re using the supplied virtual machine:</strong></em></p>
<p>Click on the keyboard icon (#3) in the launch bar to run the keyboard controller program:</p>
<a href="http://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png" data-wpel-link="internal"><img decoding="async" class="size-full wp-image-6627" title="VM Launchbar" alt="" src="http://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png" width="506" height="80" srcset="https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar.png 506w, https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar-300x47.png 300w, https://robohub.org/wp-content/uploads/2012/12/VM-Launchbar-500x79.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></a>
<div style="clear: both;"></div>
<p>Note that a connection can take up to 10 seconds. If after 10 seconds the window still says &#8220;Disconnected&#8221;, check the wireless connection to the drone, and check that any network cables have been unplugged from the computer.</p>
<p><em><strong>If you&#8217;re using a custom Linux installation or want to use the command line:</strong></em></p>
<p>Open a terminal window and type the command:</p>
<pre>roslaunch ardrone_tutorials keyboard_controller.launch</pre>
<p>Pressing TAB at various stages throughout the command should autocomplete. If this is not the case, or if this command causes errors, check that you have setup your .bashrc file as per the ROS installation guide, and that you ran <strong>rospack profile</strong> after cloning the two git repositories.</p>
<p>If successful, this command will print out many startup messages, including:</p>
<pre>Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",)...</pre>
<p>This exception is a Python bug and won&#8217;t affect the program.</p>
<p>You will also see a printout:</p>
<pre>process[ardrone_driver-2]: started with pid [6178]
===================+&gt; 192.168.1.1</pre>
<p>Within a few seconds, the output should progress well past this stage and begin printing configuration messages as the initialization of the AR.Drone progresses. If this is not the case, check the wireless connection to the drone, and check that any network cables have been unplugged from the computer.</p>
<h2><strong>Up, up and away!</strong></h2>
<p>If the keyboard controller launched successfully, you will now be seeing a live video stream from the drone. If this is the case, we&#8217;re ready to fly!</p>
<p>The controls (defined in ardrone_tutorials/src/keyboard_controller.py) are:</p>
<ul>
<li><strong>E</strong> &#8211; Pitch Forward</li>
<li><strong>D</strong> &#8211; Pitch Backward</li>
<li><strong>S</strong> &#8211; Roll Left</li>
<li><strong>F</strong> &#8211; Roll Right</li>
<li><strong>W</strong> &#8211; Yaw Left</li>
<li><strong>R</strong> &#8211; Yaw Right</li>
<li><strong>Q</strong> &#8211; Increase Altitude</li>
<li><strong>A</strong> &#8211; Decrease Altitude</li>
<li><strong>Y</strong> &#8211; Takeoff</li>
<li><strong>H</strong> &#8211; Land</li>
<li><strong>SPACEBAR &#8211; EMERGENCY STOP</strong></li>
</ul>
<p><span style="color: #ff0000;">Update 17/12:<br />
Note: Pressing the Spacebar will toggle the drone between an emergency state (all onboard LEDs are red), and the ready state (all onboard LEDs are green). If your drone isn&#8217;t responding to commands, make sure it is in the ready state!</span></p>
<p>With that said, I now hand the controls to you. Remember to keep a thumb on the Spacebar at all times, just in case something goes wrong.</p>
<p>Have fun!</p>
<h2><strong><span style="color: #ff0000;">Going Further (Added 17/12/2012)</span></strong></h2>
<p>This tutorial was fairly straight forward, the purpose being simply to get you up and running with the right software. Future tutorials will be more technical, however if you&#8217;re wanting to scratch the itch, try running some of the following commands at the terminal:</p>
<p><strong><em>With a controller running:</em></strong></p>
<pre>$ rostopic echo /ardrone/navdata</pre>
<p>Will print the data packets that are being sent back from the drone at 50Hz.</p>
<pre>$ rosservice call /ardrone/togglecam</pre>
<p>Will toggle the drone&#8217;s video stream between front and bottom cameras.</p>
<pre>$ rxplot /ardrone/navdata/ax:ay /ardrone/navdata/vx:vy</pre>
<p>Will plot the x and y acceleration on one plot, and the estimated x and y velocity on a second plot.</p>
<p><strong><em>Now without a controller running (ie close the keyboard_controller window)</em></strong></p>
<pre>$ roslaunch ardrone_tutorials keyboard_controller_with_tags.launch</pre>
<p>This runs a new launch file that enables tag detection. Now run:</p>
<pre>$ rostopic echo /ardrone/navdata</pre>
<p>And have a look at the various tag detection data that is returned (you have to be holding tags in front of or below the drone for this to work).</p>
<p>By default, this launch file configures the drone to detect Orange-Blue-Orange stickers on the front facing camera, and the A4 &#8220;Oriented Roundel&#8221; that comes with the AR.Drone 2.0 on the downward facing camera.</p>
<p>If your stickers are a different color, change the launch-file parameter <em>enemy_colors</em> to 1 for Orange-Green-Orange, 2 for Orange-Yellow-Orange and 3 for Orange-Blue-Orange.</p>
<h2><strong>Coming up in tutorial #2 &#8211; Joystick control</strong></h2>
<p>By now you may have noticed that flying with the keyboard isn&#8217;t so easy. This is largely due to the binary nature of a keypress (not pressed/pressed), which translates into 0%/100% control. Although we could implement software remedies such as input windup based on how long the key has been held, this is for the most part only a band-aid solution; what we really need is an analogue input device. Enter the Joystick (or control pad).</p>
<p>In the second tutorial of this series, we will be covering a little ROS theory (topics, messages and launch files), before installing a joystick, linking it up to the ROS system and then using it to fly the drone.</p>
<h2><em><strong>Source code and configuration</strong></em></h2>
<p>For those of you interested in the source code or configuration, I will briefly discuss the various options below. We will be going into much more detail in the next tutorial.</p>
<p>Full source code for this tutorial is available from the <a href="https://github.com/mikehamer/ardrone_tutorials" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">GitHub repository</a>.</p>
<p><strong>src/drone_controller.py</strong></p>
<p>This file provides an abstracted interface to the AR.Drone driver and shouldn&#8217;t need to be modified</p>
<p><strong>src/drone_video_display.py</strong></p>
<p>This file implements the video display window and shouldn&#8217;t need to be modified</p>
<p><strong>src/keyboard_controller.py</strong></p>
<p>This file brings everything together. The KeyboardController class implemented in this file extends the DroneVideoDisplay class, adding a keyboard handler for control. Key mappings are defined in this file and can be changed to suit your preferences.</p>
<p><strong>launch/keyboard_controller.launch</strong></p>
<p>This is the default configuration file, which sets the drone&#8217;s configuration and launches all required processes</p>
<p><strong>launch/keyboard_controller_outdoor.launch</strong></p>
<p>This configuration file implements a more aggressive set of flight parameters for outdoor flight. If you are wanting to fly outdoors, the keyboard controller can be launched with the command:</p>
<pre>roslaunch ardrone_tutorials keyboard_controller_outdoor.launch</pre>
<p>For more information about configuring the AR.Drone, have a look at the <a href="https://github.com/AutonomyLab/ardrone_autonomy" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">AR.Drone driver&#8217;s</a> readme.</p>
<h2><strong>That&#8217;s all folks</strong></h2>
<p>I hope you&#8217;ve had fun with this tutorial and I look forward to bringing you the next one in two weeks time!</p>
<p>If you have any questions, or comments about what you would like to see in the next tutorials, please send me a message or leave a comment to this post! You can see all the tutorials in here: <a href="http://robohub.org/tag/parrot-ar-drone-tutorial/" data-wpel-link="internal">Up and flying with the AR.Drone and ROS</a>.</p>
<div class="divideronpost"></div>
<p><em>If you liked this article, you may also be interested in:</em></p>
<ul>
<li><a title="Permalink to Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft" href="http://robohub.org/parrot-ar-drone-app-harnesses-crowd-power-to-fast-track-vision-learning-in-robotic-spacecraft/" rel="bookmark" data-wpel-link="internal">Parrot AR.Drone app harnesses crowd power to fast-track vision learning in robotic spacecraft</a></li>
<li><a href="http://robohub.org/taking-your-first-steps-in-robotics-with-the-thymio-ii/" data-wpel-link="internal">Taking your first steps in robotics with the Thymio II</a></li>
<li><a title="Permalink to Discovering social robotics with the Aisoy1" href="http://robohub.org/discovering-social-robotics-with-the-aisoy1/" rel="bookmark" data-wpel-link="internal">Discovering social robotics with the Aisoy1</a></li>
<li><a title="Permalink to Classroom robotics: Motivating independent learning and discovery" href="http://robohub.org/classroom-robotics-motivating-independent-learning-and-discovery/" rel="bookmark" data-wpel-link="internal">Classroom robotics: Motivating independent learning and discovery</a></li>
</ul>
<p><em>See all <a href="http://robohub.org/" data-wpel-link="internal">the latest robotics news</a> on Robohub, or <a href="http://eepurl.com/t-UEf" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">sign up for our weekly newsletter</a>.</em></p>
<p><em> </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Google+ Hangout extension &#8211; Arduino example</title>
		<link>https://robohub.org/google-hangout-extension-arduino-example/</link>
		
		<dc:creator><![CDATA[RobotGrrl]]></dc:creator>
		<pubDate>Sat, 27 Oct 2012 19:47:29 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robohub.org/?p=4837</guid>

					<description><![CDATA[New tutorial- Get your Arduino working with Google+ Hangouts! Watch video on YouTube Learn more here]]></description>
										<content:encoded><![CDATA[<p>New tutorial- Get your Arduino working with Google+ Hangouts!</p>
<div class=" "><iframe title="Google+ Hangout Extension - Arduino Example" width="500" height="281" src="https://www.youtube-nocookie.com/embed/Y1bdxf9tZWw?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>
<a href="http://www.youtube.com/watch?v=Y1bdxf9tZWw" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Watch video on YouTube</a></p>
<p><a href="http://robobrrd.com/learn/googleplus/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Learn more here</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Rapid robot prototyping with ROS</title>
		<link>https://robohub.org/rapid-robot-prototyping-with-ros/</link>
		
		<dc:creator><![CDATA[David Pietrocola]]></dc:creator>
		<pubDate>Fri, 19 Oct 2012 12:05:49 +0000</pubDate>
				<category><![CDATA[education]]></category>
		<category><![CDATA[kinect]]></category>
		<category><![CDATA[roomba]]></category>
		<category><![CDATA[ROS]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">http://robotsindc.com/?p=278</guid>

					<description><![CDATA[In the first installment of this tutorial we described how one can quickly control a roomba through any web-enabled device using open source robotics software. To recap, we connected a roomba to a laptop running: ROS, the open source Robot Operating &#8230; <a href="http://robotsindc.com/?p=278" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Continue reading <span>&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>Open-source software is making it easier to reuse algorithms and allow engineers and researchers to focus on their problems of interest instead of reinventing the wheel for each project. Not an expert in path planning or don&#8217;t have the time (or patience) to implement SLAM? There&#8217;s a package for that. Manipulator control? Package for that too. Additionally, falling component prices and commercial-off-the-shelf (COTS) devices are making robotics hardware more available. This tutorial will teach you how to put together a simple remote teleoperation robot using these principles.<br />
<span id="more-4386"></span><br />
There are a <a href="http://en.wikipedia.org/wiki/Open-source_robotics" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">few frameworks</a> in the robotics domain, but the one that is reaching critical mass (in the robotics research community at least) is Willow Garage&#8217;s <a href="http://www.ros.org/wiki/" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Robot Operating System,</a> or just ROS. Plenty of people have written about its features and if you&#8217;re interested Willow Garage has an excellent <a href="http://www.ros.org/wiki/ROS/Tutorials" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">set of tutorials</a>, so I won&#8217;t do that here. We are going to break the tutorial into two parts: first, we&#8217;ll get a robot moving using ROS through a webpage user interface; and second, we&#8217;ll build on that to add a Kinect and enable remote teleoperation. Here&#8217;s what you&#8217;ll need to get started:<br />
</p>
<ol>
<li> iRobot Roomba or Create</li>
<li>ROS Electric installed on Ubuntu Linux and configured according to the <a href="http://www.ros.org/wiki/ROS/Tutorials" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">tutorials</a></li>
<li>Some way of connecting the robot to your computer (<a href="http://www.sparkfun.com/products/10980" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">1</a>, <a href="http://store.irobot.com/product/index.jsp?productId=2818673" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">2</a>, or modify a USB-to-serial connector to interface with the mini-DIN port). For teleoperation, you can use the connected computer, another computer, smart phone, tablet, iPad, or anything with a browser supporting web sockets.</li>
</ol>
<p>Let&#8217;s get into the specifics. With ROS installed, you&#8217;ll need a few more packages that aren&#8217;t included in the base install. <a href="http://www.ros.org/wiki/rosbridge" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">Rosbridge</a> is a solid middleware package that is going to enable communication with ROS through a webpage. It can do a lot more, but this satisfies our goal for now. Let&#8217;s install that (from Brown <a href="http://www.youtube.com/watch?v=kaiwwaqH9jA" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">screencast</a>):</p>
<pre>&gt; sudo apt-get install ros-electric-brown-remotelab</pre>
<p>You&#8217;ll also need a package to enable ROS to communicate with the robot. The package, at its most basic functionality, will listen for Twist messages (ROS-speak for motor drive commands), and convert it to the low-level serial commands for the roomba. (Though this tutorial focuses on roomba/create, you can use any robot with an existing ROS package, or write your own!) You have three options, based on your roomba model:<br />
</p>
<ol>
<li>iRobot Roomba 500 series or up (uses iRobot OI <a href="http://www.irobot.com/filelibrary/pdfs/hrd/create/create%20open%20interface_v2.pdf" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">spec</a> [pdf])</li>
<li>iRobot Roomba pre-500 series (uses iRobot SCI <a href="http://www.irobot.com/images/consumer/hacker/roomba_sci_spec_manual.pdf" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">spec</a> [pdf])</li>
<li>iRobot Create (uses iRobot OI spec)</li>
</ol>
<p></p>
<div>There are packages for all three of these. I happen to have a Roomba 400-series so I went ahead and modified the <a href="http://www.ros.org/wiki/roomba_500_series" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">roomba_500_series</a> package for SCI commands. This is perfect for older roombas you might have gathering dust or picked up for cheap on ebay. There&#8217;s also a <a href="http://bilibot-ros-pkg.googlecode.com/svn/trunk/bilibot/create_driver/src/create_driver.py" target="_blank" data-wpel-link="external" rel="follow external noopener noreferrer">python implementation</a> floating around. Whichever you use, the other parts of the system won&#8217;t care because they&#8217;re publishing Twist messages and the robot will be subscribing to Twist messages. If you don&#8217;t have a folder for third-party ROS packages or didn&#8217;t follow the ROS tutorials, let&#8217;s create one in your home directory and download my <a href="https://github.com/dpiet/robotsindc-ros-pkg" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">roomba_400_series package</a>:</div>
<pre>&gt; mkdir ros_workspace
&gt; cd ros_workspace
&gt; mkdir myStacks
&gt; cd myStacks
&gt; git clone https://github.com/dpiet/robotsindc-ros-pkg</pre>
<p>Be sure to rosmake. Check to make sure the directory (or parent directory) is included in the ROS package path:</p>
<pre>&gt; echo ROS_PACKAGE_PATH</pre>
<p>If it&#8217;s not, add it:</p>
<pre>&gt; export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/david/ros_workspace</pre>
<p>There&#8217;s one more piece we need in order to control the robot through a webpage: the webpage. Fortunately, there are plenty of rosbridge examples out there and a javascript novice like me was able to hack together a simple page with keyboard inputs and button inputs. Download the <a href="https://github.com/dpiet/robotsindc-ros-pkg/blob/master/teleop.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">page</a> (or you already have it if you cloned the git repo) to your web server directory (if you&#8217;re running one) or to you /home and you need only modify the IP address to point to the computer controlling the robot. And that&#8217;s it!<br />
<br />
Here&#8217;s the procedure for putting this altogether at execution:<br />
<br />
In a separate terminal for each line, run the following commands:</p>
<pre>&gt; roscore
&gt; rosrun roomba_400_series roomba400_light_node (assumes robot is attached to /dev/ttyUSB0)
&gt; rosrun rosbridge rosbridge.py
(Optional) if you don't have a webserver, cd to your /home directory with the teleop.html file and use the magic of python:
&gt; python -m SimpleHTTPServer</pre>
<p></p>
<ol>
<li>Grab your iPad (or other device), make sure it&#8217;s on the same wifi local network as the robot computer, and load up the page. If you&#8217;re running SimpleHTTPServer, type this in: http://[robot ip address here]:8000/teleop.html</li>
<li>If all goes according to plan you&#8217;ll get a rudimentary screen with buttons for directional control and a log showing connection status messages</li>
<li> <a href="http://youtu.be/eisPM2ReN00" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Happy roomba driving!</a></li>
</ol>
<div class=" "><iframe title="How to Control Roomba with your iPad" width="500" height="281" src="https://www.youtube-nocookie.com/embed/eisPM2ReN00?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>To recap, we connected a roomba to a laptop running: ROS, the open source <a href="http://www.ros.org/wiki/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Robot Operating System</a> from <a href="http://www.willowgarage.com/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Willow Garage</a>; <a href="http://rosbridge.org/doku.php" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Rosbridge</a>, a convenient middleware package from Brown University; and a web server (in this case Python’s SimpleHTTPServer). We were then able to load up a webpage with some javascript from a laptop, android smartphone, or iPad, with each able to drive the roomba with basic forward/reverse/left/right commands. Cool.<br />
<br />
By using ROS and a few open source packages, we were able to get going with a moving robot via teleoperation with a simple user interface relatively quickly, or at least much quicker than if we were to program everything from scratch. So the benefit has been the ability to stand up a teleoperation robot in short order through code reuse. A criticism is that we used a fairly heavy framework, with a lot of pieces working under the hood, which means a lot of upfront work to read system documentation/tutorials and review examples. But as I argued above, the upfront cost is worth it, because now the robot is based on software modules with a <a href="http://answers.ros.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">vibrant community</a> of contributors that facilitates code reuse without you having to reinvent the wheel or become a path-planning expert.<br />
<br />
To take advantage of the upfront work we put in to learning ROS, we can now easily extend the first part of the tutorial and add a video feed to our web interface so we can now teleoperate <em>remotely. </em>Here’s what we need to add:<br />
// </p>
<ul>
<li>The <a href="http://www.ros.org/wiki/mjpeg_server" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">mjpeg_server</a> ROS package (to install, download <a href="http://svn.code.sf.net/p/bosch-ros-pkg/code/trunk/stacks/mjpeg_server/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">the package</a> or svn checkout. cd into the directory and run “rosmake –rosdep-install”)</li>
<li>Microsoft Kinect <a href="http://www.ros.org/wiki/openni_kinect" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">ROS package</a> using OpenNI drivers (to install, run “sudo apt-get install ros-electric-openni-kinect”)</li>
<li>A new <a href="https://github.com/dpiet/robotsindc-ros-pkg/blob/master/teleop_video.html" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">html file</a> with some additional javascript</li>
</ul>
<p></p>
<div>That’s it. The Kinect package takes care of interfacing the camera and IR streams, publishing the data to ROS topics. The mjpeg_server subscribes to that camera topic and sets up a streaming server that efficiently streams the video through HTTP. Rosbridge could be used to stream video directly by subscribing to the camera topic, but it won’t be as efficient.</div>
<p>
The following video demonstrates the first run after integrating all the components on the robot. Not too bad, but there’s definitely room for improvement. Next steps will be to add a roslaunch file to our repo to simplify startup, accelerometer controls for navigation, and further testing to identify sources of lag.<br />
</p>
<div class=" "><iframe title="Driving roomba through a web browser" width="500" height="281" src="https://www.youtube-nocookie.com/embed/cq5fegtH_tc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<p>Here’s the procedure for getting the demo running. Be sure to change the robot’s IP address as appropriate. <em>Please note</em>: this demo is currently compatible with ROS Electric, not the latest version, Fuerte.<br />
<br />
In a separate terminal for each line, run the following commands:</p>
<pre>&gt; roscore
&gt; rosrun roomba_400_series roomba400_light_node (assumes robot is attached to /dev/ttyUSB0)
&gt; rosrun rosbridge rosbridge.py
&gt; rosrun mjpeg_server mjpeg_server _port:=9091
&gt; roslaunch openni_launch openni.launch
(Optional) if you don't have a webserver, cd to your /home directory with the teleop_video.html file and use the magic of python:
&gt; python -m SimpleHTTPServer</pre>
<p>Where can we go from here? We’ve essentially built a <a href="http://www.willowgarage.com/turtlebot" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Turtlebot</a>, replacing the iRobot Create with the roomba (though we’re obviously missing the convenient mounting hardware). So there are plenty of resources for integrating advanced behaviors like mapping, autonomous navigation, or even a manipulator arm. In particular, the <a href="http://www.pirobot.org/" data-wpel-link="external" target="_blank" rel="follow external noopener noreferrer">Pi Robot project</a> has done some interesting demonstrations with the Turtlebot platform.<br />
<br />
Have a roomba gathering dust and a Kinect sitting next to your Xbox? Then you have all the major components to build a moving robot.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: robohub.org @ 2026-11-29 06:20:18 by W3 Total Cache
-->