View unanswered posts | View active topics It is currently Mon Dec 22, 2014 8:52 am






Reply to topic  [ 3 posts ] 
joystick controller 
Author Message
Rookie

Joined: Fri Feb 11, 2011 9:07 am
Posts: 2
Post joystick controller
hi guys=D we are the Singapore team going for the ftc competition. so, we just got the parts and programming software 1 week ago after waiting for 1 month. This is the first time we are using robotc and we have no people teaching us so please help us. we are already having problem with tele-op and pl dont get us started on autonomous period. so please help us.

#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Motor, motorA, kickMotor, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorB, leftGrabber, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, rightGrabber, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_1, leftMotors, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_2, rightMotors, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C2_1, armMotors, tmotorNormal, PIDControl, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop)


#include "JoystickDriver.c" //Include file to incoperate Bluetooth messages.







task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase

int thresholdP = 10;
int thresholdN =-10;

while (true)
{
getJoystickSettings(joystick);
if(abs((joystick.joy1_y1)) > thresholdP);

motor[leftMotors] = (joystick.joy1_y1);

motor[leftMotors] = 0;
{
motor[leftMotors] = (joystick.joy1_y1);
}
if(abs((joystick.joy1_y2)) > thresholdP);
{
motor[rightMotors] = -(joystick.joy1_y2);

motor[rightMotors] = (joystick.joy2_y2);

motor[leftMotors] = (joystick.joy2_y1);
}
}
}
This is our program we are not sure why our both controllers are not working so please help we are very desperate.


Fri Feb 11, 2011 9:16 am
Profile
Rookie

Joined: Wed Feb 09, 2011 7:28 pm
Posts: 14
Post Re: joystick controller
kervyn wrote:
hi guys=D we are the Singapore team going for the ftc competition. so, we just got the parts and programming software 1 week ago after waiting for 1 month. This is the first time we are using robotc and we have no people teaching us so please help us. we are already having problem with tele-op and pl dont get us started on autonomous period. so please help us.

#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Motor, motorA, kickMotor, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorB, leftGrabber, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, rightGrabber, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_1, leftMotors, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_2, rightMotors, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C2_1, armMotors, tmotorNormal, PIDControl, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop)


#include "JoystickDriver.c" //Include file to incoperate Bluetooth messages.







task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase

int thresholdP = 10;
int thresholdN =-10;

while (true)
{
getJoystickSettings(joystick);
if(abs((joystick.joy1_y1)) > thresholdP);

motor[leftMotors] = (joystick.joy1_y1);

motor[leftMotors] = 0;
{
motor[leftMotors] = (joystick.joy1_y1);
}
if(abs((joystick.joy1_y2)) > thresholdP);
{
motor[rightMotors] = -(joystick.joy1_y2);

motor[rightMotors] = (joystick.joy2_y2);

motor[leftMotors] = (joystick.joy2_y1);
}
}
}
This is our program we are not sure why our both controllers are not working so please help we are very desperate.


Well, I don't quite understand what you are trying to accomplish with this code, but I think I can help some. It seems to me that as soon as you turn a motor on, you turn it off or change its direction. If you want some code where the left joystick of controller one (joystick.joy1_y1) controls the left motors and the right joystick of controller one (joystick.joy1_y2) controls the right motors, then I might do something like this:

Code:
task main()
{
  initializeRobot();

  waitForStart(); // wait for start of tele-op phase

  int thresholdP = 10;

  while (true)
  {
    getJoystickSettings(joystick);
    if(abs(joystick.joy1_y1) > thresholdP)
    {
      motor[leftMotors] = joystick.joy1_y1 * 100 / 128; //The joystick naturally reads on a scale of 0 to 128.
    }                                    //This gives you joystick readings on a scale of 0 to 100
    else
    {
       motor[leftMotors] = 0; //If you're not moving the joystick, then stop.
    }
    if(abs(joystick.joy1_y2) > thresholdP)
    {
      motor[rightMotors] = joystick.joy1_y2 * 100 / 128;
    }
    else
    {
       motor[rightMotors] = 0;
    }
  }
}


By the way, don't have a semicolon at the end of your if statement. It is improper syntax but the RobotC compiler doesn't notice it. I once did that and the if statement always read true. :)

Hope this helps.


Fri Feb 11, 2011 10:37 am
Profile
Rookie

Joined: Fri Feb 11, 2011 9:07 am
Posts: 2
Post Re: joystick controller
thanks did not know that=D thanks a lot=D


Fri Feb 11, 2011 10:42 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.