View Full Version : Dual Joystick Code
1086Programmer
09-04-2005, 19:05
My team is considering doing dual joysticks next year. I've been searching for anything on them, and I'm coming up dry. If anyone uses dual joysticks, and happens to have an old code, I'd really appreciate looking at it.
My coach wants me to get a headstart for next year and RoSi. ^_^
thoughtful
09-04-2005, 19:10
well, dual joystick is very simple, there is no fancy code.
You should have searched there are many examples.
basically u need this in your user_routines.c
pwm13=p1_y;
pwm14=p2_y;
//Where pwm13 is the motor controlling one side of the robot and pwm14 is controlling the other.
1086Programmer
09-04-2005, 19:23
Really? That simple? Makes sense. Thanks.
I did search a bit, prolly not in the right places. ^^;
Alan Anderson
10-04-2005, 09:42
Direct mapping of joystick to motor is the easiest and most intuitive way to use two joysticks to control two motors. This year's TechnoKat robot does it the long way around, though, taking the average of the two sticks to control an internal "velocity" value, with the sticks' difference becoming a "turn" value. It essentially computes the equivalent of a single joystick. The output code remixes the velocity and turn values into two motor control numbers.
This complexity has its rewards. It makes navigating under autonomous control a wee bit simpler to implement, and it provides a straightforward way to implement speed-sensitive steering if desired. There are deadbands applied to the computed values, so it also theoretically makes driving straight at high speed slightly easier.
Actually, if you take a look at the default code, dual driving joysticks are already in there. PWM01 is assigned the y value from Joystick 1 and PWM02 is assigned the y value from Joystick 2.
Tom Bottiglieri
10-04-2005, 13:37
Direct mapping of joystick to motor is the easiest and most intuitive way to use two joysticks to control two motors. This year's TechnoKat robot does it the long way around, though, taking the average of the two sticks to control an internal "velocity" value, with the sticks' difference becoming a "turn" value. It essentially computes the equivalent of a single joystick. The output code remixes the velocity and turn values into two motor control numbers.
This complexity has its rewards. It makes navigating under autonomous control a wee bit simpler to implement, and it provides a straightforward way to implement speed-sensitive steering if desired. There are deadbands applied to the computed values, so it also theoretically makes driving straight at high speed slightly easier.
Would you share this code with us?
1086Programmer
10-04-2005, 13:56
I see. I'm not quite sure that we're using the second joystick for though, whether it's driving or operating our pneumatics. That part they neglected to tell me, would it matter?
thoughtful
10-04-2005, 14:33
I see. I'm not quite sure that we're using the second joystick for though, whether it's driving or operating our pneumatics. That part they neglected to tell me, would it matter?
It will :o , because everyone on this thread was under impression that you wanted two joysticks for driving the robot, as opposed to a single joystick for driving. If you just need another joystick for an arm here is what you need.
1. Make sure wether the arm is pneumatic, or motor.
2. If its motor, is it controlled by a victor or a spike.
If the arm is pneumatic or motor on a spike then:
relay1_fwd=p3_aux1;
relay1_rev=p3_aux2;
//here the single solenoid or the motor is on relay one.
If arm is on a motor contorlled by a victor then:
pwm03=p3_y;
// All the code is assuming that the joystick used is on port3.
1086Programmer
10-04-2005, 16:31
Okay. ^^;; Sorry for the confusion. I didn't know what I was looking for, my team coach didn't specify what he wanted.
Direct mapping of joystick to motor is the easiest and most intuitive way to use two joysticks to control two motors. This year's TechnoKat robot does it the long way around, though, taking the average of the two sticks to control an internal "velocity" value, with the sticks' difference becoming a "turn" value. It essentially computes the equivalent of a single joystick. The output code remixes the velocity and turn values into two motor control numbers.
Why not just use one joystick at that point?
I personally like how with 2 joystick drive, you know how the bot will turn (with a bit of practice). How does your modified two-joystick really offer any advantage over two-joystick (other than the easier straight values)
As for the autonomous mode, you're not reading the pwms...so how does this make a difference in the end? (compared to using the standard one-joystick drive code)
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.