I have wanted to do this with my kids for some time.  I have seen several kits that are expensive that I just don't care to purchase.  Well now I have no excuse http://homepage.ntlworld.com/telescope/Rocketweb/index.htm

 

A previous post I explained how simple it is to test your code even though you might not have a fancy test framework like NUnit.  In this post I am going to give another example of what I did to tackle a robot navigation problem and fully testing it without actually running the code in a real robot.  My point here is that it is a good practice to write test code to test sub modules to simulate all possible scenarios that would be tough to do in the real robot.

So here is the problem:

I have a compass module that outputs a heading value that equates to 0-359 degrees. I needed a module that when given a target heading and a current heading it could return the differance between the two in degrees. The return heading difference would range from -180 to 180 degrees. This return value could be processed further to determine which direction the robot needed to turn to reach the target heading. A negative heading ment to turn left and a positive number would mean turn right.

So my approach was to first identify a list of target and current headings and what I would expect the return value would be for these input parameters. I did this for 17 different scenarios. I placed the values in a spread sheet and analyzed the pattern that emerged. I took this pattern and coded a simple class (module) that would impliment the pattern.

Here is the method of the class:

Public Function GetHeadingDifference(currentHeading as Integer) As Integer
  ' Returns the following
  ' -180 to + 180
  ' Negative number means the robot would have to turn to the left to get closer 
  ' to the targetHeading
  ' Uses module variable targetHeading
  
  Dim targetMinusCurrent as Integer
  targetMinusCurrent = targetHeading - currentHeading
  
  If (targetMinusCurrent<181) And (targetMinusCurrent>-181) Then
    GetHeadingDifference=targetMinusCurrent
    Exit Function
  End If
  
  If (targetMinusCurrent<-180) Then
    GetHeadingDifference=360 - ABS(targetMinusCurrent)
    Exit Function
  End If
    GetHeadingDifference=(360-ABS(targetMinusCurrent)) * (-1)
End Function

I then created another test class (module) that would call the navigation module and pass in the 17 scenarios and validate the return heading.

Public Sub Main()
  '.......... Test code ..........
  'This needs to be done only once per program, or when you want to change the baud
  Call UARTsetup(3, 19200)  
  InitializeNavigation
  Dim testResult as Integer
  Dim newHeading as Integer
  Dim targetHeading as Integer
  Dim currentHeading as Integer
  
  '****************************************
  'Test TestHeading
  '****************************************
  DebugPrintLine "TestHeading Tests"
  newHeading=180
  currentHeading=180
  SetTargetHeading newHeading
  testResult=TestHeading(currentHeading)
  If (testResult<>0) Then
    DebugPrintLine "Test 1 Failed"
  Else
    DebugPrintLine "Test 1 Passed"
  End If
  newHeading=180
  currentHeading=183
  SetTargetHeading newHeading
  testResult=TestHeading(currentHeading)
  If (testResult<>-1) Then
    DebugPrintLine "Test 2 Failed"
  Else
    DebugPrintLine "Test 2 Passed"
  End If
........... more test code omitted for clarity 
End Sub 

I used the 17 scenaros that I layed out on the spread sheet to prove out my logic. Since the module is fully tested based on these scenarios I have complete confidence that the module will work when it is included in the main robot code project.

Well I have wanted to get an external drive to solve one primary problem I have. Desktop and Laptop synchronization.

First Some Background

I am a permanent virtual employee for a company in Scottsdale Arizona. I use the company desktop PC in my home office. I routinely travel to Scottsdale which forces me to take along a laptop. The main problem I have is getting my files off the desktop and onto the laptop for the trip. Then when I return from the trip I like to move the files from the laptop onto the desktop. Well to transfer a large amount of files over ethernet from desktop to laptop and back can be a very slow process while VPNed in. The transfer goes through Scottsdale. I can't even use local IP addresses to route the traffic. Currently I only had one option. Disconnect from VPN and transfer the files. This basically keeps me from working at all while the copy is happening. So I needed another solution.

Enter the solution

Since I had a Comp USA gift card of a sizeable amount I decided to start at my local store looking for an external drive solution. I had an old 5 1/4 30 gig hard drive that I intended to just get an external USB case for. The drive came out of an old computer and I wasn't even sure if it was fully functional. Looking at external cases they where around $40. Seemed like a large amount of changed to drop on just a case. So I started to look for another solution. I stumbled across the Hammer Storage 80 gig USB 2.0 device that was on sale (with rebate) for $69. Most other external drive solutions started at $99 so this seemed in my price range. So I grabbed one of these drives and took it home.

Conclusion

I am very happy with the device. You don't even have to load any drivers for it! It just works! I made some simple batch files to copy the data from my desktop to the external drive. And it worked relatively fast. The best thing is that I can continue to work as it is copying files. Now getting my laptop ready for a trip is no longer a painful process.