locked
LegoNXTDrivev2 invalid DriveDistanceStage when operating. RRS feed

  • Question

  • Hi,

    I'v ben trying to write simple app in VPL that drives LEGO robot in square. The sample provided with MRDS 4 is related to the iRobot (simulated) so I equipped the idea with detecting "Completed" on the run but I've found very strange behavior: "Completed" appears BEFORE physical run is finished (actually it appears right after movement is started). In case of reference sample using iRobot, VSE and GenericDifferentialDrive (Microsoft Robotics Dev Studio 4\samples\VplHandsOnLabs\Lab4\mvpl) the Completed stage of the Generic drive appear AFTER move is finished. If this behaviors is by design, how do I actually know that LegoNXTDrivev2 has finished doing its job?

    Regards,

    Piotr

    Thursday, August 23, 2012 4:40 PM

Answers

  • OK, I see the same behavior you do.  I agree that it's a bug based on the book MRDS which has a VPL example that shows creating complex movement like you are attempting based on chaining together Drive commands.  I've filed a bug in our bug tracking database.

    Monday, August 27, 2012 7:33 PM
    Moderator

All replies

  • The general answer is that RDS uses an asynchronous programming approach called 'CCR' or Concurrency & Coordination Runtime.  From your rough description, it sounds like you're firing off a number of asynchronous tasks without awaiting for them to finish first.  This makes the tasks appear to 'finish' instantaneously and hit your 'completed' step.  What's happening behind the scenes is you have a number of tasks running in the background still.

    There are a number of documents on using CCR linked from this thread.

    Thursday, August 23, 2012 5:38 PM
    Moderator
  • Hi Jay,

    Thanks for the quick reply but it is too general, afaik - let's go into a bit deeper look. Take a look at the following example in VPL (image below), please. I wonther if there are more than one asynchronous tasks that actively changes DriveState - the only one I can see is "starting" robot at the beginning, setting distance to 1m with power on 50% (DriveDistanceState is left null that is correctly identified according to the documentation as DriveStage.InitialRequest, I believe).

    Let me explain this behavior in depth: application below is supposed to show msgbox saying "Started", then travel LEGO Mindstorms Tribot for about 1 meter and finally show msgbox "Completed" - as taken from the example on iRobot (mentioned above).

    But instead of desired behavior, the observed is that "Completed" msgbox appears BEFORE physical run is finished (actually it appears right after move forward is started). I don't think there is any other task messing with LEGONXTDrivev2 as it is the only DSS node running at the moment, ane application is pretty simple.

    I think there is a mistake in NXTDrivev2 implementation, as DriveState.Completed should be fired when LEGONXTDrivev2 "travels" the desired distance, but it doesn't wait for the task to be "completed".

    Regards,

    P.

    Thursday, August 23, 2012 6:42 PM
  • One more experiment done may point that there do exists invalidity in implementation. I've created the following test - both physical NXT Tribot and virtual one are expected to drive 1m simultanously (well, almost ;-) ). Both are expected to display appropriate msgbox on beginning and ending their movement. The observed behavior is:

    - DSS Node starts

    1. Physical NXT Tribot raises DriveStage.Started.

    2. VSE robot raises DriveStage.Started.

    3. Both robots starts to move.

    4. NXT Tribot raises DriveStage.Completed (but still moves with full speed).

    5. Both robots stop.

    6. VSE Tribot raises DriveStage.Completed (it doesn't move).

    I believe behavior of VSE Tribot is correct but behavior of physical one is wrong (steps 4 and 5 should be swapped).

    The source MVPL solution is provided here for download feel free to download - should be anonyous available.

    Hope that helps,

    P.

    Thursday, August 23, 2012 8:14 PM
  • Thank you for the detailed response.  Yes, I was able to download the source and I'll investigate.
    Thursday, August 23, 2012 9:32 PM
    Moderator
  • You're welcome.

    P.

    Saturday, August 25, 2012 8:02 AM
  • OK, I see the same behavior you do.  I agree that it's a bug based on the book MRDS which has a VPL example that shows creating complex movement like you are attempting based on chaining together Drive commands.  I've filed a bug in our bug tracking database.

    Monday, August 27, 2012 7:33 PM
    Moderator
  • Thanks,

    Looking forward for a patch ;-).

    Regards,

    Piotr

    Thursday, August 30, 2012 6:03 AM