Programming instructions
Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
SPA • 1
Sense Plan Act (SPA)
task main()
{
bMotorReected[port2]=1;
while(true)
{
if(SensorValue(bumper)==0)
{
motor[port3]=127;
motor[port2]=127;
}
else
{
motor[port3]=127;
motor[port2]=-127;
wait1Msec(1500);
}
}
}
Sense, Plan, Act was an early robot control procedure commonly abbreviated SPA. Today we
use its fundamental concepts to remind us of the three critical capabilities that every robot must
have in order to operate effectively:
SENSE: The robot needs the ability to sense important things about its environment, like the
presence of obstacles or navigation aids. What information does your robot need
about its surroundings, and how will it gather that information?
PLAN: Therobotneedstotakethesenseddataandgureouthowtorespondappropriately
to it, based on a pre-existing strategy. Do you have a strategy? Does your program
determine the appropriate response, based on that strategy and the sensed data?
ACT: Finally, the robot must actually act to carry out the actions that the plan calls for. Have
you built your robot so that it can do what it needs to, physically? Does it
actually do it when told?
SENSE: The robot uses a Bumper Switch to sense whether it has collided with an object.
PLAN: The overall strategy for this robot is to run forward unless something is in its way,
which it will detect using the Bumper Switch. If the Bumper Switch is unpressed,
the motors will be run forward; if the Bumper Switch is pressed, the robot will turn
away from the obstacle. This is all captured in the program, which runs on the robot,
reading the sensor’s data and issuing the appropriate motor commands.
ACT: The robot acts by moving its motors in response to the given motor commands, which
are given in combinations that produce forward movement and turns as appropriate.
Where are S, P, and A in this program?
Go to Reference Links