Want to add Extra button to drive controls (while using tank drive)

So our team is having difficulty driving completely straight at 100% power because we use tank drive. To control our bot we use an Xbox controller - Left 2 motors (y-splitter) connected to pwm 0, controlled by left stick - Right 2 motors (y-splitter) connected to pwm 1, controlled by by right stick.

We want to add a boolean function to a button that makes both drive trains move together at 100% speed. I was able to just create the function for the button separately from the rest of the drive train code, but they were trying to override each other.

I understand why that is happening, but I’m not quite sure what logic to use to connect them such that - when the button is not pressed, the drive train refers to the 2-stick axes, and also vice-versa.

Have the two settings wires from the joysticks pass through a Case statement decided by the button press.
False case just passes through the joystick values from one side of the Case to the other.
True case outputs a constant 1.0
Then out the other side of the case feed the inputs into a single Drive Set.

Don’t ever have two different Drive Sets active.

1 Like

As an alternative, if you have triggers on your controller (such as on an Xbox or Logitech F310), you can use those to drive straight at variable speed. I’m both programmer and driver, and I have the controller set so that the right trigger drives straight forward and the left trigger drives straight backwards.
Be sure to figure out which controls have priority over others - if you don’t, you’ll end up setting the motor’s speed multiple times in the same iteration, causing your robot to jitter around.
I have an example here if needed. (Lines 55-68 also includes a P controller for angle using the NavX - you can ignore this, it should work just fine without it)

This is the LabVIEW forum not Java.
The trigger idea is good, but the implementation doesn’t apply.

So just note that running all the motor at 100% power doesn’t guarantee the robot driving straight…

This sounds like a perfect way to resolve our problem, and I know what you mean, but I’m not exactly sure how to set it up. Do you possibly have a screenshot of an example you could send? Thanks again for the help Mark.

As @Low3arth0rbit mentioned, driving two sides at the same % doesn’t mean the robot will necessarily go straight.

When I drove tank-drive-style in 2017 and 2018, I had it set up so that holding the “A” button would cause the left joystick to control the speed of both sides simultaneously.

In normal operation I would move both sticks to move both sides independently. If I wanted to drive straight, I’d press the A button with my right thumb and control the robot speed (forward or backward) with the left stick only.

The % was corrected with experimental testing so that the robot would drive straight. For example last year the right side needed to be 98% of the left side for it to drive straight.

Just a thought. I liked the ability to drive in a straight line not only at full speed, but at any arbitrary speed. It was fairly intuitive once you get the hang of it.

I can send one tomorrow. We’re traveling to an event today.

This sounds exactly like what our team is looking for - did you do this in Labview? Do you have that code still and are you willing to share it?

I just need the specific part to call two different drive functions. I’m not too familiar with case structure.

I can try and dig up our code from 2017 which was LabVIEW. Otherwise I can try and sketch it out, don’t have LabVIEW installed on my laptop.

edit: give me 10 mins I will sketch it out. it’ll be a really rough sketch that assumes you already have regular tank drive working

Here is what you originally asked for.
Drive%20Full%20Power

Here is the percent reduction of a side. I would personally recommending figuring out which side is “stronger” and reduce it assuming that it applies linerally. For example if you are turning to the left than your right is “stronger” so if you make your right go at 97% power you will drive straight.
Percent%20Reduction%20on%20a%20Side

2 Likes

Ok so your main drive logic would be like this:

So when the button is not pressed (case statement in 0 mode) it would pass through the stick values to the left and right sides of the drivetrain. When the button is pressed (case statement in 1 mode) it should pass the left stick through to both sides of the drivetrain.

Hopefully someone posts LabVIEW snippets, my apologies for not having LabVIEW

1 Like

@jdaming has exactly what I was talking about! check out his snippets

1 Like

You guys rock! Thank you!