![]() |
How to use tasks
I read the task section in the WPILib manual and the class help file, but when I'm having difficulty getting anything working. The example I'm giving has everything extra cut out. (spelling and code punctuation might not be right)
Code:
class 4174robot : public InterativeRobot |
Re: How to use tasks
Why do you need to use task? Are you comfortable with multi-tasking programming? To deal with multiple tasks, you need to understand the concept of protecting share resources when accessing them from different tasks (e.g. using semaphores). If you are not familiar with the concept, you may want to avoid using task.
Having said that, our team is using task to offload the vision processing so it doesn't bog down the main robot task. We have done some performance tests and found out that analyzing a frame takes about 150-200 msec. So if you are doing vision processing in your main robot task, you may need to set the safety expiration longer than the time required to process a frame. |
Re: How to use tasks
1. The main reason I want to use a task is so that I can tell one system to do something while continuing to do something else.
2. No, I'm not really comfortable with multi-tasked programming. But what I'm trying to do won't be subject to multiple tasks trying to access the same systems. The task that I create will be the only one accessing the systems. |
Re: How to use tasks
Code:
class 4174robot : public IterativeRobot |
Re: How to use tasks
Alright, thanks alot... I'll try it tomorrow. I wish they would have put more of this in the WPILib Manual.
In addition to that, I noticed that you added the destructor. In a lot of other [FRC] examples, it seems like it is pretty much ignored. Just good coding practices or something more? |
Re: How to use tasks
Quote:
Quote:
|
Re: How to use tasks
I wasn't aware of the "cooperative multitasking" think. I'm just not sure how to go about it...
And replace all the absolutes (won't, never, etc) with shouldn't and such. I really do have absolutely no idea what I'm talking about... :( |
Re: How to use tasks
1 Attachment(s)
Now I get this ->
|
Re: How to use tasks
Ah, try this instead.
Code:
static void TestTaskFunction(void) |
Re: How to use tasks
Alright that works... I don't get it (FUNCPTR vs VOIDFUNCPTR), but it works.
Then I was like, why am I getting no output on my console. Then I remembered that the windriver console only works for the current task. (or something like that) |
Re: How to use tasks
Quote:
|
Re: How to use tasks
BTW, FUNCPTR and VOIDFUNCPTR are custom types. I don't have Wind River in front of me at the moment so I can't find the definitions of FUNCPTR and VOIDFUNCPTR for you. But I think VOIDFUNCPTR defines a function that returns void and FUNCPTR defines a function that returns an integer. Apparent, the task function should be returning an integer. Probably wouldn't matter but more correctly:
Code:
static int TestTaskFunction(void)Code:
Task(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000); |
Re: How to use tasks
Quote:
|
Re: How to use tasks
Oh yeah, cout doesn't work, either printf or cerr will work.
|
Re: How to use tasks
huh... printf dosen't work either. Are you using the wtx console in windriver?
|
| All times are GMT -5. The time now is 12:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi