FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Programming Help

We are trying to program our robot and are wanting to program an xbox controller.  We want to use the joysticks to drive the robot.  Want to use the left and right trigger to use a motor system to pull the crate in and push it out.  Then we would like to use the bumper buttons to lift our box up and down.  We have not been able to figure that out though.  Any help would be greatly appreciated. 

 

Team 3292 

0 Kudos
Message 1 of 5
(3,247 Views)

That's a lot to walk through with a forum post.

 

You've got another couple hours of support open for tonight.  Otherwise, Monday-Friday 1-7PM Central time you can use support. 866-511-6285

 

Generally, you'll want to use the USB Tab in the Driver Station to determine what inputs you're using.

Then, you'll want to open up motors in being, access those motors using a reference in teleop, feed values from your controller into the motors, and close out the references in finish.

 

Try giving the support team a call and let them guide you through setting up a single motor.  Once you've got that, you should be able to try out the rest.

0 Kudos
Message 2 of 5
(3,245 Views)

So is the problem you don't know what buttons to use to make the actions happen or something else?

 

If you plug in your controller and then open the driver station then click on the USB symbol.

That tab will show you your controller information and as you press buttons and move axes the bars and indicators will change. The numbers next to the axis you want to use will be the number you use to index the Axes array in the code. the buttons don't have number so you start from the top and count down with the first one being zero.

 

another issue could be that your controller is being put in USB slot 1 and the code is only looking at slot 0

2018-01-31_16-56-22.png

in the image above you see that slot 1 is underlined, that mean that when I plug that controller in to the Driver station is will always go to slot 1 to add or remove the underline double click on the Controller text.

 

Hope this helps

Champion CLA

Making senseless computers do
intelligent real world things
is NOT easy. SO MAKE IT FUN!
0 Kudos
Message 3 of 5
(3,236 Views)

Ok.  I think we might have had a break through.  I know it is a lot to look at, but any thoughts are greatly appreciated!

0 Kudos
Message 4 of 5
(3,215 Views)

First, does it work?  If so, great!  That's a strong first step.  Getting functional code and understanding why it works is a great foundation.

 

If you're asking for thoughts looking for ways to clean up the code, here are some things to consider:

There are a lot of wires under other objects/wires.  This makes the code harder to read.  One example is the boolean coming out of the top of the lower Index Array.

Multiply by -1 is "Negate"

With the value being fed into left and right motors being the same, you can accomplish this by opening a reference to 2 motors in Begin and they can share that reference.  That reduces the things you need to bring out on the block diagram

The XOR is redundant logic.  If neither button is pressed, both Selects output 0 and the sum is 0.  If both are pressed, the outputs are 1 and -1 and the sum is 0.  If only one button is pressed, the sum is whichever polarity matches the button pressed.

If you're curious in seeing the Arm and Lift motor values in the Dashboard, adding the NT Write to send those values to the dashboard.

 

 

Those are all things that can clean it up.  But, the real beauty is here looking at a joystick, understanding how to map to the controls on it, and putting those into your code to get a robot moving.  That's an amazing thing to put together.  Congrats on getting your robot moving!

0 Kudos
Message 5 of 5
(3,213 Views)