View unanswered posts | View active topics It is currently Mon Jul 28, 2014 1:17 am






Reply to topic  [ 7 posts ] 
Proper Autonomous Sample Program 
Author Message
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 601
Post Proper Autonomous Sample Program
Here is a sample program for a proper autonomous program...

At the FTC competition, you will manually start your autonomous program, but your program can't "execute" until it receives a command from the Field Management system that it no long "disabled".... here's some code to get you started with that.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, PIDControl)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, PIDControl)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"  //Include the Joystick/Game variables driver.

task main()
{
   getJoystickSettings(joystick);  //Updates the game and joystick variables

        while(joystick.StopPgm)  //Continues this loop while the robot is disabled (StopPgm = true)
        {
           getJoystickSettings(joystick);  //Checks to see if the robot has been enabled (StopPgm = false)
           wait1Msec(50);  //Waits 50 milliseconds for a new BT packet to come.
        }

       // Autonomous Code Below - You can put all of your autonomous program below

   motor[motorD] = 50;
   motor[motorE] = 50;
   wait1Msec(3000);

   motor[motorD] = 0;
   motor[motorE] = 0;
}


_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Wed Sep 24, 2008 1:06 pm
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: Proper Autonomous Sample Program
We just had a "Train the Trainers" workshop with Mannie Lowe from FIRST. It turns out that the model for this year allows for a single program or two programs. Dick, have you received the details on the exact behavior yet and will it be implemented for 1.45?

_________________
Jeff McBride
Benson Robotics Club


Sun Oct 05, 2008 1:27 pm
Profile
Rookie

Joined: Wed Mar 05, 2008 11:37 am
Posts: 3
Post Re: Proper Autonomous Sample Program
Jeff McBride wrote:
We just had a "Train the Trainers" workshop with Mannie Lowe from FIRST. It turns out that the model for this year allows for a single program or two programs. Dick, have you received the details on the exact behavior yet and will it be implemented for 1.45?


Uh-oh. the secret is out... :)

Tim: Here's what I did to handle both auto and teleop in the single program. This assumes that the new version of RobotC doesn't end the single program between Auto and teleop (as it currently does in 1.44).

Mannie

Code:
task main()
{
  // assumes RobotC version 1.44
  while (true)
  {
    getJoystickSettings(joystick);

    // has the FMS stopped the program
    if (joystick.StopPgm)
    {
      nxtDisplayTextLine(2, "Disabled");
      wait1Msec(50);
      stopMotors();   // this routine sets all active motors to 0 - exercise left to student.
      continue;   // go back into top of while loop
    }

    if (!joystick.UserMode)    // autonomous mode
    {
      nxtDisplayTextLine(2, "Autonomous");
          // put autonomous code here
    }

    else                      // teleop mode
    {
      nxtDisplayTextLine(2, "TeleOp");
          // put teleop code here
    }
  }
}


Fri Oct 10, 2008 4:41 pm
Profile
Rookie

Joined: Fri Nov 14, 2008 4:51 pm
Posts: 2
Post Re: Proper Autonomous Sample Program
We were at a qualifying competition at Hillsborough High School about 3 or 4 weeks ago and the example template (containing both the autonomous code and teleop code in one program) that everyone originally received for the software inspection was wrong and didn't work properly with the field system. Fortunately, Exploding Bacon provided a code that did work. Unfortunately, after the competition that template got overwritten on my computer as I hit recompile before I changed and saved the file name. :breakcomputer:

Does anybody have this template that they KNOW FOR SURE WORKS WITH THE FIELD MANAGEMENT SYSTEM from one of the qualifying competitions this year?

Thanks.

_________________

BPS RoboBucs- FTC Team 0429
Rookie Year- 2007

2008 Tempest N' Tampa VEX Qualifier - Excellence Award

Attending 2008/2009 VEX World Championships - Dallas, Texas


Tue Dec 09, 2008 8:08 pm
Profile
Novice

Joined: Mon Oct 13, 2008 6:29 pm
Posts: 75
Location: Florida, USA
Post Re: Proper Autonomous Sample Program
the one above is fine just delete the if (!joystick.usermode), this messed up autonomous, but tele-op was fine, i was there 2

_________________
PHUHS Robotics
Team 516 FTW

Daytona Robofest Winning Alliance Captain
Daytona Robofest Inspire Award


Tue Dec 09, 2008 8:20 pm
Profile
Rookie

Joined: Fri Nov 14, 2008 4:51 pm
Posts: 2
Post Re: Proper Autonomous Sample Program
Quote:
the one above is fine just delete the if (!joystick.usermode), this messed up autonomous, but tele-op was fine, i was there 2


OK. Thanks. What can we change that to, to get the autonomous to work?

_________________

BPS RoboBucs- FTC Team 0429
Rookie Year- 2007

2008 Tempest N' Tampa VEX Qualifier - Excellence Award

Attending 2008/2009 VEX World Championships - Dallas, Texas


Wed Dec 10, 2008 5:05 am
Profile
Novice

Joined: Mon Oct 13, 2008 6:29 pm
Posts: 75
Location: Florida, USA
Post Re: Proper Autonomous Sample Program
delete the whole line

_________________
PHUHS Robotics
Team 516 FTW

Daytona Robofest Winning Alliance Captain
Daytona Robofest Inspire Award


Wed Dec 10, 2008 3:12 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.