View unanswered posts | View active topics It is currently Sat Oct 25, 2014 7:40 pm






Reply to topic  [ 2 posts ] 
FTC Tele-Op Code 
Author Message
Rookie

Joined: Mon Jan 03, 2011 10:52 pm
Posts: 22
Post FTC Tele-Op Code
Another question for those that know how to code :)..

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S2, HTServo,  HTServo,  HTServo,  HTServo)
#pragma config(Motor,  mtr_S1_C1_1,     rightMotor,    tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     leftMotor,     tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C2_2,     shoulderMotor, tmotorNormal, openLoop, encoder)
#pragma config(Servo,  srvo_S2_C1_1,    claw,                 tServoNormal)
#pragma config(Servo,  srvo_S2_C1_2,    wrist,                tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

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


void initializeRobot()
{
  // Place code here to sinitialize servos to starting positions.
  // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.

  return;
}


task main()
{
  initializeRobot();

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

  int thresholdP = 10;
  int thresholdN = -10;

  while (true)
  {
    getJoystickSettings(joystick);
    if((joystick.joy1_y1) > thresholdP)
    {
      motor[rightMotor] = (((joystick.joy1_y1) * (joystick.joy1_y1)) / 161.29);
    }
    if((joystick.joy1_y1) < thresholdN)
    {
      motor[rightMotor] = (((joystick.joy1_y1) * (joystick.joy1_y1)) / -161.29);
    }
    if((joystick.joy1_y2) > thresholdP);
    {
      motor[rightMotor] = (((joystick.joy1_y2) * (joystick.joy1_y2)) / 161.29);
    }
    if((joystick.joy1_y2) < thresholdN);
    {
      motor[rightMotor] = (((joystick.joy1_y2) * (joystick.joy1_y2)) / -161.29);
    }
    if((joystick.joy2_y1) > thresholdP);
    {
      motor[shoulderMotor] = (((joystick.joy2_y1) * (joystick.joy2_y1)) / 161.29);
    }
    if((joystick.joy2_y1) < thresholdN);
    {
      motor[shoulderMotor] = (((joystick.joy2_y1) * (joystick.joy2_y1)) / -161.29);
    }
    if((joystick.joy2_y2) > thresholdP);
    {
      motor[motorA] = (((joystick.joy2_y1) * (joystick.joy2_y1)) / 161.29);
    }
    if((joystick.joy2_y2) > thresholdN);
    {
      motor[motorA] = (((joystick.joy2_y1) * (joystick.joy2_y1)) / -161.29);
    }
    if((joy2Btn(5) == 1));
    {
      servo(wrist) = 90;
    }
    if((joy2Btn(6) == 1));
    {
      servo(wrist) = 180;
    }
    if((joy2Btn(7) == 1));
    {
      servo(claw) = 90;
    }
    if((joy2Btn(8) == 1));
    {
      servo(claw) = 180;
    }
  }
}


OK! So I tried to make this code from the template. Just attempted it on the FCS system and it told me it couldn't find a tele-op portion of the code. Any ideas?


Thu Jan 20, 2011 8:41 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: FTC Tele-Op Code
Most likely because you haven't told the system what program you want to use for TeleOp. In the RobotC IDE, click Robot->Nxt Brick->Joystick Game panel to open the joystick control panel (note: this is from my memory so the wording may not be exact). In the joystick panel, there is a dropdown text box about teleop program, select the program name you want to be your teleop program. This will download a file to the NXT that will contain the teleop filename so the FCS will know which program to load for your TeleOp.


Thu Jan 20, 2011 10:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.