View Single Post
  #1   Spotlight this post!  
Unread 12-02-2014, 11:10
mozrila mozrila is offline
Registered User
AKA: Ben
FTC #3415 (Lancer Robotics)
Team Role: CAD
 
Join Date: Apr 2012
Rookie Year: 2008
Location: United States
Posts: 12
mozrila is an unknown quantity at this point
[FTC]: Help with my Omni Code?

This isn't so much for competition as much as it is for personal reference. What am I missing here as it does not work... Am I blind?

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     BackRight,     tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     BackLeft,      tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     FrontRight,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     FrontLeft,     tmotorTetrix, openLoop)

#include "JoystickDriver.c"

// Translates values relative to a joystick to values relative to a motor
int scaleForMotor(int joyVal) {
  // The range of values returned from the joystick that should be interpreted as noise
  const int DEADZONE = 5;

  if (abs(joyVal) < DEADZONE) {
	return 0;
  }
  
  return joyVal; //for now, will scale out of max 256
}


task main() 
{
  while (true) 
  {
  	getJoystickSettings(joystick); 
  	
	  motor[BackRight] = scaleForMotor(-joy1_y2 - joy1_x2);
	  motor[BackLeft] = scaleForMotor(joy1_y1 + joy1_x1);
	  motor[FrontRight] = scaleForMotor(-joy1_y1 + joy1_x1);
	  motor[FrontLeft] = scaleForMotor(joy1_y2 - joy1_x2);


  }
}
Reply With Quote