EasyManuals Logo

LEGO MINDSTORMS Robots User Manual

LEGO MINDSTORMS Robots
226 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #142 background image
Page 154
grabber arm command it sent to avoid unnecessarily sending the same command twice.
To provide some feedback to the human operator, lightWatcher plays tones when it sends the grab or release commands.
The hearbeat task is very simple. It repeatedly sends the heartbeat command to the IR port.
Programming Minerva
Minerva's program, then, must listen for incoming messages on the IR port and respond to them. This is fairly simple, but it's complicated by two things:
1. Minerva should listen for the heartbeat commands from the remote. If she doesn't hear them, she should stop what she's doing until the IR link is established again.
2. The human operator should be able to change the direction of the arm as it is moving, without waiting for an entire grab or release cycle to be completed. This feature, however, should not
interfere with Minerva's ability to stop the arm when it moves up as far as it can go.
Minerva's program is split into four primary tasks:
message Watcher
The messagewatcher task examines the IR port for incoming messages. When one arrives, it is examined and the appropriate action is taken.
grab and release
The grab and release tasks are kicked off by messageWatcher to control Minerva's arm. They are separate tasks so that messageWatcher can continue to receive commands from the
remote while the arm is moving. You could, for example, start driving forward while the arm was grabbing. grab and release have the ability to interrupt each other, so you can change the
direction of the arm as it's moving.
heartbeatWatcher
This task keeps count of missing heartbeats. When messageWatcher receives a heartbeat, it subtracts one from a tally of missing heartbeats, kept in the missedBeats variable. The
heartbeatWatcher adds one to this count; if it's ever more than one, heartbeatWatcher assumes it has lost contact with the remote. It then stops the messageWatcher task and shuts
down the robot's motors. When the heartbeat is heard again, heartbeatWatcher starts up messageWatcher once again.
Here's the entire program. I'll describe more of the details after the listing.
Page 155
#define FORWARD_MESSAGE 16
#define SPIN_MESSAGE 17
#define STOP_MESSAGE 18
#define GRAB_MESSAGE 19
#define RELEASE_MESSAGE 20
#define HEARTBEAT_MESSAGE 21
#define HEARTBEAT_TIME 20
int message;
int armLock;
int missedBeats;
task main() {
SetSensor (SENSOR_3, SENSOR_LIGHT);
armLock = 0;
missedBeats = 0;
start messageWatcher;
start heartbeatWatcher;

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

LEGO MINDSTORMS Robots Specifications

General IconGeneral
Product LineLEGO MINDSTORMS
CategoryToy
Age Range10+
Batteries RequiredYes
Memory64 MB RAM, 16 MB Flash
ConnectivityBluetooth, USB
SensorsTouch, Color, Gyro
Battery TypeAA
Interactive FeaturesProgrammable, Remote Control
App CompatibilityiOS, Android
ProcessorARM9
Pieces Count601
Battery Count6
App NameLEGO MINDSTORMS EV3 Programmer App

Related product manuals