<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Robot Log</title>
	<atom:link href="http://roachnet.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://roachnet.wordpress.com</link>
	<description>Behavior-Based Autonomous Robotics - The Mindstorms way!</description>
	<lastBuildDate>Tue, 01 Sep 2009 04:14:00 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='roachnet.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9d470cd89db8a366630bf70ad5bac1ce?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>My Robot Log</title>
		<link>http://roachnet.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://roachnet.wordpress.com/osd.xml" title="My Robot Log" />
		<item>
		<title>Follow a Line &#8211; Line Following Basics</title>
		<link>http://roachnet.wordpress.com/2009/08/31/follow-a-line-line-following-basics/</link>
		<comments>http://roachnet.wordpress.com/2009/08/31/follow-a-line-line-following-basics/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 04:14:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[My Robots]]></category>
		<category><![CDATA[PathBot]]></category>
		<category><![CDATA[follow]]></category>
		<category><![CDATA[light sensor]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[line leader]]></category>
		<category><![CDATA[mindsensors]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[robotc]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/08/31/follow-a-line-line-following-basics/</guid>
		<description><![CDATA[
Summary
There are many ways (and sensors) available that can allow a robot to follow a line. I have experimented a few that are of interest.

Single Light Sensor 
Two Light Sensors 
Mindsensors LineLeader Sensor (Intelligent array of 8 light sensors in one I2C package) 

In this article I review a couple of standard ways of staying [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=227&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h4></h4>
<h2>Summary</h2>
<p>There are many ways (and sensors) available that can allow a robot to follow a line. I have experimented a few that are of interest.</p>
<ul>
<li>Single Light Sensor </li>
<li>Two Light Sensors </li>
<li>Mindsensors LineLeader Sensor (Intelligent array of 8 light sensors in one I2C package) </li>
</ul>
<p>In this article I review a couple of standard ways of staying on track, and then review the new Mindsensors – Line Leader sensor.&#160; I was part of a beta-testing group for this great sensor.</p>
<h2>Single Light Sensor</h2>
<p>Using on NXT light sensor, there </p>
<p>are a couple of possibilities for following a line that can be effective. The programmer can either code to follow the line itself, or the edge of the line.</p>
<p> <a href="http://roachnet.files.wordpress.com/2009/08/clip_image001.gif"><img style="display:inline;border-width:0;" title="clip_image001" border="0" alt="clip_image001" src="http://roachnet.files.wordpress.com/2009/08/clip_image001_thumb.gif?w=200&#038;h=39" width="200" height="39" /></a>
<p>Following inside the line offers the advantage of knowing the robot is on the line, but what direct do we turn of we fall off? If the robot falls off of the line, which direction should it turn to return to it? As the robot drifts back and forth on the line, the programmer must try to correct its course to stay on the line. This method is mostly impractical.</p>
<p> <a href="http://roachnet.files.wordpress.com/2009/08/clip_image0014.gif"><img style="display:inline;border-width:0;" title="clip_image001[4]" border="0" alt="clip_image001[4]" src="http://roachnet.files.wordpress.com/2009/08/clip_image0014_thumb.gif?w=199&#038;h=50" width="199" height="50" /></a>
<p>Edge following offers the advantage of knowing the direction to turn in order to stay on the line. It is generally a faster, more accurate method for following a line. You select the right or left side of the line to follow, and code the robot to turn left if the light sensor reports BLACK and right if WHITE. This method allows a robot to follow the edge of the line through straight sections and curves. Is there a better method to follow a line?</p>
<h2>Two Light Sensors</h2>
<p> Using two NXT light sensors, there are also a couple of useful configurations to review. Sensors are generally set side by side on the front of the robot with either both inside, or both outside the line. With two sensors (left and right), more accurate line following can be achieved because as a line is lost on one side or the other, recovery is possible because we know which side lost the line. <a href="http://roachnet.files.wordpress.com/2009/08/clip_image0016.gif"><img style="display:inline;border-width:0;" title="clip_image001[6]" border="0" alt="clip_image001[6]" src="http://roachnet.files.wordpress.com/2009/08/clip_image0016_thumb.gif?w=200&#038;h=74" width="200" height="74" /></a>
<p>Placement of the light sensors is very important so that only one sensor at a time could be on the line. As can be seen in the illustration, as the robot drifts from one side to the other, one sensor contacts the line and the robot can react accordingly.</p>
<p> <a href="http://roachnet.files.wordpress.com/2009/08/clip_image0018.gif"><img style="display:inline;border-width:0;" title="clip_image001[8]" border="0" alt="clip_image001[8]" src="http://roachnet.files.wordpress.com/2009/08/clip_image0018_thumb.gif?w=214&#038;h=75" width="214" height="75" /></a>
<p>Coding is similar to using one light sensor following the edge of a line, but you can let the robot run straight if both report WHITE or both report BLACK (depending on the configuration). This allows the robot to gain speed instead of oscillating back and forth (as much) as it must with one light sensor.</p>
<h2>Mindsensors Line Leader Sensor</h2>
<p>A more advanced method for following a line is to utilize three or more light sensors to follow a line. Many people have custom built line following sensor arrays, but Mindsensors has just released the Line Leader sensor for the rest of us. Not only does it contain eight (8) sensors in its array, the intelligent sensor also implements some very nice internal coding and a robust I2C interface to communicate with the robot.</p>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="100%"></td>
</tr>
<tr>
<td><a href="http://roachnet.files.wordpress.com/2009/08/clip_image00110.gif"><img style="display:inline;border-width:0;" title="clip_image001[10]" border="0" alt="clip_image001[10]" src="http://roachnet.files.wordpress.com/2009/08/clip_image00110_thumb.gif?w=170&#038;h=153" width="170" height="153" /></a></td>
<td><a href="http://roachnet.files.wordpress.com/2009/08/clip_image00112.gif"><img style="display:inline;border-width:0;" title="clip_image001[12]" border="0" alt="clip_image001[12]" src="http://roachnet.files.wordpress.com/2009/08/clip_image00112_thumb.gif?w=170&#038;h=153" width="170" height="153" /></a></td>
</tr>
</tbody>
</table>
<p>Because there are 8 light detectors under the sensor, it is very easy to determine how to follow a line. The goal is to keep the line centered under the sensor. As the line moves left or right under the robot, it can compensate to center the line under the sensor. How is this done? Mindsensors has a good explanation in the Line Leader user guide.</p>
<p>Mindsensors took all of the hard work and math out of determining how to follow the line. There is a register for retrieving the STEERING value from the sensor. I have used the STEERING value successfully by supplying speed values to two motors. The following example code shows how to read the STEERING value from the sensor, and apply it to two drive <a href="http://roachnet.files.wordpress.com/2009/08/image.png"><img style="border-bottom:0;border-left:0;display:inline;margin-left:0;border-top:0;margin-right:0;border-right:0;" title="image" border="0" alt="image" align="right" src="http://roachnet.files.wordpress.com/2009/08/image_thumb.png?w=238&#038;h=178" width="238" height="178" /></a>motors. </p>
<pre class="csharpcode"><span class="kwrd">int</span> clip(<span class="kwrd">int</span> x, <span class="kwrd">int</span> min, <span class="kwrd">int</span> max) {
  <span class="kwrd">if</span> (x&lt;min)
    <span class="kwrd">return</span> min;
  <span class="kwrd">else</span> <span class="kwrd">if</span> (x&gt;max)
    <span class="kwrd">return</span> max;
  <span class="kwrd">else</span>
    <span class="kwrd">return</span> x;
}

While(<span class="kwrd">true</span>) {
<span class="rem">//TWO MOTORS – DIFFERENTIAL DRIVE STEERING FROM LINE LEADER </span>
<span class="rem">//GET STEERING FEEDBACK FROM THE SENSOR TO KEEP ROBOT ON THE LINE</span>

  steering = (<span class="kwrd">int</span>) LL_Read(SensorPort, LineLeaderAddr, LL_READ_STEERING);
  motor[RIGHTMOTOR] = clip(70 + steering, -100, 100); <span class="rem">//RIGHT MOTOR</span>
  motor[LEFTMOTOR] = clip(70 - steering, -100, 100); <span class="rem">//LEFT MOTOR</span>
}</pre>
<p>The clip function is a simple utility function that should be in everyone’s toolbox. It takes value returns it if it is between min and max. If outside the range, it returns min or max.</p>
<p>Mindsensors supplies a simple driver file that makes reading the STEERING value easier. We call LL_Read() with the LL_READ_STEERING constant to return the STEERING value suggested by the sensor based on where the line is. The last step is to determine speed value for the left and right motors. We ideally (in this case) want to travel straight at speed = 70. We add the steering value to the right motor, and subtract it from the left motor (within the range motors accept – [-100 to 100]). That’s it.</p>
<p>As the line drifts to the right (or robot to the left), steering becomes a negative number. The further it moves to the right, the bigger the number becomes to allow for correction of the robot.</p>
<p>If the STEERING value returned is -20, we set the motors to use the value to correct the robot’s steering.</p>
<p>RIGHTMOTOR power = 70 + (-20) = <b>50</b> </p>
<p>LEFTMOTOR power = 70 – (-20) =<b> 90</b></p>
<p>This causes the right motor to spin faster than the left turning the robot left to re-center the sensor over the line.</p>
<p>Your program would continue to loop, finding the next steering value and correcting the motors accordingly. The robot uses this feedback control to follow a line.</p>
<p>What if the robot takes advantage of the NXTs motor implementation and links the RIGHTMOTOR and LEFTMOTOR together? NXT firmware allows the motors to take advantage of the internal encoding for each motor to keep them running at the same speed (It can move in a straight line!). I often implement my drive motors with this configuration so the robot can easily move straight. Here is a quick code sample of implementing sync’d motors.</p>
<pre class="csharpcode"><span class="kwrd">void</span> _DriveRobot(<span class="kwrd">int</span> power, <span class="kwrd">int</span> steering) {
  <span class="kwrd">if</span> (steering &gt;= 0) { <span class="rem">//RIGHT TURN or STRAIGHT</span>
    <span class="kwrd">if</span> (lastPower!=power || lastSteering != steering){
      nSyncedMotors = synchBA;
      nSyncedTurnRatio = (100 - (2*abs(steering)));
      motor[LEFTMOTOR]=power;
      lastPower=power;
      lastSteering=steering;
    }
  }
  <span class="kwrd">else</span> { <span class="rem">//LEFT TURN</span>
    <span class="kwrd">if</span> (lastPower!=power || lastSteering != steering){
      nSyncedMotors = synchAB;
      nSyncedTurnRatio = (100 - (2*abs(steering)));
      motor[RIGHTMOTOR]=power;
      lastPower=power;
      lastSteering=steering;
    }
  }
}</pre>
<p>In this case, I have directly passed the STEERING value returned from the Line Leader to this routine with excellent success. Robot speed is determined by the POWER parameter (-100 to 100) to implement reverse, stop, or forward. The STEERING parameter (-100 to 100) determines left, straight, or right turns.</p>
Posted in My Robots, PathBot  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=227&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/08/31/follow-a-line-line-following-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image001_thumb.gif" medium="image">
			<media:title type="html">clip_image001</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image0014_thumb.gif" medium="image">
			<media:title type="html">clip_image001[4]</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image0016_thumb.gif" medium="image">
			<media:title type="html">clip_image001[6]</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image0018_thumb.gif" medium="image">
			<media:title type="html">clip_image001[8]</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image00110_thumb.gif" medium="image">
			<media:title type="html">clip_image001[10]</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/clip_image00112_thumb.gif" medium="image">
			<media:title type="html">clip_image001[12]</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/08/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Puckbot &#8211; Collector Robot Post-Mortem</title>
		<link>http://roachnet.wordpress.com/2009/07/26/puckbot-collector-robot-post-mortem/</link>
		<comments>http://roachnet.wordpress.com/2009/07/26/puckbot-collector-robot-post-mortem/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 03:31:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[afterthought]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[behavior-based]]></category>
		<category><![CDATA[collector]]></category>
		<category><![CDATA[conclusions]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/26/puckbot-collector-robot-post-mortem/</guid>
		<description><![CDATA[Building and programming the Puckbot was a fascinating project.&#160; I have attempted to build similar robots a few times over the past couple of years,&#160; but I never really devoted the time toward creating a stable, reliable behavior-based framework first.&#160; Earlier frameworks utilized different techniques that were weak in execution, difficult to debug, and unpredictable.&#160; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=212&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Building and programming the Puckbot was a fascinating project.&#160; I have attempted to build similar robots a few times over the past couple of years,&#160; but I never really devoted the time toward creating a stable, reliable behavior-based framework first.&#160; Earlier frameworks utilized different techniques that were weak in execution, difficult to debug, and unpredictable.&#160; With my latest venture using RobotC, I spent some real time working on the framework.&#160; The framework was the least of my worries on this robot.&#160; It functioned as designed and is easy to add behaviors to, easy (easier) to debug, and certainly robust enough to create viable autonomous robots.</p>
<p>Implementing the collector robot with Lego Mindstorms NXT and my RobotC behavior-based framework was completely rewarding.&#160; I still have to laugh a little when I watching the robot move around the arena, collecting pucks and delivering the successfully to the light.&#160; Of course, I thought out the sensors and behaviors, of course there is a ton of information and study on the collector in my books, but to see it actually do the job for real was special.&#160; I have to admit, I was a little unsure if I could pull it off.&#160; There are a lot of behaviors working in concert, all with their own set of parameters to fiddle with, and so many things that could have gone wrong; They had in the past…</p>
<p>Wow!&#160; Watching the robot in figure out what to do, and doing it by its self, is what it is all about.&#160; </p>
<h2></h2>
<p> <span id="more-212"></span><br />
<h2>What Went Right</h2>
<p>As you can see, I am proud of this accomplishment as a whole.&#160; When I break down the components, there are many things I learned, that really worked well.&#160; Here are a few.</p>
<ul>
<li>Learning that one front bumper is enough in many cases.&#160; Like most of you, I almost always create my front bumpers with two bumpers (left &amp; right).&#160; I starting thinking about it, and wanted to try to use only one input for the bumpers and found I was not giving up too much advantage by implementing one bumper.</li>
<li>Going a step further and adding a light sensor to the same port as the bumpers. In my case, I was able to work around the limitation of having light sensor and bumper readings on the same port and I saved inputs for other sensors.</li>
<li>By implementing sensor drivers, I also created a standard set of functions to communicate with the sensors.&#160; The idea was to create a function like FrontBumper.isBumped() so that in the future, a behavior that implements this function does care about the implementation or configuration of the sensors, only is the front bumper was bumped or not.&#160; The driver performs the calculations and returns whether or not the bumper is engaged. (note-I did not say pressed).&#160; The bumper be physically implemented to be “isBumped” when pushed or not pushed depending on the design.</li>
<li>Creating a sensor driver for the differential light sensor also shined for me.&#160; By creating a driver that supplied standard methods and values, multiple behaviors could use the “triggers” for their own purposes without complicated, customized logic in each behavior.&#160; Look at the code to see what I mean; Especially with the differential light sensor.&#160; Seeing or not Seeing a light is critical to the operation of the robot.&#160; The driver return true or false.&#160; Calculations are done internally to the driver to determine thresholds, etc…&#160; Several behaviors use the common functions.</li>
<li>The Differential Light Sensor auto calibrates.&#160; When I first created the robot and coded some behaviors, varying light sources in my office caused many confusing problems for the robot (and me!).&#160; The differential light sensor driver attempts to do the hard work no matter the environment lighting by storing hi, lo, and current values and doing calculations to automatically configure thresholds and return meaningful information.</li>
</ul>
<h2>What Were Some Challenges</h2>
<ul>
<li>The Puckbot manages several behaviors at once.&#160; Trying to understand programmatic failures is not always easy to determine.&#160; I found that by disabling all behaviors but one or two really helps to find issues.&#160; By implementing only LIGHT HOME, I was able to move the robot manually into position, and watch trigger points and see the homing action.</li>
<li>Speaking of homing, There were times when the robot would home in on the light source only to get too close and “loose” track of it because the light sensors saw a similar value, but did not directly see the light.&#160; Kind of like going cross-eyed trying to see the tip or your nose.&#160; The robot would crash into the wall behind the source and escape most of the time, but it looked clumsy.&#160; At least there is some inherent graceful degradation, even in my simple NXT robot.</li>
<li>Wall following utilized the front bumper, which was on the same input port as the down pointing light sensor.&#160; While touching a wall, the robot is unable to determine if it has captured a puck.&#160; It is effectively blind at times.</li>
<li>On this topic, one weakness of the hierarchical behavior model is the paradox it can create at times where it seems one behavior should be higher priority than another in some cases, and lower in others.&#160; BUMP FOLLOW and DARK PUCK were victims of this.&#160; Generally, bump follow must be high on the list above BUMP ESCAPE since it only triggers sometimes, but what if the robot encounters a puck along the wall while following?&#160; DARK PUCK is pretty low in the list and should not be above the escape behaviors or the robot might crash into a wall carrying a puck and not be able to escape.&#160; I need to think more on this, but I think the answer may be to create a new, special case, behavior above BUMP FOLLOW for when a puck is encountered while following a wall.</li>
<li>Physical design caused interesting challenges.&#160; For example, I changed the puck catching mechanism several times to maximize capture.&#160; I even changed the design after I posted nice pictures on the design in this blog.&#160; I was not capturing pucks when they were near the front wheels.&#160; Compare the video with the pictures in the blog and you will see differences (if you look close).</li>
<li>I noticed the robot seemed to get stuck in a loop in a few cases where it was away from the light source, and carrying a puck.&#160; I think the robot starts to turn toward the light source with a puck, but the puck slips from the catch.&#160; The light sensor looses it momentarily, and the light source is not strong enough to attract the robot, so it starts to CRUISE.&#160; At that point, the puck slips back into the catch and starts the loop over.&#160; It is a complex case of canyoning and surprised me when I first saw it.&#160; The robot appears to orbit the light source for a time before giving up.&#160; I would like to revisit that scenario, but it is difficult to trigger when you are trying. </li>
</ul>
<h2>Last Thoughts</h2>
<p>All in all, the Puckbot collector robot was a complete success.&#160; It can collect four pucks and deliver them to the light source successfully most of the time in less than 5 minutes.&#160; There are some cases when a puck gets trapped along a wall or in a corner and the robot fails, but most of the time it succeeded.&#160; I will certainly revisit this robot and tackle these weaknesses.</p>
Posted in CollectorBot, My Robots  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=212&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/26/puckbot-collector-robot-post-mortem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>
	</item>
		<item>
		<title>Puckbot I &#8211; Collector Robot Success!</title>
		<link>http://roachnet.wordpress.com/2009/07/18/puckbot-i-collector-robot-explained/</link>
		<comments>http://roachnet.wordpress.com/2009/07/18/puckbot-i-collector-robot-explained/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 04:38:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[RobotC Code]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[behavior-based]]></category>
		<category><![CDATA[Collection]]></category>
		<category><![CDATA[collector]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/18/puckbot-i-collector-robot-explained/</guid>
		<description><![CDATA[The collector is a more complex robot building on concepts learns from AreaBot.  The robot covers are much area of a closed arena as possible collecting Mindstorms NXT foam pucks, and delivering them to a central home base (light source).  The following represents the sensors, drivers, and behavior hierarchy to accomplish the task.

See all of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=196&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The collector is a more complex robot building on concepts learns from AreaBot.  The robot covers are much area of a closed arena as possible collecting Mindstorms NXT foam pucks, and delivering them to a central home base (light source).  The following represents the sensors, drivers, and behavior hierarchy to accomplish the task.</p>
<p><a href="http://roachnet.files.wordpress.com/2009/07/collectorbotbehdia.jpg"><img style="display:inline;border-width:0;" title="collectorbot-behdia" src="http://roachnet.files.wordpress.com/2009/07/collectorbotbehdia_thumb.jpg?w=420&#038;h=235" border="0" alt="collectorbot-behdia" width="420" height="235" /></a></p>
<p>See all of the <a href="http://roachnet.wordpress.com/category/my-robots/collectorbot/"><strong>collector robot</strong> articles here</a>.<br />
Download the Code: <a href="https://www.qdrive.net/download/sharelinkdownloader.php?id=18188&amp;key=N7E3L2CmX3IjH6zxN5tjLxrpB9IXx4zmFvE">Download: bbPuckBot.zip</a><br />
See the video <a href="http://www.youtube.com/watch?v=Egm1KML07mQ">here</a>.</p>
<p><span id="more-196"></span></p>
<p><span style="text-align:center; display: block;"><a href="http://roachnet.wordpress.com/2009/07/18/puckbot-i-collector-robot-explained/"><img src="http://img.youtube.com/vi/Egm1KML07mQ/2.jpg" alt="" /></a></span></p>
<h2>Behaviors in Detail</h2>
<p>I have reviewed the sensors and drivers in previous posts, so here I will focus on new behaviors, and discuss the big picture.  I have described CRUISE, BUMP ESCAPE, and BUMP FOLLOW in posts for the <a href="http://roachnet.wordpress.com/category/my-robots/areabot/">AreaBot</a>.</p>
<h3>LIGHT ESCAPE – If a light source is too bright, get away</h3>
<p><a href="http://roachnet.files.wordpress.com/2009/07/antimothbehavior.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="AntiMothBehavior" src="http://roachnet.files.wordpress.com/2009/07/antimothbehavior_thumb.jpg?w=260&#038;h=114" border="0" alt="AntiMothBehavior" width="260" height="114" align="right" /></a> Light escape is the highest priority and key to collecting pucks in a central home base location.  Although it has nothing to do with collecting anything, this behavior is the mechanism for dropping off the pucks at home base.  When the robot approaches the light source (with or without a puck in its grasp), and gets close, this behavior is triggered.  The robot backs up (leaving the puck it was pushing behind) and spins away to find more pucks.</p>
<p>Light escape is a relatively small behavior that relies on the differential light sensor as a trigger and the generic escape sequence to escape.</p>
<h3>HOME LIGHT – if a light source is in view, move toward it</h3>
<p><a href="http://roachnet.files.wordpress.com/2009/07/homelight.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="HomeLight" src="http://roachnet.files.wordpress.com/2009/07/homelight_thumb.jpg?w=171&#038;h=120" border="0" alt="HomeLight" width="171" height="120" align="left" /></a> Home Light is a behavior that is triggered when the robot see enough light to determine it sees the home beacon, and attempts to move the robot toward it.  The differential light sensor is employed to determine the difference between left and right light intensity, and uses that value to steer the robot toward the light.</p>
<p>In an ideal situation, the robot will home in on the light while also pushing a puck.  In this way, pucks are delivered to the light source.</p>
<h3>DARK PUCK – If a puck is captured and home is not in sight, turn toward it</h3>
<p><a href="http://roachnet.files.wordpress.com/2009/07/darkpuckbehavior.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="DarkPuckBehavior" src="http://roachnet.files.wordpress.com/2009/07/darkpuckbehavior_thumb.jpg?w=164&#038;h=120" border="0" alt="DarkPuckBehavior" width="164" height="120" align="right" /></a> Dark Puck is a departure from the collector robot from my reference book.  The original behavior was called DARK PUSH.  When the robot encountered a puck it could push it.  In the book, pucks were detected by turning toward them, and only pushing them if there was a light.  If no light beacon was seen, the robot would execute an escape sequence.</p>
<p>It was not practical to detect pucks with my robot using the IR proximity sensors, so I needed another way to increase the odds of moving pucks to the home base.  Dark Push applies similar principals to Dark Push by triggering when the robot is pushing a puck, and facing away from the home base beacon.  Dark Puck detects a captured puck using a legacy light sensor pointed down into the puck catch.  When detected, and the differential light sensors report no beacon, the robot attempts to turn (without loosing the puck) toward the light source.  If successful, HOME LIGHT may take over and move the puck to home base.</p>
<p>WordPress Tags: <a rel="Tag" href="http://wordpress.com/tag/Collector">Collector</a>,<a rel="Tag" href="http://wordpress.com/tag/Robot">Robot</a>,<a rel="Tag" href="http://wordpress.com/tag/Behavior">Behavior</a>,<a rel="Tag" href="http://wordpress.com/tag/Diagram">Diagram</a>,<a rel="Tag" href="http://wordpress.com/tag/AreaBot">AreaBot</a>,<a rel="Tag" href="http://wordpress.com/tag/Mindstorms">Mindstorms</a>,<a rel="Tag" href="http://wordpress.com/tag/task">task</a>,<a rel="Tag" href="http://wordpress.com/tag/Behaviors">Behaviors</a>,<a rel="Tag" href="http://wordpress.com/tag/CRUISE">CRUISE</a>,<a rel="Tag" href="http://wordpress.com/tag/BUMP">BUMP</a>,<a rel="Tag" href="http://wordpress.com/tag/ESCAPE">ESCAPE</a>,<a rel="Tag" href="http://wordpress.com/tag/HOME">HOME</a>,<a rel="Tag" href="http://wordpress.com/tag/DARK">DARK</a>,<a rel="Tag" href="http://wordpress.com/tag/PUCK">PUCK</a>,<a rel="Tag" href="http://wordpress.com/tag/PUSH">PUSH</a>,<a rel="Tag" href="http://wordpress.com/tag/concepts">concepts</a></p>
Posted in CollectorBot, My Robots, RobotC Code, Video  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=196&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/18/puckbot-i-collector-robot-explained/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/collectorbotbehdia_thumb.jpg" medium="image">
			<media:title type="html">collectorbot-behdia</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/Egm1KML07mQ/2.jpg" medium="image" />

		<media:content url="http://roachnet.files.wordpress.com/2009/07/antimothbehavior_thumb.jpg" medium="image">
			<media:title type="html">AntiMothBehavior</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/homelight_thumb.jpg" medium="image">
			<media:title type="html">HomeLight</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/darkpuckbehavior_thumb.jpg" medium="image">
			<media:title type="html">DarkPuckBehavior</media:title>
		</media:content>
	</item>
		<item>
		<title>Escape Sequence &#8211; A generic approach to getting away</title>
		<link>http://roachnet.wordpress.com/2009/07/14/escape-sequence-a-generic-approach-to-getting-away/</link>
		<comments>http://roachnet.wordpress.com/2009/07/14/escape-sequence-a-generic-approach-to-getting-away/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 04:28:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[AreaBot]]></category>
		<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[RobotC Code]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[behavior-based]]></category>
		<category><![CDATA[bump]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[collision]]></category>
		<category><![CDATA[escape]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[robotc]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[threshold]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/14/escape-sequence-a-generic-approach-to-getting-away/</guid>
		<description><![CDATA[The escape behavior is one of the more important behaviors implemented in my robots.&#160; Any time the robot bumps into a wall, there is an opportunity to escape.&#160; In response to a trigger (collision), the robot backs up, spins away, and nudges forward to execute the “escape sequence”.&#160; I have detailed this sequence in articles [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=187&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://roachnet.files.wordpress.com/2009/07/bumpescapestatedia.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="BumpEscapeStateDia" border="0" alt="BumpEscapeStateDia" align="right" src="http://roachnet.files.wordpress.com/2009/07/bumpescapestatedia_thumb.jpg?w=260&#038;h=200" width="260" height="200" /></a>The escape behavior is one of the more important behaviors implemented in my robots.&#160; Any time the robot bumps into a wall, there is an opportunity to escape.&#160; In response to a trigger (collision), the robot backs up, spins away, and nudges forward to execute the “escape sequence”.&#160; I have detailed this sequence in articles about creating the <a href="http://roachnet.wordpress.com/category/my-robots/areabot/">AreaBot</a> robot.</p>
<p>The reason I am blogging about it again, is that I believe the escape sequence is a generic action.</p>
<p>Download Sample Code: <a href="https://www.qdrive.net/download/sharelinkdownloader.php?id=15170&amp;key=m47EqDszhB9tXHX6mJ3Ebx6OhN9MnXXCdF3">EscapeSequence.zip</a></p>
<p>What do I mean?</p>
<p> <span id="more-187"></span>
<p>In my experiments so far, any time the robot needs to escape from a trigger (collision, too much light, etc…) the same sequence of events occurs in order to free the robot from the trigger.</p>
<p><a href="http://roachnet.files.wordpress.com/2009/07/escapesequence.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="EscapeSequence" border="0" alt="EscapeSequence" align="left" src="http://roachnet.files.wordpress.com/2009/07/escapesequence_thumb.jpg?w=240&#038;h=140" width="240" height="140" /></a> </p>
<p>We examined BUMP ESCAPE where a bumper collision occurs.&#160; Once triggered, the robot backs up for a time, spins right or left for a number of degrees, and finishes by moving forward a short time to make sure it starts the next behavior in a different location as when escape was triggered.</p>
<p>For the collector robot, a behavior was written that needs to escape when a light source is too bright (LIGHT ESCAPE).&#160; Why not use the same code to escape from a “too bright” light source.&#160; I have a Boolean trigger, and I understand the movements the robot can perform to move away from the light.&#160; At first, I copied the escape code from bump escape, and changed it to work with the bright light.&#160; Then I got an idea…</p>
<p>Maybe I should create a generic escape sequence function and allow other behaviors to utilize the common code.&#160; I spent an evening coping key parts of the code to a new include, and called it escape sequence.&#160; Now a new escape behavior is easy to implement.&#160; I just need to know the current state and trigger condition.</p>
<pre class="csharpcode"><span class="rem">// *** NEEDS EscapeSequence.h</span>
<span class="rem">// *** ASSUMES A FRONT BUMPER IS IMPLEMENTED IN THE MAIN ROBOT CODE</span>

<span class="rem">// BEHAVIOR CODE TO ESCAPE FROM A FRONTAL COLLISION</span>
<span class="kwrd">void</span> BEH_BumpEscape() {
  Behavior(BEHAVIOR_BUMP_ESCAPE);  <span class="rem">// SET THE BEHAVIOR ID</span>
  <span class="kwrd">static</span> typEscapeState bumpState; <span class="rem">// ESCAPE STATE VALUE</span>
  <span class="kwrd">bool</span> isCollision;                <span class="rem">// COLLISION VALUE</span>

  isCollision = bumper_isBumped();    <span class="rem">// DID A COLLISION OCCUR?</span>
  <span class="kwrd">if</span> (bumpState != STATE_START) {   <span class="rem">// ALREADY ACTIVE, FOLLOW ESCAPE ROUTINE</span>
    EscapeSequence(bumpState, isCollision);
  }
  <span class="kwrd">else</span> {
    <span class="kwrd">if</span> (isCollision)
      EscapeSequence(bumpState, isCollision);
      <span class="kwrd">else</span>
        DeclineControl();  <span class="rem">// NO COLLISION OCCURED-DO NOTHING</span>
    }
}</pre>
<p>Here is the <strong>new BUMP ESCAPE</strong> behavior.&#160; The behavior checks if the robot is in a collision (trigger condition), and calls EscapeSequence(currentState, currentTriggerCondition).&#160; The Escape Sequence does the rest.&#160; How is that for a few POWERFUL lines of code!</p>
<p>The code is very similar to implement <strong>LIGHT ESCAPE</strong>.&#160; Notice the trigger condition isTooLight.&#160; The only difference is under the statement that checks “not state = start” where I send “false” as the condition.&#160; If I sent the isTooLight condition here, the robot backs up until there is not too much light.&#160; I just wanted the robot to recognize it was too close to the light source and turn away.</p>
<pre class="csharpcode"><span class="rem">// *** NEEDS EscapeSequence.h</span>
<span class="rem">// *** ASSUMES TWO LIGHT SENSORS ARE IMPLEMENTED IN THE MAIN ROBOT CODE</span>

<span class="rem">// BEHAVIOR CODE TO ESCAPE FROM A FRONTAL COLLISION</span>
<span class="kwrd">void</span> BEH_LightEscape() {
  Behavior(BEHAVIOR_LIGHT_ESCAPE);  <span class="rem">// SET THE BEHAVIOR ID</span>
  <span class="kwrd">static</span> typEscapeState leState; <span class="rem">// ESCAPE STATE VALUE</span>
  <span class="kwrd">bool</span> isTooLight;                  <span class="rem">// COLLISION VALUE</span>

  isTooLight = DiffLight_IsHome();

  <span class="kwrd">if</span> (leState != STATE_START) { <span class="rem">// ACTIVE, EXECUTE ESCAPE ROUTINE</span>
    EscapeSequence(leState, <span class="kwrd">false</span>);
  }
  <span class="kwrd">else</span> {
    <span class="kwrd">if</span> (isTooLight)  <span class="rem">// TRIGGER THE ESCAPE ROUTINE TO START</span>
      EscapeSequence(leState, isTooLight);
      <span class="kwrd">else</span>
        DeclineControl();  <span class="rem">// NO COLLISION OCCURED-DO NOTHING</span>
    }
}</pre>
<p>I will make all code for the collector robot available very soon as one download package.</p>
Posted in AreaBot, CollectorBot, My Robots, RobotC Code  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=187&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/14/escape-sequence-a-generic-approach-to-getting-away/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/bumpescapestatedia_thumb.jpg" medium="image">
			<media:title type="html">BumpEscapeStateDia</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/escapesequence_thumb.jpg" medium="image">
			<media:title type="html">EscapeSequence</media:title>
		</media:content>
	</item>
		<item>
		<title>Bumpers and Light &#8211; Combining Sensors into One Port</title>
		<link>http://roachnet.wordpress.com/2009/07/14/bumpers-and-light-combining-sensors-into-one-port/</link>
		<comments>http://roachnet.wordpress.com/2009/07/14/bumpers-and-light-combining-sensors-into-one-port/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 14:53:52 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[RobotC Code]]></category>
		<category><![CDATA[bumper]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[robotc]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/14/bumpers-and-light-combining-sensors-into-one-port/</guid>
		<description><![CDATA[Some of you may have noticed that my Collector Robot has more than two light sensors hanging off the sides…  There is an archaic bumper (design from the original Mindstorms 1.0 kit) and a legacy light sensor buried in the bumper.  There is also a couple of white arched technic pieces under the bumper.
I thought [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=178&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694_thumb.jpg"><img class="size-full wp-image-165 alignright" title="Collector Robot" src="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694_thumb.jpg?w=124&#038;h=124" alt="TFR_20090713_0694_thumb.jpg" width="124" height="124" /></a>Some of you may have noticed that my Collector Robot has more than two light sensors hanging off the sides…  There is an archaic bumper (design from the original Mindstorms 1.0 kit) and a legacy light sensor buried in the bumper.  There is also a couple of white arched technic pieces under the bumper.</p>
<p>I thought I would go into more detail on this design because the implementation was interesting.  This robot is designed to find and move Lego NXT pucks around.  It does not specifically search for pucks, but happens upon them because it is able to cover all areas of the arena.</p>
<p>Download the driver here: <a href="https://www.qdrive.net/download/sharelinkdownloader.php?id=15010&amp;key=dJ7EbP26hF9MgXXCmX3IqX2GpN9MgL46dNv">BumpLightCombo.h</a></p>
<h2><span id="more-178"></span>Technical Background</h2>
<p>The bumpers give the robot protection from walls and objects and trigger several behaviors within the robot to perform tasks like escaping a collision and following a wall (just like Areabot).</p>
<p><a href="http://roachnet.files.wordpress.com/2009/07/collectorbot2of4.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="Collectorbot (2 of 4)" src="http://roachnet.files.wordpress.com/2009/07/collectorbot2of4_thumb.jpg?w=244&#038;h=164" border="0" alt="Collectorbot (2 of 4)" width="244" height="164" align="left" /></a></p>
<p>There is a “puck catch” under the bumper that is designed to either direct pucks into the middle where a light sensor can detect the black color, or deflect pucks to far to the right or left away from the wheels.  If a puck is detected in the catch, various behaviors are triggered to increase the chance the robot will deliver them to home base.</p>
<h2>Sensor Implementation</h2>
<p>Sometimes there is an opportunity to combine sensors together into one port that requires no additional hardware.  It requires a little bit of ingenuity and programming creativity, but the results can give you more sensory power without using additional input ports.</p>
<p>For my <strong>Collector Robot</strong>, I wanted to implement a front bumper to detect collisions, and a light sensor to detect captured pucks. As <span style="text-decoration:line-through;">knowledge and experience</span> luck would have it, I was able to combine the bumper and down pointing light sensor into one port because the sensors are not needed at the same time.</p>
<p><a href="http://roachnet.files.wordpress.com/2009/07/collectorbot3of4.jpg"><img style="display:inline;border-width:0;" title="Collectorbot (3 of 4)" src="http://roachnet.files.wordpress.com/2009/07/collectorbot3of4_thumb.jpg?w=214&#038;h=143" border="0" alt="Collectorbot (3 of 4)" width="214" height="143" /></a> <a href="http://roachnet.files.wordpress.com/2009/07/collectorbot1of4.jpg"><img style="display:inline;border-width:0;" title="Collectorbot (1 of 4)" src="http://roachnet.files.wordpress.com/2009/07/collectorbot1of4_thumb.jpg?w=214&#038;h=144" border="0" alt="Collectorbot (1 of 4)" width="214" height="144" /></a></p>
<p>There are a few compromises that need to be understood to configure the sensors using only one NXT input port.</p>
<ul>
<li>The left and right bumpers are connected together to provide ONE bumper on the front of the robot.
<ul>
<li>A compromise with this configuration is the loss of ability to detect left or right collisions.  I used to think this was bad, but I found out it is not that big of a deal.  In my case, bumping is used to escape from a collision or for following a wall.  In both cases, I control the turning directions anyway, so there is no reason to implement left and right bumpers.  Escape randomly turns away from the wall.  Wall following always follows walls on the right side, so a spin gets it into position easily.</li>
</ul>
</li>
<li>The legacy light sensor is also connected to the same port as the bumpers and is used to detect pucks in the “puck catch” area.
<ul>
<li>What happens, is the light sensor value is read as long as there is not a collision.  If there is a collision, the value goes to 100.  No problem for collector robot because I am continually monitoring for the presence of a puck when not hitting a wall.
<ul>
<li>You must implement bumpers that are normally open (not pressed) in order to use the light sensor.  These are not the best for bumpers because it takes more force to press the buttons than to release them.  Collector Robot gets beat up a little, but it is good for its sole <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I can live with that.</li>
<li>When the bumper is pressed, the light sensor is useless.  This can be an issue if you need the bumpers and the light sensor at the same time.  In my case, a collision was more critical than whether or not I could detect a puck in the collector.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>I wrote a driver that allows me to abstract all of this logic into a few functions I can call to check the sensor(s) status.  It is not complicated, but lets me concentrate on the rest of the code without remembering the implementation.</p>
<h2>Code Listing</h2>
<pre class="csharpcode"><span class="preproc">#define</span> FRONT_BUMPER S2  <span class="rem">//DEFAULT INPUT PORT FOR BUMPER SWITCH SENSOR</span>
<span class="preproc">#define</span> LIGHT_DOWN S2  <span class="rem">//DEFAULT INPUT PORT FOR BUMPER SWITCH SENSOR </span>

<span class="kwrd">const</span> <span class="kwrd">int</span> kLightSensorDark = 24; <span class="rem">//LIGHT SENSOR BLACK THRESHOLD </span>

<span class="rem">//INITIALIZE FRONT BUMPER TYPE AND MODE</span>
<span class="kwrd">void</span> BumpLightCombo_Initialize() {
  SensorType[LIGHT_DOWN] = sensorReflection;
  SensorMode[LIGHT_DOWN] = modePercentage;
} 

<span class="rem">// CHECK THE SENSOR FOR BUMPED.  MUST BE NORMALLY OPEN AND CLOSED ON TRIGGER!</span>
<span class="kwrd">bool</span> bumper_isBumped() {
  <span class="kwrd">return</span> (<span class="kwrd">bool</span>) (SensorValue[FRONT_BUMPER] &gt;= 99);
} 

<span class="rem">// CHECK THE SENSOR FOR BUMPED OR NOT BASED ON VALUE AND CONFIGURATION</span>
<span class="kwrd">bool</span> lightDown_isDark() {
  <span class="kwrd">return</span> (<span class="kwrd">bool</span>) (SensorValue[LIGHT_DOWN] &lt;= kLightSensorDark);
} 

<span class="rem">// CHECK THE SENSOR FOR BUMPED OR NOT BASED ON VALUE AND CONFIGURATION</span>
<span class="kwrd">bool</span> lightDown_isLight() {
<span class="kwrd">byte</span> _value = SensorValue[LIGHT_DOWN];
  <span class="kwrd">return</span> (<span class="kwrd">bool</span>) (_value &gt; kLightSensorDark + 5 &amp;&amp; _value &lt;99);
}</pre>
<p>cccc</p>
Posted in CollectorBot, My Robots, RobotC Code  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=178&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/14/bumpers-and-light-combining-sensors-into-one-port/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694_thumb.jpg" medium="image">
			<media:title type="html">Collector Robot</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/collectorbot2of4_thumb.jpg" medium="image">
			<media:title type="html">Collectorbot (2 of 4)</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/collectorbot3of4_thumb.jpg" medium="image">
			<media:title type="html">Collectorbot (3 of 4)</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/collectorbot1of4_thumb.jpg" medium="image">
			<media:title type="html">Collectorbot (1 of 4)</media:title>
		</media:content>
	</item>
		<item>
		<title>AreaRover III &#8211; Video</title>
		<link>http://roachnet.wordpress.com/2009/07/13/arearover-iii-video/</link>
		<comments>http://roachnet.wordpress.com/2009/07/13/arearover-iii-video/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 18:21:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[AreaBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[arearover]]></category>
		<category><![CDATA[behavior-based]]></category>
		<category><![CDATA[bump]]></category>
		<category><![CDATA[bumper]]></category>
		<category><![CDATA[collision]]></category>
		<category><![CDATA[follow]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[NXT]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[wall]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/13/arearover-iii-video/</guid>
		<description><![CDATA[Sorry this video took so long to post.  Some time in the past two weeks, my microphone/Windows 7 combination started acting up.  The voice was recorded choppy and awful.  I sounds like two drivers are competing for control of the microphone processing, but I can’t tell for sure.  I guess those are the breaks with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=168&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sorry this video took so long to post.  Some time in the past two weeks, my microphone/Windows 7 combination started acting up.  The voice was recorded choppy and awful.  I sounds like two drivers are competing for control of the microphone processing, but I can’t tell for sure.  I guess those are the breaks with release candidate software…</p>
<p>Any way, here is the missing video.</p>
<p><span id="more-168"></span><span style="text-align:center; display: block;"><a href="http://roachnet.wordpress.com/2009/07/13/arearover-iii-video/"><img src="http://img.youtube.com/vi/1YDgmuJk4S8/2.jpg" alt="" /></a></span></p>
<p>It shows the robot trying to move about in my arena.  The first part shows AreaRover bouncing off the walls and failing to enter the second chamber because the door is not very large.  Eventually, the robot would make it into the room, but we like efficiency.</p>
<p>By adding wall following to the behaviors, the robot is able to follow a wall around the corner and into the 2nd chamber very easily.  I experimented with using the Ultrasonic sensor to follow a wall on one side, and bumper collisions to follow the wall on the other side to add variety.  It just goes to show you that behaviors can be layered in a robust manner fairly easily.</p>
<p>WordPress Tags: <a rel="Tag" href="http://wordpress.com/tag/AreaRover">AreaRover</a>,<a rel="Tag" href="http://wordpress.com/tag/Video">Video</a>,<a rel="Tag" href="http://wordpress.com/tag/robot">robot</a>,<a rel="Tag" href="http://wordpress.com/tag/chamber">chamber</a>,<a rel="Tag" href="http://wordpress.com/tag/Ultrasonic">Ultrasonic</a>,<a rel="Tag" href="http://wordpress.com/tag/sensor">sensor</a>,<a rel="Tag" href="http://wordpress.com/tag/collisions">collisions</a>,<a rel="Tag" href="http://wordpress.com/tag/behaviors">behaviors</a></p>
Posted in AreaBot, My Robots, Video  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/168/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/168/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/168/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=168&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/13/arearover-iii-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/1YDgmuJk4S8/2.jpg" medium="image" />
	</item>
		<item>
		<title>Differential Light Sensor &#8211; Two NXT Light Sensors as One</title>
		<link>http://roachnet.wordpress.com/2009/07/13/differential-light-sensor-two-nxt-light-sensors-as-one/</link>
		<comments>http://roachnet.wordpress.com/2009/07/13/differential-light-sensor-two-nxt-light-sensors-as-one/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 17:52:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[RobotC Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[differential]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[homing]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/13/differential-light-sensor-two-nxt-light-sensors-as-one/</guid>
		<description><![CDATA[&#160; One of the goals of the Collector Robot is to push pucks to a light source “Home Base” and leave them there.&#160; In order to accomplish this, the robot must be able to home in on a light source.&#160; In order to home, the robot needs to have some method for finding the light, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=166&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>&#160;<a href="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="Collector Robot" border="0" alt="Collector Robot" align="right" src="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694_thumb.jpg?w=124&#038;h=124" width="124" height="124" /></a> One of the goals of the <strong>Collector Robot</strong> is to push pucks to a light source “Home Base” and leave them there.&#160; In order to accomplish this, the robot must be able to home in on a light source.&#160; In order to home, the robot needs to have some method for finding the light, and adjusting its course to drive toward it.</p>
<p>I created a virtual differential light sensor using two NXT light sensors mounted on the robot facing forward, angled to the left and right.&#160; This gives me a good starting point to read values from each sensor to determine the difference in intensity and therefore determining the STEERING value to drive the robot toward the light.</p>
<p>Download the driver: <a href="https://www.qdrive.net/download/sharelinkdownloader.php?id=14748&amp;key=vAqH2G7X5tbDXrdJ183xxOmN1EqD9rXXvIj">DiffLight-driver.h</a>     <br />Download this too: <a href="https://www.qdrive.net/download/sharelinkdownloader.php?id=14751&amp;key=gXXzmX3AbP6Oh49EnHxzmF7IjH6rhJ1IgPX">mathext.h</a></p>
<p> <span id="more-166"></span><br />
<h2>Purpose</h2>
<p>One of the challenges I ran into was the many things a robot can do with two light sensors combined in this configuration.</p>
<ul>
<li>check the intensity of each light sensor separately. </li>
<li>calculate the difference between the sensors for applying a steering value. </li>
<li>determine which sensor sees the most light at a given time. </li>
<li>determine which sensor sees the least amount of light at a given time. </li>
<li>auto calibrate a dark/light threshold value for each sensor. </li>
<li>what is the maximum intensity each sensor has recorded? </li>
<li>what is the minimum intensity each sensor has recorded? </li>
<li>determine an overall average light from the sensors. </li>
<li>determine if the robot is close to a light source. </li>
<li>determine if the robot is facing a light or not. </li>
</ul>
<p>So you can see, this list screams – Create a driver!&#160; So I did.</p>
<h2>The Driver Implementation</h2>
<p>The differential light sensor driver consolidates the logic and data necessary to accomplish the above tasks.&#160; The following represents the current functionality within the differential light sensor driver class I created.</p>
<pre class="csharpcode"><span class="rem">//FUNCTION PROTOTYPES ---------------------------------------------------</span>
<span class="kwrd">void</span> DiffLight_init();          <span class="rem">//INITIALIZE THE SENSORS</span>
<span class="kwrd">int</span> DiffLight_LeftThreshold();  <span class="rem">//CALC'D RIGHT THRESHOLD VALUE</span>
<span class="kwrd">int</span> DiffLight_RightThreshold(); <span class="rem">//CALC'D RIGHT THRESHOLD VALUE</span>
<span class="kwrd">int</span> DiffLight_Threshold();      <span class="rem">//CALC'D THRESHOLD BETWEEN LIGHT &amp; DARK</span>
<span class="kwrd">int</span> DiffLight_Average();        <span class="rem">//AVERAGE CURRENT LIGHT VALUE</span>
<span class="kwrd">int</span> DiffLight_Maximum();        <span class="rem">//LOWEST OF LOW READING FROM SENSORS</span>
<span class="kwrd">int</span> DiffLight_MaximumAvg();     <span class="rem">//AVERAGE OF LEFT &amp; RIGHT MIN VALUES</span>
<span class="kwrd">int</span> DiffLight_Minimum();        <span class="rem">//HIGHEST READING FROM EITHER SENSOR</span>
<span class="kwrd">int</span> DiffLight_MinimumAvg();     <span class="rem">//AVERAGE OF LEFT &amp; RIGHT MAX VALUES</span>
<span class="kwrd">int</span> DiffLight_Difference();     <span class="rem">//DIFFERENCE BETWEEN LEFT &amp; RIGHT VALUES</span>
typLightSensorBool DiffLight_State(); <span class="rem">//FACING LIGHT SOURCE OR NOT</span>
<span class="kwrd">bool</span> DiffLight_IsHome();              <span class="rem">//IS AT THE LIGHT SOURCE OR NOT</span>
//-----------------------------------------------------------------------</pre>
<p>One of the interesting aspects of this driver, is its auto-calibration feature.&#160; I was getting tired of setting and setting constants for light and dark values.&#160; I wanted to robot to build a knowledge&#160; base of its environment and calculate decisions on that data.&#160; All of the functions above take into account data the sensors collect and return values relative to the environment, no matter how light or dark home base and the ambient light are.&#160; This is accomplished by storing min and max values for each sensor giving the robot a basis for understanding light and dark thresholds.</p>
<p>The work horses driver functions for the collector robot code are DiffLight_Difference, DiffLight_State() and DiffLight_IsHome().</p>
<p><strong>DiffLight_Difference()</strong> is a simple function that returns the difference between the current values of the two light sensors.&#160; This value shows if a light source is on the left or right side of the robot.</p>
<p><strong>DiffLight_State()</strong> uses an algorithm to determine if the virtual sensor is facing toward or away from a light source (home).&#160; You might think this is an easy task, but experimentation showed me it can be more difficult to implement.&#160; I wound up implementing hysteresis into the function to prevent the sensor from oscillating back and forth near border zones.&#160; Once locked into IS_LIGHT or IS_DARK, the sensor needs to overcome a hysteresis factor to switch states.</p>
<p><strong>DiffLight_IsHome()</strong> is another useful function I implemented to determine if the robot is very close to the light source.&#160; I wanted a generic method for determining this, but again it turned out to be a little more complicated than expected.&#160; I wanted to know when I was ~90% to the maximum light value to determine “HOME” success.&#160; With auto-calibration, the sensor is unable to make a good decision until it gathers enough information about its environment.&#160; I implemented a minimum difference factor that makes sure the min and max values are at least 30 before allowing home to be calculated.</p>
<p>In addition, I added a structure to capture several values of interest about the sensors that can be used in internal calculations.</p>
<pre class="csharpcode">typedef <span class="kwrd">struct</span> {
  ubyte rtMax;  //RIGHT LIGHT SENSOR MAX RECORDED VALUE SINCE START
  ubyte rtMin;  //RIGHT LIGHT SENSOR MIN RECORDED VALUE SINCE START
  ubyte rtVal;  //RIGHT LIGHT SENSOR CURRENT VALUE
  ubyte ltMax;  //LEFT LIGHT SENSOR MAX RECORDED VALUE SINCE START
  ubyte ltMin;  //LEFT LIGHT SENSOR MIN RECORDED VALUE SINCE START
  ubyte ltVal;  //LEFT LIGHT SENSOR CURRENT RECORDED
} sDiffLight;
sDiffLight _dlSensor;</pre>
<p>A task that continually runs to read the values and populate the structure.&#160; The functions utilize the structure values and return appropriate values.&#160; The base code is encapsulated to keep the results consistent for all behaviors that require values.&#160; I am a fan of hiding complexity and doing things once.</p>
<p>To use the driver, include the file in your robot code and start the task.</p>
<pre class="csharpcode">#include <span class="str">&quot;driver\DiffLight-driver.h&quot;</span>

StartTask(DifferentialLightSensor);</pre>
<p>That&#8217;s it.</p>
Posted in CollectorBot, My Robots, RobotC Code  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=166&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/13/differential-light-sensor-two-nxt-light-sensors-as-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/tfr_20090713_0694_thumb.jpg" medium="image">
			<media:title type="html">Collector Robot</media:title>
		</media:content>
	</item>
		<item>
		<title>New Pages &#8211; My Bookshelf &amp; My Code Library</title>
		<link>http://roachnet.wordpress.com/2009/07/09/new-pages-my-bookshelf-my-code-library/</link>
		<comments>http://roachnet.wordpress.com/2009/07/09/new-pages-my-bookshelf-my-code-library/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 03:55:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[RobotC Code]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/09/new-pages-my-bookshelf-my-code-library/</guid>
		<description><![CDATA[ I added a couple of new pages to the blog where I posted a list of my robot books, and my Mindstorms behavior-based framework code (RobotC).&#160; I found that as I posted more articles, the code was getting lost.
I plan to add a change log for the framework, so you can all get the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=162&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_i.png"><img style="border-bottom:0;border-left:0;display:inline;margin-left:0;border-top:0;margin-right:0;border-right:0;" title="glossy_3d_blue_i" border="0" alt="glossy_3d_blue_i" align="left" src="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_i_thumb.png?w=50&#038;h=50" width="50" height="50" /></a> I added a couple of new pages to the blog where I posted a list of <a href="http://roachnet.wordpress.com/my-bookshelf/">my robot books</a>, and <a href="http://roachnet.wordpress.com/robotc-code-library/">my Mindstorms behavior-based framework code</a> (RobotC).&#160; I found that as I posted more articles, the code was getting lost.</p>
<p>I plan to add a change log for the framework, so you can all get the latest versions and know what changes were made (and why…).</p>
<p>I also created sections for behavior code to be posted, but I am not exactly sure if that makes sense because each robot requires certain sensors and structure in order for a given behavior to make any sense.&#160; </p>
<p>I think I will summarize each robot project and post zipped code for each experiment for you to download in this one place.&#160; This way you can see the robot, and view the sample associated code.</p>
</p>
<p> WordPress Tags: <a href="http://wordpress.com/tag/Code" rel="Tag">Code</a>,<a href="http://wordpress.com/tag/Library" rel="Tag">Library</a>,<a href="http://wordpress.com/tag/robot" rel="Tag">robot</a>,<a href="http://wordpress.com/tag/Mindstorms" rel="Tag">Mindstorms</a>,<a href="http://wordpress.com/tag/behavior" rel="Tag">behavior</a>,<a href="http://wordpress.com/tag/framework" rel="Tag">framework</a>,<a href="http://wordpress.com/tag/RobotC" rel="Tag">RobotC</a></p>
Posted in Information  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=162&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/09/new-pages-my-bookshelf-my-code-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_i_thumb.png" medium="image">
			<media:title type="html">glossy_3d_blue_i</media:title>
		</media:content>
	</item>
		<item>
		<title>Homing Behavior &#8211; Home in on a Light Source</title>
		<link>http://roachnet.wordpress.com/2009/07/09/homing-behavior-home-in-on-a-light-source/</link>
		<comments>http://roachnet.wordpress.com/2009/07/09/homing-behavior-home-in-on-a-light-source/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 02:25:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[Behavior-based Theory]]></category>
		<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[beacon]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[homing]]></category>
		<category><![CDATA[light sensor]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/09/homing-behavior-home-in-on-a-light-source/</guid>
		<description><![CDATA[ My next robot is taking some time to build, code and&#160; debug, so I thought I would create some quick posts about some of the behaviors I am implementing along the way.&#160; Homing in on a target is a very useful behavior that can be broadly applied to many types of situations.

Finding a beacon [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=149&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://roachnet.files.wordpress.com/2009/07/collectorlight.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="CollectorLight" border="0" alt="CollectorLight" align="right" src="http://roachnet.files.wordpress.com/2009/07/collectorlight_thumb.jpg?w=229&#038;h=155" width="229" height="155" /></a> My next robot is taking some time to build, code and&#160; debug, so I thought I would create some quick posts about some of the behaviors I am implementing along the way.&#160; Homing in on a target is a very useful behavior that can be broadly applied to many types of situations.</p>
<ul>
<li>Finding a beacon </li>
<li>Finding a light source </li>
<li>Following a line </li>
</ul>
<p> <span id="more-149"></span><br />
<h2>Homing in on a light source</h2>
<p>By placing two light sensors on the front of the robot facing ~45 degrees to left and right, we can search for a light source and home in on the signal by checking the difference in light levels between the two sensors.&#160; For example, if the light is brighter on the left, the robot will turn left attempting to equalize the signals between the two sensors (thus point directly at the light source).&#160; Moving the robot forward at the same time allows the robot to home in on the source.</p>
<p>The concept is to utilize two (or more) sensors arranged to allow the robot to consume data and make steering decisions based on signal strength or quality between the two.</p>
<h2>Implementation</h2>
<pre class="csharpcode">If (Light &gt; Threshold) {
  DriveCommand( speed, g(right-left));
}</pre>
<p>The pseudo-code above illustrates how easy homing can be implemented.&#160; If the robot sees a light to follow, it sets the drive command to move toward it using the difference between left and right light values (multiplied by a gain constant) to control the steering toward the light.</p>
<p>This code can also be implemented as a bang-bang controller by implementing a constant steering value based on the sign of (right &#8211; left).&#160; If the light is on the left, sgn() returns –1, if on the right sgn() returns +1.&#160; The gain becomes the steering value.</p>
<h2>Other Homing Actions</h2>
<p>Homing on a digital beacon can be implemented with the same logic.&#160; The difference is the left and right signals may be counted pulses.&#160; If the left sensor is aligned more to the source than the right, it should theoretically receive more pulses from the homing beacon.&#160; The above implementation can be applied to the counts.</p>
<p>Simple line following also follows this concept.&#160; Two light sensors pointing to the ground can be implemented this way by comparing the two signals and adjusting steering to keep the robot on the line.</p>
</p>
<p>WordPress Tags: <a href="http://wordpress.com/tag/Behavior" rel="Tag">Behavior</a>,<a href="http://wordpress.com/tag/robot" rel="Tag">robot</a>,<a href="http://wordpress.com/tag/beacon" rel="Tag">beacon</a>,<a href="http://wordpress.com/tag/example" rel="Tag">example</a>,<a href="http://wordpress.com/tag/concept" rel="Tag">concept</a>,<a href="http://wordpress.com/tag/logic" rel="Tag">logic</a>,<a href="http://wordpress.com/tag/light sensor" rel="Tag">light sensor</a></p>
Posted in Behavior-based Theory, CollectorBot, My Robots  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=149&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/09/homing-behavior-home-in-on-a-light-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/collectorlight_thumb.jpg" medium="image">
			<media:title type="html">CollectorLight</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding Objects &#8211; A new robot idea for an autonomous robot</title>
		<link>http://roachnet.wordpress.com/2009/07/05/finding-objects-a-new-robot-idea-for-an-autonomous-robot/</link>
		<comments>http://roachnet.wordpress.com/2009/07/05/finding-objects-a-new-robot-idea-for-an-autonomous-robot/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 05:33:00 +0000</pubDate>
		<dc:creator>Thom</dc:creator>
				<category><![CDATA[CollectorBot]]></category>
		<category><![CDATA[My Robots]]></category>
		<category><![CDATA[actions]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[behaviors]]></category>
		<category><![CDATA[BSim]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Collection]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[Jones]]></category>
		<category><![CDATA[Joseph]]></category>
		<category><![CDATA[lego]]></category>
		<category><![CDATA[mindstorms]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[Roomba]]></category>
		<category><![CDATA[Round]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[simulator]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[techniques]]></category>

		<guid isPermaLink="false">http://roachnet.wordpress.com/2009/07/05/finding-objects-a-new-robot-idea-for-an-autonomous-robot/</guid>
		<description><![CDATA[Creating a collector robot capable of finding objects within a closed environment and moving them to a centralized area using behavior-based programming.  This is the first post for this new robot I am creating as a tribute to Joseph L. Jones book; Robot Programming - A Practical Guide to Behavior-Based Robotics.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=143&subd=roachnet&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_orbs2_108.png"><img style="border-bottom:0;border-left:0;display:inline;margin-left:0;border-top:0;margin-right:0;border-right:0;" title="glossy_3d_blue_orbs2_108" border="0" alt="glossy_3d_blue_orbs2_108" align="left" src="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_orbs2_108_thumb.png?w=50&#038;h=50" width="50" height="50" /></a> I started this blog about a month ago to share ideas and robot programs using behavior-based techniques.&#160; I went back to one of my favorite books, “<a href="http://www.amazon.com/Robot-Programming-Practical-Behavior-Based-Robotics/dp/0071427783/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1246850616&amp;sr=8-1" target="_blank">Robot Programming – A Practical Guide to Behavior-Based Robotics</a>” by Joseph L. Jones to renew my ideas.</p>
<p> <span id="more-143"></span>
</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:0f42b1cf-ddf2-4a77-96e6-5cd95bf2b180" class="wlWriterEditableSmartContent">
<table cellspacing="0" cellpadding="2" width="400" border="0">
<tbody>
<tr>
<td valign="top" width="400">
<p><a title="Robot Programming : A Practical Guide to Behavior-Based Robotics" href="http://www.amazon.com/exec/obidos/ASIN/0071427783/troach242"><img src="http://images.amazon.com/images/P/0071427783.01.MZZZZZZZ.jpg" border="0" align="left" style="float:left;">Robot Programming : A Practical Guide to Behavior-Based Robotics</a></p>
<p><b>ISBN</b>: 0071427783<br /><b>ISBN-13</b>: 9780071427784</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>I have decided to create a Lego NXT robot that is similar to the one featured in the online simulator that used to run for this book.&#160; Unfortunately, the site was disbanded a while back so you can’t see it in action, but you can still find the user documentation <a href="http://www.behaviorbasedprogramming.net/manual.html" target="_blank">here</a>.&#160; The java code for BSim is <a href="http://bsim.cvs.sourceforge.net/viewvc/bsim/bsim/" target="_blank">here</a>.&#160; Anyone want to host this applet?&#160; It is pretty cool.</p>
<p>The task I am interested in is “Collection Task”.&#160; This task uses several behaviors to have the robot move around an area collecting pucks and moving them to a light source in the middle.&#160; It is fun to watch in Bsim because none of the behaviors collects anything?!&#160; Each behavior they implement performs its goals that collectively solve this challenge.&#160; The <a href="http://www.behaviorbasedprogramming.net/manual.html#Collection%20Task">Collection Task</a> uses behaviors <a href="http://www.behaviorbasedprogramming.net/manual.html#Escape">Escape</a>, <a href="http://www.behaviorbasedprogramming.net/manual.html#Dark-push">Dark-push</a>, <a href="http://www.behaviorbasedprogramming.net/manual.html#Anit-moth">Anti-moth</a>, <a href="http://www.behaviorbasedprogramming.net/manual.html#Avoid">Avoid</a>, <a href="http://www.behaviorbasedprogramming.net/manual.html#Home">Home</a>, and <a href="http://www.behaviorbasedprogramming.net/manual.html#Cruise">Cruise</a> in order of decreasing priority.</p>
<p>&#160;</p>
<p>Of course, I have some hurdles to overcome implementing this on my Lego NXT robot.&#160; Challenges are fun, right!</p>
<p>Here are some of my initial challenges.</p>
<ul>
<li>Robot shape – Their robot is like <a href="http://store.irobot.com/category/index.jsp?categoryId=3334619&amp;cp=2804605&amp;ab=CMS_IRBT_Storefront_062209_vacuumcleaning" target="_blank">Roomba</a>.&#160; Round and smooth.&#160; Sensors are cool and well thought out.&#160; Robot actions are very cool.</li>
<li>Limited sensors on the <a href="http://mindstorms.lego.com/eng/Egypt_dest/Default.aspx" target="_blank">Mindstorms</a> robots.&#160; There are several sensors engaged on Bsim.&#160; Some creativity with the NXT is necessary to come close.</li>
<li>The simulator has a perfect world where everything works as designed.</li>
<ul>
<li>Lights are a problem because in the simulator they do not reflect light off the walls or objects.&#160; They are easy to home in on.&#160; The real world is not so easy.</li>
<li>BSim is able to understand PUSHING a puck vs. COLLIDING with a wall.&#160; That is tougher with the NXT.&#160; To implement this, you may need to be able to implement a stall sensor or something like it.&#160; I have not been able to consistently make a stall sensor reliable.&#160; I have some ideas around this.</li>
</ul>
</ul>
<p>I am up for the challenge.&#160; I built and programmed a prototype this week, but still have some more work to do.&#160; I will post more progress this week.</p>
<p>Stay tuned…</p>
<p>&#160;</p>
<p>WordPress Tags: <a href="http://wordpress.com/tag/robot" rel="Tag">robot</a>,<a href="http://wordpress.com/tag/ideas" rel="Tag">ideas</a>,<a href="http://wordpress.com/tag/behavior" rel="Tag">behavior</a>,<a href="http://wordpress.com/tag/Practical" rel="Tag">Practical</a>,<a href="http://wordpress.com/tag/Guide" rel="Tag">Guide</a>,<a href="http://wordpress.com/tag/Robotics" rel="Tag">Robotics</a>,<a href="http://wordpress.com/tag/Joseph" rel="Tag">Joseph</a>,<a href="http://wordpress.com/tag/Jones" rel="Tag">Jones</a>,<a href="http://wordpress.com/tag/Lego" rel="Tag">Lego</a>,<a href="http://wordpress.com/tag/documentation" rel="Tag">documentation</a>,<a href="http://wordpress.com/tag/code" rel="Tag">code</a>,<a href="http://wordpress.com/tag/BSim" rel="Tag">BSim</a>,<a href="http://wordpress.com/tag/task" rel="Tag">task</a>,<a href="http://wordpress.com/tag/Collection" rel="Tag">Collection</a>,<a href="http://wordpress.com/tag/Roomba" rel="Tag">Roomba</a>,<a href="http://wordpress.com/tag/Round" rel="Tag">Round</a>,<a href="http://wordpress.com/tag/Sensors" rel="Tag">Sensors</a>,<a href="http://wordpress.com/tag/actions" rel="Tag">actions</a>,<a href="http://wordpress.com/tag/Mindstorms" rel="Tag">Mindstorms</a>,<a href="http://wordpress.com/tag/world" rel="Tag">world</a>,<a href="http://wordpress.com/tag/Lights" rel="Tag">Lights</a>,<a href="http://wordpress.com/tag/walls" rel="Tag">walls</a>,<a href="http://wordpress.com/tag/sensor" rel="Tag">sensor</a>,<a href="http://wordpress.com/tag/prototype" rel="Tag">prototype</a>,<a href="http://wordpress.com/tag/techniques" rel="Tag">techniques</a>,<a href="http://wordpress.com/tag/goals" rel="Tag">goals</a>,<a href="http://wordpress.com/tag/robots" rel="Tag">robots</a>,<a href="http://wordpress.com/tag/simulator" rel="Tag">simulator</a>,<a href="http://wordpress.com/tag/behaviors" rel="Tag">behaviors</a></p>
Posted in CollectorBot, My Robots  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/roachnet.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/roachnet.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/roachnet.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/roachnet.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/roachnet.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/roachnet.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/roachnet.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/roachnet.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/roachnet.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/roachnet.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=roachnet.wordpress.com&blog=8252109&post=143&subd=roachnet&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://roachnet.wordpress.com/2009/07/05/finding-objects-a-new-robot-idea-for-an-autonomous-robot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6ec42eb9fd1f6929f16bd75139dfe0f9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Thom</media:title>
		</media:content>

		<media:content url="http://roachnet.files.wordpress.com/2009/07/glossy_3d_blue_orbs2_108_thumb.png" medium="image">
			<media:title type="html">glossy_3d_blue_orbs2_108</media:title>
		</media:content>

		<media:content url="http://images.amazon.com/images/P/0071427783.01.MZZZZZZZ.jpg" medium="image" />
	</item>
	</channel>
</rss>