|
Page 1 of 1
|
[ 4 posts ] |
|
Is it possible to create an "overlooking" function?
Author |
Message |
Mockingbirch
Rookie
Joined: Tue Mar 25, 2014 6:44 pm Posts: 1
|
 Is it possible to create an "overlooking" function?
Hey everyone,
My course requires us to build a robot that can detect an infrared pulse, travel to it, and neutralize it. On our last milestone, we had each function working fine independently. For this upcoming one, however, we also need to have bumpers that will always cause the robot to stop and back up if triggered. The issue is, I can't figure out a way to program this simply into our existing code. It may be possible to create some complicated loops and if statements, but this is a task I'd rather avoid if possible.
Here's my question. Is it possible to create a function in RobotC that is always "watching" to see if it needs to trigger? ie the robot can be doing any task at all, but if a bumper is activated, everything else is overridden and it backs up? Or, if not, is there a simple bit of code I can insert into each function to achieve this? Thank you for any replies.
|
Tue Mar 25, 2014 6:52 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Is it possible to create an "overlooking" function?
You can use multiple tasks for this purpose. You'd have a global variable that is set to a specific value in your watcher task and is constantly checked for in your other tasks: Just keep in mind that using multiple tasks can cause more problems that you might think. = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Wed Mar 26, 2014 2:43 am |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Is it possible to create an "overlooking" function?
Or you can do multiple things in the same task.
|
Wed Mar 26, 2014 3:55 am |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Is it possible to create an "overlooking" function?
Or, instead of constantly checking the value in other tasks, Hog the CPU in the detecting task using hogCPU(), do the required actions, and then use releaseCPU(). Note that all other tasks are temporarily suspended and cannot function during this time. For more information, check out here. -A
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Fri Mar 28, 2014 10:44 am |
|
|
|
Page 1 of 1
|
[ 4 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
|
|