View unanswered posts | View active topics It is currently Fri Jan 20, 2017 10:22 pm

Reply to topic  [ 2 posts ] 
Single Joystick Problem 
Author Message

Joined: Tue Dec 14, 2010 4:50 pm
Posts: 3
Post 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 :)

Tue Dec 14, 2010 4:58 pm
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 409
Post 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!

Jesse Flot
CMU Robotics Academy
ROBOTC Support

Wed Dec 15, 2010 12:42 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.