RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Using Microsoft Robotics Studio to Program Parallax's Boe-Bot : Page 3

With the newly released Microsoft Robotics Studio and Parallax's Boe-Bot Robot Kit, which uses Bluetooth technology, robotic programming has become accessible to anyone with .NET programming skills.

How the Code Works
The BoeBotControlForMsrsCtp2.bs2 file acts like a software driver for the Boe-Bot. It receives instructions from .NET programs and determines which PBASIC commands the driver must execute to attain the desired outcome from the robot. For example, clicking the right arrow button on the form in Figure 3 executes the following code:

   _mainPort.Post(new TurnRight());
The TurnRight operation is one of five operations that the tutorial code supports. It also supports Stop, Forward, Backward, and TurnLeft, each of which corresponds to one of the buttons on the form. These also correspond with a class and handler defined in the RoboticsTutorial4Types file. Each class derives from a basic type used to submit a request to the robot. Here's what the class and handler look like for the TurnRight operation:

   public class TurnRight : Submit<TurnRightRequest, 
      PortSet<DefaultSubmitResponseType, Fault>>
           public TurnRight()
               : base(new TurnRightRequest())
       public class TurnRightRequest { }
The instructions for the Boe-Bot reside in the TurnRightHandler. This handler first ensures that the motor is enabled and then instantiates a SetDrivePowerRequest object. This object has properties that correspond to the amount of power that must be requested from both the right and left motors. To turn right, for example, the Boe-Bot requires a left wheel power level instruction that is the opposite of the value assigned to the right wheel power level. Here's the code:

   public virtual IEnumerator<ITask> TurnRightHandler(
      TurnRight forward)
      if (!_state.MotorEnabled)
         yield return EnableMotor();
      drive.SetDrivePowerRequest request = new
      request.LeftWheelPower = 0.5;
      request.RightWheelPower = -0.5;
      yield return Arbiter.Choice(
         delegate(DefaultUpdateResponseType response) { },
         delegate(Fault fault)
            LogError(null, "Unable to turn right", fault);
This request must be interpreted by the Boe-Bot, which is where the BASIC BoeBotControlForMsrsCtp2.bs2 program comes in. That program accepts the incoming request through the serial port and executes the appropriate BASIC code. The code to set the power for the motors is as follows:

   ' -----[ Subroutine Set_Servo_Speed ]----------
   ' Range of 0 to 200 with 100 = stopped 
   ' maps to 650 to 850 with 750 stopped.
     tLeft = buffer3 + 650    ' Decode servo speed.
     tRight = buffer4 + 650
Making Changes to the Robotics Studio Samples
If you decide to make any changes to the samples and tutorials provided with Robotics Studio, you will need to do a full recompile of the samples.sln file before you can execute any of the samples. This is due to strong name signing. Unless you do this you will receive an error stating that "Duplicate assemblies exist in the Robotics SDK which may prevent this service from operating normally." To recompile, navigate to the \Microsoft Robotics Studio (October 2006)\Samples directory and open the Samples.sln file in Visual Studio. Select "Rebuild Solution" from the Build menu and ensure that the status bar shows that the build succeeded.

Adding Boe-Bot Accessories
The Boe-Bot kit comes with wire whiskers that allow it to detect objects and thus avoid collisions. It also comes with photoresistors that allow it to perform light-sensitive navigations, and infrared object detection sensors for non-contact object detection. All these sensors let you program the Boe-Bot to navigate through its environment safely and effectively. You can even program it in an autonomous mode so that it wanders around avoiding obstacles as necessary.

In addition to the sensors provided with the Boe-Bot kit, you can purchase special accessory kits to go with it. For instance, you can purchase a line-follower kit that uses an infrared emitter and receiver to follow a strip of electrical tape across white poster board. You can also purchase a digital encoder kit that allows the Boe-Bot to get position feedback and thus perform well in maze-solving contests. My favorite kit is the CMUCam AppMod that allows the Boe-Bot to see.

What's Next?
The Boe-Bot is just one of several robot kits available on the market today. At this moment, it is one of only a few that Robotics Studio supports, but I expect that number to increase in time. Robots are becoming more mainstream everyday and it will not be long before their practical benefits let them infiltrate every level of business. The sooner you learn the concepts surrounding robotics programming the better prepared you will be. And best of all, it is a lot of fun.

Sara Morgan Rea is a 2007 Microsoft MVP for Office Communications Server. Her first book, Building Intelligent .NET Applications, was published in 2005. In addition to co-authoring several Microsoft Training Kits, she recently published Programming Microsoft Robotics Studio. She currently works as a robotic software engineer at CoroWare.com.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date