View Single Post
  #1   Spotlight this post!  
Unread 15-01-2005, 17:16
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Steering wheel problems

I'm working on controlling our robot with a steering wheel on port 1, and a throttle on port 2. I have the following definitions at the top of user_routines.c:
Code:
#define WHEEL p1_x-127				//Steering wheel on port 1
#define THROTTLE p2_y-127			//Throttle joystick on port 2
#define PIVOT_DISABLE p2_sw_trig	//Trigger button on port 2, disables in-place rotation
#define DEAD 7						//Dead zone where joystick input is ignored
#define LEFT pwm15					//Left drive motor
#define RIGHT pwm16					//Right drive motor
I also have these nifty functions:
Code:
int isActive(int x)
{
  if(abs(x)>DEAD)
    return 1;
  else
    return 0;
}

double turnRatio(void)
{
  return 1-abs(WHEEL)/127.1;
}
Then, in the driving routine, I have this code:
Code:
LEFT=0;
RIGHT=0;
if(!isActive(THROTTLE))
{
  if(isActive(WHEEL)&&!PIVOT_DISABLE)
  {
    LEFT=WHEEL;
    RIGHT=0-WHEEL-1;
  }
}
else
{
  LEFT=THROTTLE;
  RIGHT=THROTTLE;
  if(WHEEL>DEAD)
  {
    RIGHT*=turnRatio();
  }
  else if(WHEEL<-DEAD)
  {
    LEFT*=turnRatio();
  }
}
if((THROTTLE<-DEAD)&&(WHEEL<-DEAD))
  LEFT-=254*turnRatio();
if((THROTTLE<-DEAD)&&(WHEEL>DEAD))
  RIGHT-=254*turnRatio();
LEFT+=127;
RIGHT+=127;
I have tested this code in RobotEmu2 countless times, and it acts as intended (pivot when wheel is engaged without throttle, go straight with throttle but no wheel, arc with both), but when I actually hook up the equipment to the OI and RC, pwm15 and pwm16 show seemingly random values in Dashboard. I don't think that it's a problem with the actual controllers, because the actual values of p1_x and p2_y are as expected. I can't figure out why there's a discrepancy in operation between the emulator and the actual RC, and it's driving me nuts. Anything to help me figure out why this is happening would be appreciated.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_

Last edited by jgannon : 15-01-2005 at 17:24.