Log in

View Full Version : [FTC]: Help with my Omni Code?


mozrila
12-02-2014, 11:10
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?

#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);


}
}

maths222
12-02-2014, 11:15
joystick.joy1_y1 and so on

mozrila
12-02-2014, 12:21
*facepalm*

Thanks a bunch... I am a complete dope for not seeing that...