Go to Post Good Luck all - this one will hurt your brain, but it's all in a good way. - meaubry [more]
Home
Go Back   Chief Delphi > Technical > Programming > WindRiver C++
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-15-2012, 02:10 PM
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 281
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Tasks based programming questions

So I feel like our teams teleop code is in a pretty good place as of last night, and we're getting started with autonomous (and the kinect ). But I'm also a bit curious if I should consider shuffling some routines into tasks.

Here's my current teleop code:
Code:
void TeleopPeriodic(void)
{
    // increment the number of teleop periodic loops completed
    m_telePeriodicLoops++;
    
    if (!BUTTON_CAMERA_ALIGN_SHOT_BUTTON())
    {
        anglesComputed = false;
        myRobot.TankDrive(stickLeftDrive,stickRightDrive);
        //myRobot.SetSafetyEnabled(true);
        myRobot.SetSafetyEnabled(false);
        testCount = 0;
    }
    CameraInitialize();
    AxisCamera &camera = AxisCamera::GetInstance("10.24.74.11");
    
    
    ManageAppendages();
    ManageElevator();
    ManageCatapult();
        
    if (camera.IsFreshImage())
    {
        ColorImage *colorImage = new ColorImage(IMAQ_IMAGE_HSL);
        camera.GetImage(colorImage);
        if (BUTTON_CAMERA_ALIGN_SHOT_BUTTON() && (anglesComputed == false))
        {
            DetermineTargetPosition(colorImage);
        }
        delete colorImage;
    }
}

void TeleopContinuous(void)
{
    if ((BUTTON_CAMERA_ALIGN_SHOT_BUTTON()) &&
    (anglesComputed == true))
    {
        RotateToTarget();
    }
}
My other question is do any of the WPILib constructs, like Jaguar, Joystick, Gyro, etc play nice when shared between tasks, or do I need to set things up with semaphores and protect them (semaphoreDriverStick.get) OR will the inards of the WPILib choke if I try to use these attributes outside of the main task (implying that I will need to get values and put them into a seperate variable so I can protect them)?


Unrelated question: How often is periodic? Is it called at a set rate, or is it only when control packets are recieved from the DS (which would really be semi-periodic)?

Thanks
Reply With Quote
  #2   Spotlight this post!  
Unread 02-15-2012, 06:49 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 596
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Tasks based programming questions

You can look at the WPILib source code to answer most of your questions. So far we found almost no scenario that we must use tasks (with only one exception: vision targeting). Even with vision targeting, it is arguable if we need a separate task. The reason we use a separate task for vision targeting is because we did a performance test on the various image filtering functions and found that total time it took to process an image is about 150-200 msec. We do not want to call into vision processing and have the main robot task hang for 200 msec. The worst case could be worse if your filter parameters resulted in generating a lot of false positive particles. Having said that, we could "yield" to process other robot subsystems after each filtering step. That could be acceptable. But the longest step could still take up tens of msecs so in the interest of having a "responsive" robot, we opt to use task for vision processing. By limiting the use of tasks, we would avoid all the pitfalls with multi-tasking programming on sharing resources. If you are not fluent with multi-tasking programming, you could have weird bugs that are hard to debug.
Quote:
Originally Posted by DjScribbles View Post
Unrelated question: How often is periodic? Is it called at a set rate, or is it only when control packets are recieved from the DS (which would really be semi-periodic)?
According to the WPILib source code on IterativeRobot:
Code:
/*
 * The default period for the periodic function calls (seconds)
 * Setting the period to 0.0 will cause the periodic functions to follow
 * the Driver Station packet rate of about 50Hz.
 */
static const double kDefaultPeriod = 0.0;
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 02-15-2012, 07:31 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 5,866
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Tasks based programming questions

Quote:
Originally Posted by DjScribbles View Post
How often is periodic? Is it called at a set rate, or is it only when control packets are recieved from the DS (which would really be semi-periodic)?
It's event driven. TeleOp is called each time a packet is received. The packets are supposed to be transmitted at ~20ms.

Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:12 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi