Go to Post At this rate, Team Update #2 should just eliminate the Minibots and replace it with the drive team captains playing rock-paper-scissors to determine the bonus points. - artdutra04 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-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 23-02-2010, 20:18
DjMaddius's Avatar
DjMaddius DjMaddius is offline
Registered User
AKA: Matt Smith
FRC #2620 (Southgate Titans)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Southgate, Mi
Posts: 161
DjMaddius is an unknown quantity at this point
Tasks?

Can someone explain to me how to do the VxWorks tasks?


Currently our code isnt working.

Task loopingTask("SpinTask", (FUNCPTR)(int(PneumaticSystem::lop)));

Doesnt work.
Get error "error: argument of type `int (PneumaticSystem:()' does not match `int (*)(...)'"
Reply With Quote
  #2   Spotlight this post!  
Unread 23-02-2010, 20:39
gvarndell's Avatar
gvarndell gvarndell is offline
Software Engineer
AKA: Addi's and Georgie's Dad
FRC #1629 (GaCo)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Grantsville, Maryland
Posts: 350
gvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond reputegvarndell has a reputation beyond repute
Re: Tasks?

Quote:
Originally Posted by DjMaddius View Post
Can someone explain to me how to do the VxWorks tasks?

Currently our code isnt working.

Task loopingTask("SpinTask", (FUNCPTR)(int(PneumaticSystem::lop)));

Doesnt work.
Get error "error: argument of type `int (PneumaticSystem:()' does not match `int (*)(...)'"
Looks like you've got a smiley face in there somewhere.

Why did you insert 'int' right in front of the left paren?
Are you trying to cast (PneumaticSystem::lop)?
The FUNCPTR macro should be all the cast you need.
__________________
Robots never, ever, ever, ever break -- The Robot Repairman (Backyardigans)
Reply With Quote
  #3   Spotlight this post!  
Unread 23-02-2010, 21:11
DjMaddius's Avatar
DjMaddius DjMaddius is offline
Registered User
AKA: Matt Smith
FRC #2620 (Southgate Titans)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Southgate, Mi
Posts: 161
DjMaddius is an unknown quantity at this point
Re: Tasks?

Quote:
Originally Posted by gvarndell View Post
Looks like you've got a smiley face in there somewhere.

Why did you insert 'int' right in front of the left paren?
Are you trying to cast (PneumaticSystem::lop)?
The FUNCPTR macro should be all the cast you need.
Should i make it void?

I put an int because thats how i saw it in a previous code.
Reply With Quote
  #4   Spotlight this post!  
Unread 23-02-2010, 23:12
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Tasks?

(FUNCPTR)neumaticSystem::lop should work fine.
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 27-02-2010, 08:17
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Tasks?

you need to make the function static, or you can add tons of gobbeldygook (I would add static in front of the function)
also, if you are in your class, you can just use Task loopingTask("SpinTask", (FUNCPTR)lop);
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #6   Spotlight this post!  
Unread 27-02-2010, 09:58
mikets's Avatar
mikets mikets is online now
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
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?

You have to be careful when using tasks. Tasks are run concurrently. In a preemptive multi-tasking environment, you need to use semaphores to protect against resources being accessed by concurrent tasks (take a look at the notifier as an example). If you are not familiar with this concept, I would advise against using them. You can easily implement the effect of tasks by using cooperative multi-tasking. IterativeRobot class is such an example. In cooperative multi-tasking, tasks can only be switched away if the task chooses to do so. For example, in IterativeRobot, consider AutonomousPeriodic is a task. It got run in every StartCompetition loop, just like a task got run periodically. But the difference is that you are guaranteed that nobody changes the robot state while you are executing your AutonomousPeriodic code.
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 27-02-2010, 14:27
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Tasks?

We use several tasks for doing things that need to happen continuously and which have limited interaction with the other portions of the program. For example, we have a task that controls the motor power change rate.

What we do is have a non class based function which we call to start the task. The method used is somewhat similar to that used in the compressor.

We create a class for the operation in question to contain the data to be shared and the methods for accessing that data. The class also contains the task variable.

class Drive {
Task motorControlTask;
....
public:
Drive();
~Drive();
Drive(UINT32, UINT32);
};

The .cpp file for this class contains a function outside of the class called motorLimitStub which takes as its argument a pointer to the class.

The constructor for this class constructs this task.
Drive:rive(UINT32 leftChan, UINT32 rightChan) :
motorControlTask ("Motor Control Task", (FUNCPTR)motorLimitStub),

The stub function that is called when the task is started looks like:
static void motorLimitStub(Drive *bd) {
bd->motorLimitTask();
}

In this case, the drive class/task has complete ownership of the drive motor speed controls and monitors/adjusts the rate at which the motor speeds are allowed to change. No other part of the robot is allowed to adjust drive motor power levels. Instead, they post requests to the task, for a desired power level which the drive task will get to over some period of time.

Last edited by ericand : 27-02-2010 at 14:32. Reason: Error in initial posting
Reply With Quote
  #8   Spotlight this post!  
Unread 28-02-2010, 13:31
DjMaddius's Avatar
DjMaddius DjMaddius is offline
Registered User
AKA: Matt Smith
FRC #2620 (Southgate Titans)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Southgate, Mi
Posts: 161
DjMaddius is an unknown quantity at this point
Re: Tasks?

Quote:
Originally Posted by byteit101 View Post
you need to make the function static, or you can add tons of gobbeldygook (I would add static in front of the function)
also, if you are in your class, you can just use Task loopingTask("SpinTask", (FUNCPTR)lop);
Thanks! This fixed my problem.

Its always the simplest of things isnt it? -.-
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error creating tasks that use encoders tbinns C/C++ 5 14-02-2010 10:28
What are RobotC tasks? daltore Programming 4 01-07-2009 08:59
Periodic Tasks Luke Pike NI LabVIEW 1 04-02-2009 01:14
RobotC tasks ratcateme Programming 1 07-11-2008 00:58
First logo and tasks Denman Rumor Mill 21 19-04-2005 11:32


All times are GMT -5. The time now is 02:47.

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


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