Having trouble codeing my teams robot for VEX. The arms and gripping device are not following command to the Duel joystick controller. They continue to move even after the buttons are released . If anyone can help me PLEASE HELP

Mon Nov 07, 2011 2:06 pm

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

Re: Robot Trouble

The more detail that you give, the more help that you will get. What exactly do you want the robot to do? What have you already tried? Post the code that you have tried so we can see if that is the source of the problem.

_________________sudo rm -rf /

Mon Nov 07, 2011 2:29 pm

Mr.Roboto3335

Rookie

Joined: Mon Nov 07, 2011 2:01 pmPosts: 5

Re: Robot Trouble

i want to make it to where if you release the button it stops and if you press the button it goes

while (true) {{ int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0) // feel free to change this to match your needs.

while(1 == 1) { if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold: { motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2. } else // If the left joystick is within the threshold: { motor[leftMotor] = 0; // Stop the left motor (cancel noise) }

if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:

Fist of all, lets put your code into properly spaced formatting so that it's easier to see what is in the scope of what:

Code:

while (true){ { int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0) // feel free to change this to match your needs.

while(1 == 1) { if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold: { motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2. } else // If the left joystick is within the threshold: { motor[leftMotor] = 0; // Stop the left motor (cancel noise) }

if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:

The reason that your motors do not stop when you release the button, is because you never tell your motors to stop. The motors will keep doing what you told them to do last until you tell them otherwise. You have to explicitly set them to 0 when the button is released. Also, you may want to look into why you have two while loops.Just as a side note, after looking at this code, I have to wonder if more than one person worked on this, as you have different coding customs in the same piece of code. Not that there is anything wrong with that, but it might be easier to understand if everything in a single program is formatted the same way.

_________________sudo rm -rf /

Mon Nov 07, 2011 5:47 pm

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

Re: Robot Trouble

Fist of all, lets put your code into properly spaced formatting so that it's easier to see what is in the scope of what:

Code:

while (true){ { int threshold = 10; // helps to eliminate 'noise' from a joystick that isn't perfectly at (0,0) // feel free to change this to match your needs.

while(1 == 1) { if(abs(vexRT[Ch3]) > threshold) // If the left joystick is greater than or less than the threshold: { motor[leftMotor] = (vexRT[Ch3]); // Left Joystick Y value / 2. } else // If the left joystick is within the threshold: { motor[leftMotor] = 0; // Stop the left motor (cancel noise) }

if(abs(vexRT[Ch2]) > threshold) // If the right joystick is greater than or less than the threshold:

The reason that your motors do not stop when you release the button, is because you never tell your motors to stop. The motors will keep doing what you told them to do last until you tell them otherwise. You have to explicitly set them to 0 when the button is released. Also, you may want to look into why you have two while loops.Just as a side note, after looking at this code, I have to wonder if more than one person worked on this, as you have different coding customs in the same piece of code. Not that there is anything wrong with that, but it might be easier to understand if everything in a single program is formatted the same way.

_________________sudo rm -rf /

Mon Nov 07, 2011 5:47 pm

Mr.Roboto3335

Rookie

Joined: Mon Nov 07, 2011 2:01 pmPosts: 5

Re: Robot Trouble

More than one person worked on this and thank you for helping

Mon Nov 07, 2011 5:52 pm

Mr.Roboto3335

Rookie

Joined: Mon Nov 07, 2011 2:01 pmPosts: 5

Re: Robot Trouble

would it be too much to ask someone to edit my code to make buttons 5U and 5D and 6U and 6D stop when buttons not being pressed. we don't have any programmers on our team.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum