View unanswered posts | View active topics It is currently Wed Aug 27, 2014 11:12 am






Reply to topic  [ 8 posts ] 
Merge Teleop and Autonomous code together 
Author Message
Rookie
User avatar

Joined: Sat Feb 14, 2009 5:59 pm
Posts: 22
Post Merge Teleop and Autonomous code together
How do you properly merge the autonomous and teleop code into one program so that the FMS will recognize it and not disqualify my team?
Our official competition is tomorrow! :shock:

our teleop code is below
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  HTMotor,  none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     motorF,        tmotorNormal, openLoop)
#pragma config(Servo,  servo1,          servoL,               tServoNormal)
#pragma config(Servo,  servo2,          servoR,               tServoNormal)

#include "JoystickDriver.c"

task main()
{
  while (true)
  {
    getJoystickSettings(joystick);     //Update variables with current joystick values
    motor[motorD] = joystick.joy1_y1;
    motor[motorE] = joystick.joy1_y2;
    motor[motorF] = joystick.joy2_y1;
    servo[servoL] = joystick.joy2_y2 + 127;
    servo[servoR] = 255 - servoTarget[servoL];
  }
}


and our autonomous code is here:
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  HTMotor,  none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     motorF,        tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorG,        tmotorNormal, openLoop, reversed)
#pragma config(Servo,  servo1,          servoL,               tServoNormal)
#pragma config(Servo,  servo2,          servoR,               tServoNormal)

#include "JoystickDriver.c"

task main()
{
   getJoystickSettings(joystick);  //Update initial joystick/game values

  while(joystick.StopPgm)  //While the FMS says we're "disabled", keep looping
   {
    getJoystickSettings(joystick);  //Update joystick/game values to see if enabled
      wait1Msec(50);  //wait 50 milliseconds
   }
  {
  motor[motorD] = 50; // forward for three seconds
  motor[motorE] = 50;
  wait1Msec(3000);
  }
  {
  motor[motorD] = -25;
  motor[motorE] = 0;   //turns left
  wait1Msec(2000);
  }
  //I'd like to put some code for a touch sensor so that
  //the robot stops when the sensor is pushed
  //but will continue to go forward when it is released
  {
  motor[motorD] = 0;
  motor[motorE] = 0; //stops
  }
}

_________________
Lead Programmer for Team COV-0651.


Fri Mar 06, 2009 4:12 pm
Profile
Rookie
User avatar

Joined: Tue Feb 17, 2009 12:04 am
Posts: 3
Post Re: Merge Teleop and Autonomous code together
It's not necessary to merge your autonomous and teleop code together to pass software inspection (I'm not even sure if it's possible). The way the competition is set up is:
1: You connect your robot to the FMS.
2: You place your robot on the field and start the autonomous program.
3: The match starts and your autonomous programs runs.
4: Autonomous ends, the score is counted, and the FMS automatically switches control to the teleop program (which you select in the joystick control window of RobotC before the match).
Also you are not using the official templates http://www.education.rec.ri.cmu.edu/content/events/ftc/robotc/index.htm. PLEASE use the official templates.


Fri Mar 06, 2009 5:19 pm
Profile
Rookie
User avatar

Joined: Sat Feb 14, 2009 5:59 pm
Posts: 22
Post Re: Merge Teleop and Autonomous code together
yeah thats what I meant - am I supposed to put the code inside the FTC supplied templates?

Do I save it as "TeleOp" / "Autonomous" or can I give it a custom name?

_________________
Lead Programmer for Team COV-0651.


Fri Mar 06, 2009 5:22 pm
Profile
Rookie
User avatar

Joined: Tue Feb 17, 2009 12:04 am
Posts: 3
Post Re: Merge Teleop and Autonomous code together
Using a custom name is fine.


Fri Mar 06, 2009 5:25 pm
Profile
Novice

Joined: Fri Oct 24, 2008 8:58 am
Posts: 87
Post Re: Merge Teleop and Autonomous code together
since the autonomous and manual templates are identical its pretty trivial to have a single program that you use for both teleop and autonomous.

The big-big-big advantage to this is that you never download a different program into the robot. So the "telop program" selection needs to be only done once (I literally did it last October and never had to worry about it again.)

I think they really confused things by going to this 2 program method (perhaps it makes more sense for NXT-G or Labview but I doubt it)

To use a single template for both modes just copy the default template, then after the "WaitForStart" (I forget the exact name off the top of my head)
check which mode is actually being played by using the value in the joystick variable.

This way will definitely pass the software inspection and I never had any problems with the FMS either. Alot of 2 program teams had tons of problems. Not that its hard to use 2 programs its just a needless extra step.


Fri Mar 06, 2009 6:19 pm
Profile
Rookie
User avatar

Joined: Sat Feb 14, 2009 5:59 pm
Posts: 22
Post Re: Merge Teleop and Autonomous code together
so do you take the autonomous code and place it after the #pragma statements but before the "wait for start" piece of the TeleOp program?

_________________
Lead Programmer for Team COV-0651.


Fri Mar 06, 2009 7:24 pm
Profile
Novice

Joined: Thu Oct 09, 2008 7:58 pm
Posts: 79
Post Re: Merge Teleop and Autonomous code together
I'm sorry, But I think you're confused.

There are two ENTIRELY different templates for autonomous and teleoperated period, thus two entirely different codes.

The first teleoperated file will need to be selected via the field management system and will run automatically.

So if you have two separate files for autonomous and teleop, then it should be alright. Just make sure that in the program chooser, the telelop file is selected as your teleop program.

...now that I think about...your competition is probably over by now...How'd it go?


Fri Mar 06, 2009 11:29 pm
Profile
Rookie
User avatar

Joined: Sat Feb 14, 2009 5:59 pm
Posts: 22
Post Re: Merge Teleop and Autonomous code together
As of right now it's 10:45 pm (Friday) and the competition doesn't start until 9 am Saturday (EST).

Hopefully all will go well.

Hopefully.

:bigthumb:

_________________
Lead Programmer for Team COV-0651.


Fri Mar 06, 2009 11:47 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.