locked
Problems with the book Microsoft Press - Programming Microsoft® Robotics Studio by Sara Morgan?! RRS feed

  • Question

  • Problems with the book Microsoft Press - Programming Microsoft® Robotics Studio by Sara Morgan?!

    THE BOOK HAS HUGE ERRORS, and they all seem to be documented here:
    http://oreilly.com/catalog/errata.csp?isbn=9780735624320
    Finding this page has eased the pain A LOT.

    I'm at chapter 5:
    Building a BasicDrive Program
     
    This simply isn't just your simple follow along book. At the end of the chapter you are told to compile but there are obvious chunks of the code missing like the DropHanler, ReplaceHandler, GetHandler.

    My slooow brain has managed to figure out that the generic implementations in chapter 2 (different project) would do the trick of "playing ball" for the time being.

    Am i missing something here?! Should i continue like this?

    Friday, October 8, 2010 3:15 PM

Answers

  • Here are the missing Handlers to get the code to run:

      [ServiceHandler(ServiceHandlerBehavior.Concurrent)]
      public virtual IEnumerator<ITask> GetHandler(Get get)
      {
       get.ResponsePort.Post(state);
       yield break;
      }
    
    
      [ServiceHandler(ServiceHandlerBehavior.Teardown)]
      public virtual IEnumerator<ITask> DropHandler(DsspDefaultDrop drop)
      {
       // Perform service specific shutdown logic including shutting
       // down dependent service instances
    
       // Perform default shutdown logic
       base.DefaultDropHandler(drop);
    
       // Shutdown complete
       yield break;
      }
    
      [ServiceHandler(ServiceHandlerBehavior.Exclusive)]
      public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
      {
    
       state = replace.Body;
       replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
       yield break;
      }
    

    And where you register the message handlers with the main interleave you need

    Arbiter.ReceiveWithIterator<DsspDefaultDrop>(false, _mainPort, DropHandler)
    instead of:
    Arbiter.Receive<DsspDefaultDrop>(false, _mainPort, DropHandler)
     

    Saturday, October 9, 2010 4:19 PM

All replies

  • Just found others:
    1. It should be like this: (base.OnClosed can't be called from where it tells you to add the code)

    The last thing to add is a clean-up method for handling when the form is closed. In this case, we want to send a request that drops the BasicDrive service. The code for this method, which you can add just under the DriveDialog method, by right-clicking DriveDialog.cs and selecting View Code, is as follows:

     protected override void OnClosed(EventArgs e)
     {
     _mainPort.Post(new DsspDefaultDrop(DropRequestType.Instance));
     base.OnClosed(e);
     }
    
    
    

    2. On the line where it says:

    The manifest file that is used to access the Create's drive system and contact sensors is named iRobot.DriveBumper.manifest.xml. This file is included with the MSRS installation, and it is located in the \samples\config folder. To load this additional manifest, you need to modify the project properties for the BasicDrive service. You accomplish this by clicking Project and then BasicDrive Properties. Click the Debug tab (see Figure 5-6) and locate the text box named Command Line Arguments. Append the following to the end of this line:

    -m:"samples\config\iRobot.DriveBumper.manifest.xml"

    That -m SHOULD be /m like in:

    /m:"samples\config\iRobot.DriveBumper.manifest.xml"

    3. A boolean value has to be created to "hold" the get set, otherwise you get a "stackoveflow" when compiling:

    The state represents the service at the time it is requested, and state variables are containers for the individual pieces of information that make up the state. For this service, we will have a single state variable that indicates whether the motor has been enabled. To add this state variable, append the following code to the public class named BasicDriveState (this class definition was created automatically by the Visual Studio template and is included in the BasicDriveTypes class file):

    /// <summary>
    /// Indicates if the Motor is running.
    /// </summary>

    [DataMember]
    public bool MotorRunning
    {
    get { return _motorRunning; }
    set { _motorRunning = value; }
    }

    SHOULD BE:

    /// <summary>
    /// Indicates if the Motor is running.
    /// </summary>

    bool _motorRunning

    [DataMember]
    public bool MotorRunning
    {
    get { return _motorRunning; }
    set { _motorRunning = value; }
    }

    Saturday, October 9, 2010 12:34 PM
  • That's it... i've finished Chapter 5.

    There is one big problem. Although Visual Simulation Environment is there to ease the pain for people developing without the ACTUAL hardware. The book does not take advantage of it. I would've been nice to stick a VSE on my BasicDrive and actually see the "fruits" of my work, but it doesn't... and i don't know how to do it.

    I'll keep on going forwards :D maybe i will... come back and rewrite the book. Never surrender!!! AAAAAHHHHH

    Saturday, October 9, 2010 4:08 PM
  • Here are the missing Handlers to get the code to run:

      [ServiceHandler(ServiceHandlerBehavior.Concurrent)]
      public virtual IEnumerator<ITask> GetHandler(Get get)
      {
       get.ResponsePort.Post(state);
       yield break;
      }
    
    
      [ServiceHandler(ServiceHandlerBehavior.Teardown)]
      public virtual IEnumerator<ITask> DropHandler(DsspDefaultDrop drop)
      {
       // Perform service specific shutdown logic including shutting
       // down dependent service instances
    
       // Perform default shutdown logic
       base.DefaultDropHandler(drop);
    
       // Shutdown complete
       yield break;
      }
    
      [ServiceHandler(ServiceHandlerBehavior.Exclusive)]
      public virtual IEnumerator<ITask> ReplaceHandler(Replace replace)
      {
    
       state = replace.Body;
       replace.ResponsePort.Post(DefaultReplaceResponseType.Instance);
       yield break;
      }
    

    And where you register the message handlers with the main interleave you need

    Arbiter.ReceiveWithIterator<DsspDefaultDrop>(false, _mainPort, DropHandler)
    instead of:
    Arbiter.Receive<DsspDefaultDrop>(false, _mainPort, DropHandler)
     

    Saturday, October 9, 2010 4:19 PM