Skip to content

Instantly share code, notes, and snippets.

@Swapnull
Last active November 14, 2016 19:50
Show Gist options
  • Save Swapnull/1dbddde41e63a5dd228ea44c0fa681b3 to your computer and use it in GitHub Desktop.
Save Swapnull/1dbddde41e63a5dd228ea44c0fa681b3 to your computer and use it in GitHub Desktop.
// this is the new behaviour. You set a global varaible inside the lineFollower task and then use it inside an arbiter.
// forage variables are show to give an idea of how it works.
int forage_left, forage_right, follow_left, follow_right;
task arbiter(){
if( follow_left || follow_right) {
setMotorSpeed(left, follow_left);
setMotorSpeed(right, follow_right);
} else if (forage_left || forage_right) {
setMotorSpeed(left, forage_left);
setMotorSpeed(right, forage_right);
}
}
task lineFollower() {
// all of your logic but using
follow_left = 30;
follow_right = 30;
// when following is done and you want to forage.
follow_left = 0;
follow_right = 0;
}
// This is basic line following behaviour, you set the speeds inside the lineFollower task.
task lineFollower() {
// all of your logic and when you want to move
setMotorSpeed(left, 30);
setMotorSpeed(right, 30);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment