View unanswered posts | View active topics It is currently Tue Sep 02, 2014 10:26 am






Reply to topic  [ 10 posts ] 
how do we switch to teleops program? 
Author Message
Rookie

Joined: Sat Oct 18, 2008 3:29 pm
Posts: 4
Post how do we switch to teleops program?
When the autonomous period ends, how do we call out the teleops program we would like to run? I've watched the webinars, and they tell me I need to call out the teleops program at the end of my autonomous code, but how do we do that? Is it as simple as just putting the name of the file at the end of the program, or is there a function we are overlooking?


Fri Dec 05, 2008 3:20 pm
Profile
Rookie

Joined: Thu Dec 04, 2008 4:40 pm
Posts: 8
Post Re: how do we switch to teleops program?
Sorry if this is not very helpful, but try this link

_________________
Trying to help you will be like trying to find a worm in the middle of a blizzard. A white worm.


Fri Dec 05, 2008 6:17 pm
Profile
Rookie

Joined: Sat Dec 06, 2008 1:47 pm
Posts: 1
Post Re: how do we switch to teleops program?
Change the "Teleop Program Name" in your debug window. A text file is created on the NXT, and the FMS will switch automatically for you at the competition.


Sat Dec 06, 2008 1:50 pm
Profile
Rookie

Joined: Mon Nov 03, 2008 1:45 pm
Posts: 14
Post Re: how do we switch to teleops program?
Why can't both autonomous and tele-op code be in the same program? The joystick struct has a flag indicating whether the FMS is in autonomous mode or not.

_________________
David Burnette
Tigard High School Robotics


Tue Dec 09, 2008 7:59 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post Re: how do we switch to teleops program?
It's the way the field management system works. Even if you choose the same program for "tele-op" as you start for autonomous, during the "pause" period between modes, the FMS will restart your program.

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


Wed Dec 10, 2008 10:35 am
Profile
Rookie

Joined: Mon Nov 03, 2008 1:45 pm
Posts: 14
Post Re: how do we switch to teleops program?
OK, so the FMS will restart the program. If we combine both auto and tele in the same program, then the FMS will restart our single program and it will still work, right?

If so, would we still need to create the configuration file?

There additional discussions on this at http://www.robotc.net/forums/viewforum.php?f=33 but the last post makes no sense. If a single program is acceptable and works, then please post the complete single-program template.

Thanks

_________________
David Burnette
Tigard High School Robotics


Thu Dec 11, 2008 11:54 am
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: how do we switch to teleops program?
We created this single program template which follows all of the rules:

Code:
#include "JoystickDriver.c"

void autonomous()
{
    // autonomous code goes here
}

void drive()
{
    // user drive code goes here
}

task UserCode()
{
    if (joystick.UserMode)
        drive();
    else
        autonomous();
}

task main()
{
    getJoystickSettings(joystick);

    // wait for the FMS to start autonomous or driver control mode
    while (joystick.StopPgm)
    {
        wait10Msec(2);
        getJoystickSettings(joystick);
    }

    StartTask(UserCode);

    // Keep polling the joysticks and keep an eye on the stop flag.
    while (!joystick.StopPgm)
    {
        wait10Msec(2);
        getJoystickSettings(joystick);
    }

    StopTask(UserCode);
    stopMotors();
}

_________________
Jeff McBride
Benson Robotics Club


Thu Dec 11, 2008 12:17 pm
Profile
Rookie

Joined: Fri Dec 12, 2008 1:59 am
Posts: 2
Post Re: how do we switch to teleops program?
Jeff,

Your code appears to be a good approach to having a single program. Have you verified that it works with an FMS?

Also, have you experienced any problems when using tasks? Not that I am aware of any--we just haven't used yet.

Thanks.

--Bill Wiley


Fri Dec 12, 2008 2:12 am
Profile
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: how do we switch to teleops program?
We were one of the teams that were chosen last spring to participate in the beta program and showcase tournament for the Tetrix platform. We have found tasks to be very useful and quite manageable. There are a couple of things that you should keep in mind when using tasks.

1) You can not call the same subroutine from more than one task. This is because all local variables are actually static globals rather than being on the stack.

2) If you have a function that you need to call from multiple tasks you can use the "inline" keyword in the function declaration. That will make the compiler insert the body of the function inline in the caller.

3) You should avoid trying to adjust the priorities of the tasks. Instead, each task should yield the CPU with a wait statement inside any loops. Notice the wait in the main task of my template for an example. Multiple tasks will still function if you do not use wait statements but it is always a good idea but a wait statement will immediately end your current time slice and allow another task to start earlier. Remember that there are bottlenecks when talking to sensors and so on that mean that a while loop can pole them far more frequently than they can update.

4) If you have a critical section you can surround it with HogCPU/ReleaseCPU. Do this ONLY when it is critical. For example if you need to swap two values that are used by a parallel task and want to make sure that the other task does not look at the values while they are changing you should hog the cpu, swap the value and then release the cpu.

5) Don't go task crazy. You should have a good reason for doing things in parallel.

6) Even if the only task you define is task main() there are actually multiple tasks running. The drivers for the various sensors and other hardware elements have background tasks that poll the hardware and update things. That is how the values in the sensor[] array get updated and how changes you make to the motor[] array actuall propagate to the motors.

You should notice that the main task in my template polls the game controllers so you will not have to do that in any other task. The "drive" task can just look at the "joystick" structure without calling getJoystickSettings() becuase it is being done by "main" in the background.

_________________
Jeff McBride
Benson Robotics Club


Fri Dec 12, 2008 11:46 am
Profile
Rookie

Joined: Fri Dec 12, 2008 1:59 am
Posts: 2
Post Re: how do we switch to teleops program?
Jeff,

Great info. Thanks.

--Bill


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