locked
NXT-MSRS question... RRS feed

  • Question

  •  

    Hi,

     

    I'm new to MSRS and NXT.  My first project is to create a simple program to read a input from the computer and send the command to the NXT robot.

     

    Here are my questions:

    - After I send the power, degree, stopstate parameter to the NXT motor (v2), it doesn't stop and keep rotating with a pulse.  What did I do wrong?  I specifically put the "motorstopstate.brake" in the stopstate attribute but no help.

    - How can I build a executable from MVPL?  All it builds is "service".  I don't know how to excute it outside MVPL.

    - Can I go further to build a web inteface?

     

    You help is greatly appreciate!

     

    Thanks!

     

    DDT

     

    Tuesday, September 30, 2008 7:27 PM

Answers

  • As far as being responsive, you have to realise that VPL is talking to the LEGO NXT over Bluetooth, so there is some delay. I assume that when you say using "the Lego NXT program" you are referring to a program running directly on the brick, which will of course be much faster.

     

    To compile a service from VPL you just need to select the Compile As a Service option. Before you do that however, check the properties on the diagram itself and make sure that you have specified where you want the output files to go.

     

    When you compile a VPL diagram as a service, VPL writes C# code and then compiles it for you. Once it is compiled, it should show up in the Services panel and you can use it from another VPL diagram. However, if you edit the C# code and change it, then you cannot import it back into VPL. So just be aware that if you start making changes to the C# code you can no longer use VPL to help you. Also, the generated code is human-readable, but it might be a little difficult to understand because it is generated by a computer :-)

     

    Trevor

     

    Wednesday, October 1, 2008 6:12 PM
  • There is a great help page that describes the configuration of the Lego NXT sensors which will probably help you a lot.  I don't seem to be able to find it in the online documentation, but in the 1.5 documentation, it is located at:

     

    Robotics Tutorials and Samples -> Setting Up Your Hardware -> LEGO Mindstorms NXT

     

    If you can't find it, I can probably copy it and post an attachment.  (Perhaps Trevor knows where this information has moved to).  I think it is a very valuable page.

     

    The page says that the Lego encoders can be configured to any number of ticks-per-revolution.  And whenever a 'tick' happens, the brick sends an update to the computer.  If you want to stop the motor after X ticks, the computer monitors these updates and tells the motor to stop when it has seen the proper number.  Now as Trevor said, because the controlling code is on the computer and it has to go over Bluetooth, there is some delay when talking to the brick.  This is bad news when you are trying to control the motor rotations accurately. 

     

    There are a few ways for this to fail.  The most common is that just because of all the delays, by they time the computer gets the notification that the wheel is at the proper rotation, and sends the stop command, the wheel has rotated past the mark quite a bit. This can be solved by slowing down the motor.  Or possibly telling the motor to stop before your actual desired mark.  For example, tell it to stop at 29 ticks instead of 30.

     

    The other failure mode is if the ticks-per-revolution are set too high on the motor, then the PC can actually miss lots of encoder updates from the brick.  This is just because the motors spins faster than the brick can send Bluetooth packets.  I have found that when the motor is going at full speed, anything more accurate than 6 ticks-per-revolution will drop updates.  So you should not set your ticks-per-revolution to anything more than 6 unless you are driving the motors slowly.

     

    Hope this helps,

    -Ben

    Sunday, October 5, 2008 3:26 PM

All replies

  • I am not sure about the problem with the motors. Are you using V1.5 or the July CTP? Can you tell us exactly which request you are using and the values of the parameters?

     

    You can use the "Compile as a Service" option in VPL. This creates a C# service. However, you will need Visual Studio installed on your PC to edit the source code. To run it you will need a manifest (which should also be created) and then you can execute it from a DSS Command Prompt or from the debugger in Visual Studio.

     

    To create a web interface is definitely possible, but you probably need to get the rest of the program working first.

     

    Trevor

    Wednesday, October 1, 2008 3:15 AM
  • Thank you very much for your reply.

     

    I kind of found out what caused the motor problem.  I put the motor command in an "Activity" container. And I didn't past the right variables to the container and cost no motion or weird motion. 

     

    Now the motor is turning and stopping, but it still react much less responsive and precisive than I expected.  It's like a drunk man walking. It turns very responsive and precisive when I send command using the Lego NXT program. Is that normal? (I'm using V1.5)

     

    Can you point me to a web site that show me in detail how to use visual studio.net to build a exe from the service created by MVPL?  I have visual studio.net installed already.

     

    Thanks!!!

     

    DDT

     

     

    Wednesday, October 1, 2008 5:55 PM
  • As far as being responsive, you have to realise that VPL is talking to the LEGO NXT over Bluetooth, so there is some delay. I assume that when you say using "the Lego NXT program" you are referring to a program running directly on the brick, which will of course be much faster.

     

    To compile a service from VPL you just need to select the Compile As a Service option. Before you do that however, check the properties on the diagram itself and make sure that you have specified where you want the output files to go.

     

    When you compile a VPL diagram as a service, VPL writes C# code and then compiles it for you. Once it is compiled, it should show up in the Services panel and you can use it from another VPL diagram. However, if you edit the C# code and change it, then you cannot import it back into VPL. So just be aware that if you start making changes to the C# code you can no longer use VPL to help you. Also, the generated code is human-readable, but it might be a little difficult to understand because it is generated by a computer :-)

     

    Trevor

     

    Wednesday, October 1, 2008 6:12 PM
  • Thanks for your reply.

     

    I've downloaded the July CTP version and I will try the C# build once I got my program stabllzed.

     

    I've got all the algorithm working.  Just that the motor problem is still lingering.

     

    I can live with the little delay on execution. But I can't live with the inaccuracy of their turning degree.

    My project totally depends on the accuracy of the motor turning degree.  To pin down the problem, I even set constant numbers on rotation degree command to eliminate any wrong variables passing.  Say, I asked the motor to turn 90 degree forward and then 90 degree backward, after a few runs, it totally shift the start position.

     

    Is it a known limitation I have to accept??  I would really surpised since the whole robotic programing should have accuracy as pirority.  (BTW, if I program it in Lego mindstorm NXT and download it to the brick, the motor turning degree are absolutely consistent.)

     

    Thanks!

     

    DDT

     

     

     

    Friday, October 3, 2008 5:04 PM
  • There is a great help page that describes the configuration of the Lego NXT sensors which will probably help you a lot.  I don't seem to be able to find it in the online documentation, but in the 1.5 documentation, it is located at:

     

    Robotics Tutorials and Samples -> Setting Up Your Hardware -> LEGO Mindstorms NXT

     

    If you can't find it, I can probably copy it and post an attachment.  (Perhaps Trevor knows where this information has moved to).  I think it is a very valuable page.

     

    The page says that the Lego encoders can be configured to any number of ticks-per-revolution.  And whenever a 'tick' happens, the brick sends an update to the computer.  If you want to stop the motor after X ticks, the computer monitors these updates and tells the motor to stop when it has seen the proper number.  Now as Trevor said, because the controlling code is on the computer and it has to go over Bluetooth, there is some delay when talking to the brick.  This is bad news when you are trying to control the motor rotations accurately. 

     

    There are a few ways for this to fail.  The most common is that just because of all the delays, by they time the computer gets the notification that the wheel is at the proper rotation, and sends the stop command, the wheel has rotated past the mark quite a bit. This can be solved by slowing down the motor.  Or possibly telling the motor to stop before your actual desired mark.  For example, tell it to stop at 29 ticks instead of 30.

     

    The other failure mode is if the ticks-per-revolution are set too high on the motor, then the PC can actually miss lots of encoder updates from the brick.  This is just because the motors spins faster than the brick can send Bluetooth packets.  I have found that when the motor is going at full speed, anything more accurate than 6 ticks-per-revolution will drop updates.  So you should not set your ticks-per-revolution to anything more than 6 unless you are driving the motors slowly.

     

    Hope this helps,

    -Ben

    Sunday, October 5, 2008 3:26 PM
  • Thank you for you guys' help. You are very helpful!

     

    After spending several days dealing with the motor problem, I found myself getting into a deadend. I tired adjusting the ticks, it didn't help neither.  So, I stepped back and changed my scheme.  Rather than controlling the motors by MVPL directly, I saved all the articulation I need into the NXT brick using the Lego mindstrom NXT program.  Then I used the MVPL to call and run each aritculation program I need according to the program logic.  That way I can get the accuracy and responsiveness I want and I can easliy fine tune the aritculation thru lego NXT program without touching my code on MVPL.  Problem Solved! Smile

     

    Though I can work around my issue here, I think there are many cases, say you need to control how many degrees the motor turns according to the input, you have to control the motor thru MVPL (well in theory, you can preset 360 programs for it. Stick out tongue).  Anyway, enough MVPL for me for now.

     

    Thanks again!

     

    DDT

     

     

     

    Monday, October 6, 2008 4:57 PM
  • sir i have a problem with system generated code for lab7(vplHandonlabs/lab7) i.e. tasklearing via speech recognition. The mvpl file for lab7 is executing properly. But the code generated by system is having some bugs. The code is compiling but, the robot in the simulation environment is not responding to the human actions. I dont understand what the problem is. please help me. i hav to sumbit my prob by the time. so, please help me... In TaskLearner.cs file, in 147 line i changed the mode (.Exclusive to .Concurrent). The intial problem is cleared. But now i have a problem with  learing. The robot cannot responds to the command "Perform Action". i request you to kindly look into my matter.
                      Thanking you.
    Wednesday, April 1, 2009 6:29 AM