Single Joystick Problem
Page 1 of 1

Author:  D1581A [ Tue Dec 14, 2010 4:58 pm ]
Post subject:  Single Joystick Problem

So we are basing our user control code off of the single joystick sample program supplied with robotc for our VeX cortex robot. However, we have modified it so that it runs off of two joysticks: (similar to an xbox controller) with steering on the right joystick, and moving forwards/backwards on the left joystick.

Our issue is that with our current code, the right joystick (steering) is reversed. For instance when you push the stick to the right, the robot will turn left and vice-versa. I'm hoping that it's just a simple program fix, and i'm thanking you in advance for your answers.

Supplied below is our user code as it is now.
#pragma config(Sensor, dgtl1,  rightencoder,        sensorQuadEncoder)
#pragma config(Sensor, dgtl3,  leftencoder,         sensorQuadEncoder)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port4,           rightarmMotor, tmotorNormal, openLoop)
#pragma config(Motor,  port5,           leftarmMotor,  tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port6,           rightclampMotor, tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port7,           leftclampMotor, tmotorNormal, openLoop)
#pragma platform(VEX)

task main()
   while (true)
    //Wheel Motors
    motor[leftMotor] = (vexRT[Ch3] + vexRT[Ch1]);      //y-axis value: forward/backward motion
      motor[rightMotor] = (vexRT[Ch3] - vexRT[Ch1]);      //x-axis value: left/right steering
      //Arm Motors
      motor[leftarmMotor] = -vexRT[Ch3Xmtr2];
      motor[rightarmMotor] = -vexRT[Ch3Xmtr2];
      //Clamp Joystick
      motor[leftclampMotor] = -vexRT[Ch2Xmtr2];
      motor[rightclampMotor] = -vexRT[Ch2Xmtr2];
      //Clamp Joystick-

Thanks again :)

Author:  jbflot [ Wed Dec 15, 2010 12:42 pm ]
Post subject:  Re: Single Joystick Problem

Have you considered multiplying the entire value for the steering by -1, to reverse the motor powers? For example, you could change:

 motor[rightMotor] = (vexRT[Ch3] - vexRT[Ch1]);      //x-axis value: left/right steering


 motor[rightMotor] = (vexRT[Ch3] - vexRT[Ch1])*-1;      //x-axis value: left/right steering

Hope that helps!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group