FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Coding

Hi,

I have questions about 3/4 different codes and error message problems.

Arm Coding.jpg

          FIGURE 1- Coding for the Robot Arm

3. My question about the coding in FIGURE 1 is that for USB 3 and PWM 7, is that the correct way to make a motor run off of a button? And would that be through a spike?

Holomonic Drive Coding.jpg

          FIGURE 2- Holomonic Drive System Coding

2. How should the FIGURE 2 coding be set up to make the robot move directly left and right, forward and backward, and cause the robot to rotate while using omni wheels?

My 3rd and 4th problems are about servos.

3. I am still having difficulty causing a servo to move using joystick movement.  Also depending on how I set up the rotation for the drive system, I would like to set the servos up to so that pressing one button makes one of the servers move one direction and pressing the opposing button makes the same servo move the other direction (i.e. I press the left button on the top of the joystick so the horizontal servo will aim the camera left and when i press the right button that servo will aim the camera right and similar for the verticle servo).

4. Would there be a way so that when i press the center button the camera will allign forward and level (or some other starting configuration)?

Thanks for all the help given so far, just so close now

Thanks,

Davis Catherman

0 Kudos
Message 1 of 20
(17,319 Views)

43803490 wrote:


3. My question about the coding in FIGURE 1 is that for USB 3 and PWM 7, is that the correct way to make a motor run off of a button? And would that be through a spike?


That will run the motor forward when you press the button and will have the motor off when the button is not pressed. Is that what you want? Your program uses a victor speed controller. If you want it to use a spike, use the code for a relay.

43803490 wrote:

2. How should the FIGURE 2 coding be set up to make the robot move directly left and right, forward and backward, and cause the robot to rotate while using omni wheels?

Since you have three different motions, you'll need to have three different joystick axises. Most teams either use 2 different joysticks, or buy a joystick that has 3 or more axises built in.

43803490 wrote:


My 3rd and 4th problems are about servos.

3. I am still having difficulty causing a servo to move using joystick movement.  Also depending on how I set up the rotation for the drive system, I would like to set the servos up to so that pressing one button makes one of the servers move one direction and pressing the opposing button makes the same servo move the other direction (i.e. I press the left button on the top of the joystick so the horizontal servo will aim the camera left and when i press the right button that servo will aim the camera right and similar for the verticle servo).

4. Would there be a way so that when i press the center button the camera will allign forward and level (or some other starting configuration)?

Thanks for all the help given so far, just so close now

Thanks,

Davis Catherman

Servos move to a position, so you just need to convert the joystick commands to the position that you want it go to. It also makes it easy to make the servo go to a position when you press a button.

0 Kudos
Message 2 of 20
(5,108 Views)

Thanks,

About the button motor control, I didn't think that would do it for the Victor Speed Controller but that will actually work better than what i expected. But how would I make it so that I can press a button to run the motor forward, and a different button to run backwards?

About the Drive System coding, is the code in the picture below suitable for 2 joysticks (one for forward/backward and left/right and a second joystick for rotation?

And if i wanted set up a joystick that has a 3rd axis (Z), would I add another "get axis" on the same joystick as the others are on and select Axis 3 and connect to rotation?

About the servo coding, this is where I have always encountered problems, How would the coding be set up to cause the servo to that position? Also if I use the 3rd axis on the drive system joystick, I could use the freed joystick space for the servos (if that is possible), and how would that be set up?

    Holomonic Drive Coding Fixed.jpg

                         Holomonic Drive System Coding 2 Joysticks

these are the problems I have mostly encounted thrrough the years of coding. (This will be a big help)

Thanks,

Davis Catherman

0 Kudos
Message 3 of 20
(5,108 Views)

Hi,

I fixed the arm coding shown below.

Arm Coding Fixed.png

This runs PWM 7 off of a Victor using buttons.  It depicts the buttons, then converts it, then button 2 is negated (so they run different directions) then go into an "or" statement then go to the motor. Works Great!

I updated it but my Omni Drive System code still NEEDS HELP.

It uses 4 omni wheels on each side of the robot, making it multidirectional.  The setup and code are in pictures below, and the labview coding file is attached.

How do I make this work?

Omni wheel depiction.png

Holomonic Drive Coding Fixed #2.png

thanks,

Davis Catherman

0 Kudos
Message 4 of 20
(5,108 Views)

43803490 wrote:

I updated it but my Omni Drive System code still NEEDS HELP.

It uses 4 omni wheels on each side of the robot, making it multidirectional.  The setup and code are in pictures below, and the labview coding file is attached.

How do I make this work?

Omni wheel depiction.png

Holomonic Drive Coding Fixed #2.png

thanks,

Davis Catherman

Your code looks good if you had a drive train that matches what the holonomic drive VI expects. The description of holonomic drive says it is for mecanum drive or omni wheels mounted at 45 degree angles to the frame. Your drive arrangement doesn't match either of those, so the holonomic motor drive will not work. With the omniwheels mounted at 45 degrees, to go forward you set all 4 motors forward. With your arrangement, you set 2 motors forward and 2 motors off. You will need to derive an algorithm specific to your drive train. I would recommend using separate motor vis for each motor, rather then trying to use robot drive.

0 Kudos
Message 5 of 20
(5,108 Views)

well,

Do you mean like this?

Holomonic Drive Coding Custom.png

Or each motor to be on a completely different VI?

The new code is also attached.

also can you provide a diagram or picture of the 45 degree mounted system?

Thanks,

Davis Catherman

0 Kudos
Message 6 of 20
(5,108 Views)

In that last code screenshot you posted, why are you setting individual motor values based on the first joystick, then immediately setting all motor values to one axis from the second joystick?  Without that, it might work.

It would be a good idea to put a wait of some sort inside your while loop to allow other processing to occur.  Without one, your loop runs as fast as possible, preventing other functions (such as communication with the driver station) from responding.

0 Kudos
Message 7 of 20
(5,108 Views)

There is a link with a picture in my previous post.

0 Kudos
Message 8 of 20
(5,108 Views)

Hi,

@sciencewhiz

Yea, i understand that system now, I noticed that my teams robot moves diagonally with that coding (makes sense)

Also, the last peice of coding I provided, Is that what you meant?

@nathand

I have it set to the first joystick so that when the first joystick is used, it will moved directly with the robot (forward, backward, left, right).

Then it is set to the second joystick so that when that is used, it will turn the robot (rotate)

(thats the thoery at least, doesnt seem to work)

And yea, I need to add a loop delay.

@all

Is it even possible to set it like that? ( mentioned above, in @nathand )

Thanks,

Davis Catherman

0 Kudos
Message 9 of 20
(5,108 Views)

43803490 wrote:

@nathand

I have it set to the first joystick so that when the first joystick is used, it will moved directly with the robot (forward, backward, left, right).

Then it is set to the second joystick so that when that is used, it will turn the robot (rotate)

(thats the thoery at least, doesnt seem to work)

Won't work.  You set the values from the first joystick, then immediately overwrite them with the value coming from the second joystick, so the first joystick does nothing.  I'm not sure I understand exactly what you're trying to achieve, but you might try taking the output from the second joystick and putting it into "In Range and Coerce."  If I remember correctly the joystick axis value is something like -32000 to +32000, so try setting the limits to +10 to -10.  If the axis is in that range, then it's basically 0 and you should use the values from the first joystick.  If it's outside that range, then someone/something is pushing on the second joystick, and you want to use that value instead.  You can put a case structure around the Set Motor commands, or use a Select to switch between values going to it.

However, I'm not really sure why you'd want to do that, since pushing the first joystick toward one of the corners should have the same effect of driving all four motors at once.

0 Kudos
Message 10 of 20
(5,108 Views)