LEGO MINDSTORMS Robots Manual page 185

Unofficial guide
Table of Contents

Advertisement

• avoid() is the highest-level behavior. It is triggered by the bumpers and does the standard back-up-and-turn.
Convincing Hank to seek light is surprisingly hard. You can, of course, implement your own algorithm in seek_enlightenment(). It's a neat feature of subsumption architecture that you can
concentrate solely on light-seeking behavior in seek_enlightenment(). The obstacle avoidance behavior is already programmed in a different behavior and will subsume the light-seeking
behavior as necessary.
Without further ado, here's the entire program, LightSeeker.c:
#include "conio.h"
#include "direct-button.h"
#include "direct-motor.h"
#include "direct-sensor.h"
#include "unistd.h"
#include "sys/tm.h"
#define MAX_TASKS 32
pid_t pid[MAX_TASKS];
int task_index;
#define BACK_TIME 500
#define TURN_TIME 800
// Motor commands.
#define COMMAND_NONE -1
#define COMMAND_FORWARD 1
Figure 10-2.
Hank, retrofitted with a light sensor
Page 205

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MINDSTORMS Robots and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents