ROBOTC.net forums
http://robotc.net/forums/

Please help me with my teleop code!
http://robotc.net/forums/viewtopic.php?f=52&t=9540
Page 1 of 1

Author:  nanoslugs [ Sun Oct 12, 2014 3:53 pm ]
Post subject:  Please help me with my teleop code!

So, I am making a teleop program for our FTC Tetrix robot and my code is currently not working, so if someone would be so kind as to help me fix my code that would be great.
Well here it is:
Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     RightDrive,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     empty,         tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_1,     LeftDrive,     tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S2_C1_2,     empty,         tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{
    while(true)
       {
          getJoystickSettings(joystick);
         if(joy1Btn(joy1_y1) == -128)
             {
                   motor(LeftDrive) = 100;
           }
       else if(joy1Btn(joy1_y2) == -128)
             {
                   motor(RightDrive) = 100;
           }
          else
          {
                motor(LeftDrive) = 0;
                motor(RightDrive) = 0;
             }
       }
}


So I go in to the Samantha Field Control program, connect to the robot with samantha, and start the match and nothing happens. All the motors are connected, all the wires are in tight, I set the teleop program on the NXT to this program, and thats all I can think of, so thank you in advance.

Author:  BurningLights [ Sun Oct 12, 2014 9:37 pm ]
Post subject:  Re: Please help me with my teleop code!

I'm amazed this even compiles. But, ROBOTC seems to allow some funky things when it comes to the joysticks. Anyhow, if you're going for analog control, what you need is something like this:

Code:
motor[LeftDrive] = joystick.joy1_y1;
motor[RightDrive] = joystick.joy1_y2;


If you want to include a dead band (since the controller sticks usually don't return exactly to 0), you would need something like:
Code:
const int DEAD_ZONE = [insert value you want here];
if (abs(joystick.joy1_y1) > DEAD_ZONE)
{
  motor[DriveLeft] = joystick.joy1_y1;
}
else
{
  motor[DriveLeft] = 0;
}

And then use the same type setup for your right motor.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/