locked
Desktop Y Axis Not Working RRS feed

  • Question

  • I am attempting to control th Mindstorm NXT using the Desktop Joy Stick in Visual Programming Language. I have made it so that the X Axis controls left/right motion and the Y Axis controls the forward/backward motion. The X Axis works perfectly fine, no problems. But when I use the Y Axis (forward and backward) the wheels just kind of twitch every so often. I have searched everywhere and cannnot find the answer. 
    Thursday, December 15, 2011 1:24 AM

Answers

  • This might be way off the mark, but I am just wondered if you are doing a calculation like X / 1000 in a Calculate block? This will result in 0 unless X is exactly 1000 (fully pushed to the right) when it will be 1 because VPL does integer arithmetic in this case. You can however write X / 1000.0 and this will result in a floating point value, which is what you want, i.e. a value that ranges from -1.0 to +1.0.

    By the way, I have played around with the Desktop Joystick in response to your question and I can get the full range of values out of both X any Y axes. I have not tried driving a LEGO NXT though because I do not have one readily at hand.

    Trevor

     

    Monday, January 2, 2012 12:05 AM

All replies

  • My guess is that the calculation is producing very small values for the left and right wheel power. The results should be between -1.0 and +1.0.

    Trevor

     

    Friday, December 16, 2011 4:35 AM
  • Thanks, but I tried setting the drive to 1, 1.0 and various other values such as .95, and still no luck.

    Saturday, December 17, 2011 9:25 PM
  • Respected Sir,

    You can set the drive power. Please go through the following paragraph that I got from MSDN article which might help you out.

    SetDrivePower accepts power settings for the left and right wheels as values between -1.0 and 1.0 (doubles). Negative values mean that the wheel should rotate backwards, and positive values mean the wheel should rotate forwards.

    Successive SetDrivePower requests can be used to vary the motor powers and achieve complex driving patterns. Each new request simply changes the power applied to the motors and supersedes the previous request.

    Setting a value of zero for both wheels means that the robot should stop. Be aware, however, that some robots might "coast" for a little while before stopping after driving at high speed. By applying equal power to both wheels but with opposite signs a two-wheeled robot can be made to rotate on the spot.

    There might not be a direct relationship between the power settings and the speed of the robot, i.e it is not required to be linear. The only requirement is that larger (absolute) values should make the motors run faster. There might be some point less than 1.0 where the motors reach their maximum running speed. Some robots might only support a discrete set of power levels, and it is even possible for the motors to only have two levels: off (stopped) or on (running).

    Due to the characteristics of real motors it is possible that small values of power, e.g. 0.1, might not be sufficient for the robot to move. Conversely, using a value of 1.0 might result in the robot moving very fast. You should establish the behavior of your particular robot in response to power settings during initial testing.

    For robots that do not have a two-wheel drive, these power settings can be interpreted to mean the left-side power and the right-side power for whatever the method of locomotion might be.

    Please try the above to modify your calculation values if they work. Please do reply if there is any problem.

    Thanks

    Rehan

    • Proposed as answer by REHAN BHARUCHA Thursday, December 22, 2011 4:13 PM
    • Unproposed as answer by REHAN BHARUCHA Sunday, December 25, 2011 6:14 AM
    • Proposed as answer by REHAN BHARUCHA Monday, January 2, 2012 8:34 AM
    • Unproposed as answer by REHAN BHARUCHA Monday, January 2, 2012 8:34 AM
    • Proposed as answer by REHAN BHARUCHA Monday, January 2, 2012 8:35 AM
    Thursday, December 22, 2011 4:13 PM
  • Like I said before I don't think the problem is drive power. The Desktop Joystick is attached to and IF block with a notification "wire" that is set to UpdateAxes. The IF block says Y < 0 (which doesn't have an error message) and then is attached to a NXT drive through a SetDrivePower wire. Currently I have the power set at .95 and have tried 1.0, .5, and other powers and no luck. Also note that the X Axis is set at .25 and .75 in the same manner, but doesn't seem to have a problem during my tests. My guess, (which is nothing more than a guess) is that the problem is somewhere in the software of the Deskto p Joystick, but that could also be completely wrong. If this helps I also have an IF block that says Y = 0 and X = 0, which does make the robot stop.
    Thursday, December 22, 2011 8:58 PM
  • Hello Sir,

    You might be right but now its a matter of a few experiments as to why is it not working.

    Just try Desktop Joy Stick (User) service if not tried and see the response and get back to me...


    Thanks

    Rehan Bharucha - The Tech Robot

    MCTS, MCITP, MCPD, MCT

    Sunday, December 25, 2011 6:13 AM
  • Okay, so I have been experimenting with differnent areas of program, mostly with the connection from the IF block to the Drive block. Every time I try it it either just twitches or, in the case of using and EnableDrive wire, doesn't do anything at all. The wierd thing is, is that the X axis works fine, and I made the X axis commands first and then modeled the Y axis exactly like the X axis except for the drive power. I've also seen forums where people have made pograms that are to complicated or messy for the computer and/or the robot to execute properly. After reading those I went back and made it so it only uses one drive activity and one desktop joystick activity, and because of that I've ruled out the chance that I'm overloading it.
    Thursday, December 29, 2011 7:29 PM
  • Hi

    I would suggest to just keep whittling it down -- write the smallest repro that you can, even isolate the joystick functionality from the motor.  For example, can you turn on a light with the joystick Y axix?  Likely you'll have an aha moment!  Did you try another motor?  Good luck!

     

    Saturday, December 31, 2011 12:30 AM
  • Thank You. I will try everything I can to fix it with your suggestions. I appreciate everyone who has responded to try and help me. I will reply if I have any break throughs. In the mean time, if someone thinks of something please post it. I am new to MRDS and may have made a stupid mistake that I overlooked. 
    Sunday, January 1, 2012 3:26 PM
  • NightBot,

    I took your advice and was succesful in making the Y axis make my computer make a sound rather than have it make the robot drive. I also swithed the x and y axis in the IF blocks, e.i. The x axis controlled the forward/backward motion and the y axis did the right/left. Again, only the x axis was successful which means it's something in the desktop joystick or my robot.


    • Edited by R Gregg S Sunday, January 1, 2012 5:50 PM
    Sunday, January 1, 2012 5:45 PM
  • This might be way off the mark, but I am just wondered if you are doing a calculation like X / 1000 in a Calculate block? This will result in 0 unless X is exactly 1000 (fully pushed to the right) when it will be 1 because VPL does integer arithmetic in this case. You can however write X / 1000.0 and this will result in a floating point value, which is what you want, i.e. a value that ranges from -1.0 to +1.0.

    By the way, I have played around with the Desktop Joystick in response to your question and I can get the full range of values out of both X any Y axes. I have not tried driving a LEGO NXT though because I do not have one readily at hand.

    Trevor

     

    Monday, January 2, 2012 12:05 AM
  • Actually, no I wasn't using a calculate box, so I tried using one. It didn't work, but for some reason when I run the program now the forward and backwards motion twitches a little harder and for longer. It did end up moving forward for about three quarters of a second. I'm not sure what I did though. And I can get it to drive forward when it's twitching by also moving pressing a or d (left and right motion). It seems to activate the motors or something.

    • Edited by R Gregg S Tuesday, January 3, 2012 9:12 PM
    Monday, January 2, 2012 4:11 PM