![]() |
control all driving with one joystick
does anyone know how to program the robot to drive with one joystick
|
Re: control all driving with one joystick
Depends, what program are you using? if your using easyC just change the programming from tank to arcade
|
Re: control all driving with one joystick
It would also depend on your drivebase. Are you using:
4wd 6wd Tank Tread Ackermann 4 wheel 90 offset Omni 3 wheel 120 offset Omni (Kiwi) Swerve/Crab (4 rotateable pods) Mecanum 1565-esque Linkage Drive etc |
Re: control all driving with one joystick
Quote:
|
Re: control all driving with one joystick
kevin's code has a limit_mix function by default, so i'd think that you could just use that ... just assign your drive motor pwm's to the value returned by limit_mix
|
Re: control all driving with one joystick
Quote:
|
Re: control all driving with one joystick
What are you using to program your robot? easyC, the default code, WPILib...?
This year we experimented with two different drive modes: arcade mode and RC-Car style drive (two joysticks, one for forward/backward and one for steering). If you're using WPILib or easyC, arcade mode for 2 wheel drive is fairly easy to do. I don't have experience with easyC, but with WPILib/MPLab, you need to call Arcade2() function in your OperatorControl(). Unfortunately, I appear to have lost the code that I used for it, but check the docs (page 41) for more information. Basically, you just need to pass Arcade2 the joystick port you're using (PORT_1, PORT_2, etc), the axis of the joystick (X_AXIS, Y_AXIS), the PWM ports that your victors are plugged into (1, 2, etc), and if either your left or right motor is inverted (1=inverted, 0=not, I think). If you're not using WPILib, you can still do the mixing of the joysticks manually and achieve the same result. This is what we ended up doing because we wanted more control over how sensitive the joysticks were (and so we could use a gyro to keep our bot driving in a straight line). Our final code worked something like this:
This is what our code that processes joystick values into motor values sort of looks like: Code:
/* OurDriveGood luck! If you have any other questions, please ask! - Taj |
Re: control all driving with one joystick
Quote:
And for the record we only use one joystick, only ever have used one joystick I think we use blend functions to drive it with one joystick. Drive foreward: all wheels turn foreward Drive backward: all wheels turn backwards Turn left: left wheels turn back, right wheels turn foreward Turn right: left wheels turn forward, right wheels turn back Those are the extremes, and then we set up a blend function (not sure if it something we made or not though) to blend the extremes together for any other joystick position. For the record, I am not the programmer, that all I know about, and I have heard the term blend function so many times from them while they work on the drive program, so it must be important!! best of luck!! |
Re: control all driving with one joystick
Quote:
EX. pwm01=pwm02=p1_y; //right wheels forward with the joystick pwm03=pwm04=flip(p1_y); //flip() simply makes 255 into 0, and so on pwm01=pwm03=blend(pwm01,p1_x); //add p1_x to what pwm01 is already doing pwm03=pwm04=blend(pwm03,flip(p1_x)); //same with other side. of course, this is very simple. when you realize that the KOP joysitcks arent the bast things to use and have a lot of error, you'll want to make a function that returns if it's around a certain value, say, 127 perhaps? good luck! |
Re: control all driving with one joystick
Quote:
|
Re: control all driving with one joystick
Quote:
|
| All times are GMT -5. The time now is 00:57. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi