this is my code. i know it looks confusing the first joystick on usb 1 controls the two motors on the left side of the robot. the joystick on usb 2 controlls the two motors on the right side. the third joystick controls our manipulator. with the victorl only controls one motor on pwm 5, pwm 6 is a ghost so it will work. i have tried other programs and they do nto seem to work the way i want them to. i know that it is confusing but how do i program that in autonomous mode. i already looked at the tip jar and that did not help. i do not need to put the manipulater in there i just need to get control of all 4 motors at once. i know that i will probally not be ably to test it but i need to get it done. please help
Basic Robot Main.vi (90.4 KB)
Basic Robot Main.vi (90.4 KB)
I would be simpler to use 4 motor tank drive, then your autonomous mode is also much simpler. Making three duplicates of the original drive function isn’t the right way to go.
For just the top Drive section:
-
Right click on the top “Drive Open 2 Motor” and choose: Replace -> RobotDrive Pallet -> Open 4 Motor
You’ll then need to add constants for the extra PWMs for your motors, but make sure to read which motor each connection is supposed to be. -
Right click on “Drive Arcade Drive” and choose: Replace -> RobotDrive Pallet -> TankDrive
-
Take the output of your second joystick on USB 2 and connect it to the Tank Drive “Right Axis value”
-
Remove the second “Drive Open 2 Motor” and the second Arcade Drive icon.
-
Switch “TeleOp Execute” to “TeleOp Reset” and also replace the Arcade Drive there with Tank Drive.
That’s all you need to have 4 motors controlled by Joysticks 1 & 2 in tank-style drive.
The attached sample of this is a direct modification of your code.
This makes Autonomous pretty simple, because you can use what’s already there
In Autonomous Independent.vi replace each of the three Arcade Drive icons with TankDrive:
-
Right click on “Drive Arcade Drive” and choose: Replace -> RobotDrive Pallet -> TankDrive
Add a second constant (use -0.5 for the fist one and 0.5 for the second one) to each of the TankDrive Left axis inputs. -
Toggle the True/False switch on the left to True, so that the autonomous is allowed to run.
P.S. I’ve attached a picture of what the autonomous would look like when you’re done.
that is awesome but will it still give me the same control with the right pwm’s like i already have it set up…?
Also, how do you check what version your driver station is and your crio i do not have the crio with me but i would like to know so when i do get to the competition i can easily check
one more thing sorry if it is much of a trouble but i am a buy that like pictures. can you get me a pic of the autonomous code
The Driver Station version is desplayed at the bottom of the LCD screen.
The cRIO version can be checked using the FRC Diagnostic Tool at: http://thinktank.wpi.edu/resources/269/FRCDiagnosticWindow_ver2.zip
When you start that up though, the version information is off the screen to the right.
This will give you the same control that you already have.
As with all code changes though, put the robot up on blocks until you’ve tested it. It’s too easy to reverse the PWMs by accident, or have the motors or wiring inverted.
Part of the problem with doing it the way you have is that RobotDriveDefRef is messed up so that autonomous wouldn’t work.
Even your manipulator drive should at least have the RobotDriveDefRef taken off of it.
I’ve attached to the original post what the Autonomous described would look like.
A better way to handle your manipulator is to learn how to use a single motor.
In your case for example:
-
Go to the Pallet WPI Robotics Library -> RobotDrive ->Advanced -> Motor Control
-
Use Motor Open, Set Speed, and Close
Here’s a picture of what that would look like:
thank you but can i have a pic of the autonomous mode
You have one.
okay i am just hopping that you guys are right and that this will drive just like when i had it before
also can you explain autonomous mode a little better like how do i make i go further or longer
sorry for all the questions but on the motor control for my manipulator shouldn’t i have a joystick close…?
The sample autonomous code sets the motor speeds to some value, then waits while they run at that speed, then changes the speed, then waits, …
I think what you are asking is how to get the robot to drive further or longer. They are related. Distance is velocity x time. The joystick input to the drive block is pretty much velocity of your wheels. So one approach would be to make all the motor commands go faster – you may want to think about that one this year. Another approach is to leave the motors running for longer. That would be the same as sending a larger number to the wait block.
Finally, if some part of your path that you map out is cyclical, you may want to use a loop to repeat a pattern until auto is up.
Now it is your turn to take these simple things and come up with your own autonomous path program.
Greg McKaskle
no what i mean is what do each of the constants mean how do i make all 4 of my motors go at once. all i want if 4 it to drive forward for a while
Are you talking about your drive motors? The Tank Drive VI controls all of the motors that were defined to the Four Motor Drive Open VI.
okay i am talking about autonomous mode how do i make it go further and what are the constantace for.
Using the image I posted earlier and starting from the left:
(4) – runs what’s inside the loop box four times. You use this to repeat the same actions over and over again.
(-0.5) into Tank Drive – runs the motors forward at half speed (-1.0 would be full speed and 0.0 is stopped)
(1) into Delay & FEED – Keeps the tank drive settings it just made going for 1 second
(0.5) into Tank Drive – runs the motors backward at half speed (1.0 would be full speed)
(0.25) into Delay & FEED – keeps the tank drive settings it just made going for .25 seconds
(0) into the final Tank Drive – stopps the motors as the last thing done in autonomous
So what this code does is to:
– drive forward for 1 sec.
– drive backwards for 1/4 sec.
– repeat these two drive commands four times
– then stop
To go further you can increase the amount of time into the Delay & FEED’s.
then how do i change that to drive a head at have speed for 20 seconds forward
Change the (4) to (1) - so you do this only once
Remove the second Tank Drive and second Delay & FEED
Change the (1) input into the first Delay & FEED to (20)
Yes, you’re right. It does need a joystick Close too.
The last programmer I showed this to didn’t remember that the PWM order feeding the Open 4 Motor vi mattered. No promises, but if you have trouble just ask at your Regional for a LabVIEW programmer to take a look.
Looks good.
P.S.
Change Arcade Drive to Tank Drive in “TeleOp Reset” too.