View unanswered posts | View active topics It is currently Sun Mar 01, 2015 7:53 am






Reply to topic  [ 2 posts ] 
Robotc Does Not Register Ch or Btn for Controller, Error 
Author Message
Rookie

Joined: Tue Dec 30, 2014 4:24 pm
Posts: 2
Post Robotc Does Not Register Ch or Btn for Controller, Error
We are attempting to use the vexRT[] command, which has worked before. However, the program suddenly does not recognize the keywords "Ch1", "Ch2", "Btn8R", "Btn6U", etc. It does recognize "ChA" or "ChD" oddly. The code and errors are pasted below.


Code:
#pragma config(Motor,  motor1,          rightwheels,   tmotorVexIQ, openLoop)
#pragma config(Motor,  motor6,          claw,          tmotorVexIQ, openLoop)
#pragma config(Motor,  motor7,          arm,           tmotorVexIQ, openLoop)
#pragma config(Motor,  motor10,         leftwheels,    tmotorVexIQ, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   //sets speed of motors
   float speed = 1;
   //toggle for claw clamp
   bool toggle = false;
   //thumbstick position
   float x = vexRT[Ch4];
   float y = vexRT[Ch3];
   float rad = sqrt((x*x)+(y*y));
   bool above = false;
   bool right = false;
   float theta = (1/atan(abs(y)/abs(x)));

   while (true)
   {
      //refresh thumbstick values
      x = vexRT[Ch4];
      y = vexRT[Ch3];
      if (y >= 0)
      {
         above = true;
      }
      if (y < 0)
      {
         above = false;
      }
      rad = sqrt((x*x)+(y*y));
      if (x > 0)
      {
         right = true;
      }
      if (x < 0)
      {
         right = false;
      }
      theta = (atan(y/x));

/* -----------------------*/
// Speed system
   if (vexRT[Btn8L] == 1)
   {
      speed = .3;
   }

   if (vexRT[Btn8D] == 1)
   {
      speed = .7;
   }

   if (vexRT[Btn8R] == 1)
   {
      speed = 1;
   }
/* ------ Improved moving ------- */
   //Forward-right (quadrant 1)
if (rad >= 10)
{
   if (right == true && above == true)
   {
      motor[rightwheels] = ((254*(theta - 45))/90);
      motor[leftwheels] = -127;
   }
   //backward-right (quadrant 4)
   if (right == true && above == false)
   {
      motor[rightwheels] = -((254*(theta - 45))/90);
      motor[leftwheels] = -127;
   }
   //forward-left (quadrant 2)
   if (right == false && above == true)
   {
      motor[leftwheels] = ((254*(theta - 45))/90);
      motor[rightwheels] = -127;
   }
   //backward-left (quadrant 3)
   if (right == false && above == false)
   {
      motor[leftwheels] = -((254*(theta - 45))/90);
      motor[rightwheels] = -127;
   }
}
/* ----------------------  Disabled Currently
      // Forward
   if (vexRT[Ch3] > 40)
   {
      motor[rightwheels] = vexRT[Ch3] * speed;
      motor[leftwheels] = -vexRT[Ch3] * speed;
   }
   //Backward
   else if (vexRT[Ch3] < -40)
   {
      motor[rightwheels] = vexRT[Ch3] * speed;
      motor[leftwheels] = -vexRT[Ch3] * speed;
   }
      //right
   else if (vexRT[Ch4] < -15)
   {
      motor[rightwheels] = -vexRT[Ch4] * speed;
      motor[leftwheels] = -vexRT[Ch4] * speed;
   }
   //left
   else if (vexRT[Ch4] > 15)
   {
      motor[rightwheels] = -vexRT[Ch4] * speed;
      motor[leftwheels] = -vexRT[Ch4] * speed;
   }
   //break
   else
   {
      motor[rightwheels] = 0;
      motor[leftwheels] = 0;
   }
 ---------------------------- */
   //arm up
   if (vexRT[Ch2] > 40)
   {
      motor[arm] = vexRT[Ch2] * speed;
   }
   //arm down
   else if (vexRT[Ch2] < -40)
   {
      motor[arm] = vexRT[Ch2] * speed;
   }
      //claw open
   else if (vexRT[Ch1] < -15)
   {
      motor[claw] = vexRT[Ch1] * speed;
   }
   //claw close
   else if (vexRT[Ch1] > 15)
   {
      motor[claw] = vexRT[Ch1] * speed;
   }
   else
   {
      motor[arm] = 0;
      motor[claw] = 0;
   }

/* ------------------------- */
//Claw Hold
   if (vexRT[Btn6U] == 1)
   {
      toggle = true;
   }

   if (vexRT[Btn6D] == 1)
   {
      toggle = false;
      motor[claw] = -63;
      waitInMilliseconds(500);
      motor[claw] = 0;
   }

   if (toggle)
   {
      motor[claw] = 85;
   }

/* ------------------------- */
//Emergency Break
   if (vexRT[Btn8U] == 1)
   {
      speed = 0;
      wait(1);
      speed = 1;
   }
  }
}


Errors
Code:
**Error**:Undefined variable 'Ch4'. 'short' assumed.
**Error**:Undefined variable 'Ch3'. 'short' assumed.
**Error**:Undefined variable 'Btn8L'. 'short' assumed.
**Error**:Undefined variable 'Btn8D'. 'short' assumed.
**Error**:Undefined variable 'Btn8R'. 'short' assumed.
**Error**:Undefined variable 'Ch2'. 'short' assumed.
**Error**:Undefined variable 'Ch1'. 'short' assumed.
**Error**:Undefined variable 'Btn6U'. 'short' assumed.
**Error**:Undefined variable 'Btn6D'. 'short' assumed.
**Error**:Undefined procedure 'waitInMilliseconds'.
**Error**:Undefined variable 'Btn8U'. 'short' assumed.
**Error**:Undefined procedure 'wait'.


Tue Dec 30, 2014 4:38 pm
Profile
Rookie

Joined: Tue Dec 30, 2014 4:24 pm
Posts: 2
Post Re: Robotc Does Not Register Ch or Btn for Controller, Error
This problem has been solved! While going through the menus, we discovered that somehow the platform type had been changed to Vex IQ. We changed it back to VEX 2.0 Cortex (which we thought it was on), and the problem is solved.


Tue Dec 30, 2014 6:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.