Working with robots.
Robot commands talk to all objects on the
TELL list. If the
contains an object that is not a robot, like a turtle, the robot command catches any
errors that Logo throws because the object does not know the command, and ignores the
error. If the command should output a value, a robot command returns a default value.
Contains the properties of the current robot.
GPROP "ROBOT "NAME
The ROBOT variable contains a collection of all properties of a robot. The
command outputs the complete property list for a robot, but the presence of each property
can be checked for with the
The :ROBOT variable does not contain any properties if no robot is connected. If a robot is connected, :ROBOT contains the following properties:
|NAME||The name of the robot|
|MOTORS||The number of motors|
|LIGHTS||The number of lights or LEDs|
|SOUNDS|| The number of sound channels; if one or more sounds channel is present, at least the
|LIGHT.SENSORS||The number of light sensors|
|OBSTACLE.SENSORS||The number of obstacle sensors|
|LINE.SENSORS||The number of line sensors|
|SWITCH.SENSORS||The number of switch sensors|
|TEMP.SENSORS||The number of temperature sensors|
|ACCEL.SENSORS||The number of acceleration sensors; if present, the sensor outputs a list of three values for accelerations in the X, Y, or Z directions.|
|TIMERS||The number of timers on the device|
|BATTERY||Contains TRUE if the battery voltage can be checked, FALSE otherwise|
|DOWNLOAD||Contains TRUE if the robot accepts downloadable procedures, FALSE otherwise|
Reports the state of a robot's acceleration sensors.
An acceleration sensor outputs a three-element list of acceleration values. The first
element is the value for the X axis, the second for the Y axis, and the third for the
Z axis. The exact nature of these sensors depends on the robotic device. The ACCEL.SENSORS
command outputs this list. If the robot does not have any acceleration sensors, the
command outputs an empty list. See also
Reports the voltage of a robot's battery.
Some robots are able to report their battery voltage. The BATTERY command outputs the robot’s battery voltage in Volts. If there is no battery voltage to report, BATTERY reports the value 0.
Play a short beep on the robotic device.
Many robots can produce sounds, from simple beeps to complex melodies. The BEEP command issues
a beep on the robotic device. The
NOTES command controls the sound channels of a device.
Reports the state of a robot's light sensors.
The LIGHT.SENSORS command outputs a list of the values of all light sensors of a
robotic device. Each value is a value between 0 and 1, where 0 stands for total darkness,
and 1 for total brightness. If the robot does not have any light sensors, the
command outputs an empty list. See also
Turns one or more lights on or off.
LIGHTS value-or-list (LIGHTS)
The LIGHTS command instructs robotic devices to turn one or more of its lights on or off.
Lights may be controlled separately or together. The first input is a list of color values,
or a single color value. Each value is either the name of a color, a color number, or a list of color values. See the
COLORS command for details. The first element of the list is the color
of the first light, the second for the second light, and so on. A value of TRUE leaves the current
color, and a value of FALSE turns the light off. If the input is not a list, but a single value,
every light of the robot is affected.
(LIGHTS) without inputs turns off all lights altogether.
Reports the state of a robot's line sensors.
Line sensors are used to track a black line on a white sheet of paper. Usually, there
are two of them to track the left and right sides of the line, and each sensor reports
either TRUE or FALSE. The LINE.SENSORS command outputs this list. If the robot does not
have any line sensors, the command outputs an empty list. See also
Applies power to one or more motors.
MOTOR number-or-list power (MOTOR number-or-list power duration) MOTOR number-or-list "FALSE
The RCX robot controller contains three motor ports. Motors attached to these ports may be controlled separately or together. They can be turned on in either direction, the direction may be reversed, and seven levels of power may be applied to each motor. A motor can be stopped either immediately, utilizing an internal brake, or more smoothly.
The first input to MOTOR is either the number of the motor port or a list of motor numbers. Valid motor numbers are 1, 2, and 3. The second input is the power level as a percentage between -100 and 100. Negative values cause the motor turn in the opposite direction from positive values. A power level of 0 causes the motors to float, which means that they slow down until they stop. If an immediate stop is needed, use FALSE instead of a power value which turns the motor(s) off immediately. The RCX motors have 7 levels of power.
An optional, third input of time, measured in milliseconds, may be supplied. If supplied, the motor is turned off automatically after the time has elapsed.
The MOTOR command also works with motors of any other robotics devices
supported by Logo. For the number of motors and the possible power levels,
use the command
Plays a note on one or more sound channels.
NOTES value-or-list duration (NOTES value-or-list) (NOTES)
Many robots can produce sounds, from simple beeps to complex melodies. The
BEEP command issues
a beep on the robotic device. The NOTES command controls the sound channels of a device. Its first
input is a list of values, one for each channel that the device supports. If the list is shorter
than the number of available channels, the remaining channels are left untouched. If the input is
only a single value, that value affects all channels.
The value itself is the frequency of the sound in Hertz. If the value is TRUE, the value for that specific sound channel is left unchanged, and if the value is FALSE or 0, the channel is turned off. The second, optional, input is the number of milliseconds that the channels will sound before being turned off. If the NOTES command is used without any inputs, all sounds are turned off.
Reports the state of a robot's obstacle sensors.
The OBSTACLE.SENSORS command outputs a list of the values of all obstacle detection
sensors of a robotic device. These sensors are often ultrasonic devices. The values
can be numeric values, but most often, each value is TRUE if the sensor detects an
obstacle, and FALSE otherwise. If the robot does not
have any obstacle sensors, the command outputs an empty list. See also
Reports a property list containing data about the current robot.
The ROBOTFACTS command outputs a property list of information about the currently connected
robot. If no robot is connects, ROBOTFACTS outputs an empty list. ROBOTFACTS is an abbreviation
PLIST “ROBOT. See the
:ROBOT variable for a complete list of possible properties.
Reports the state of a robot's switches.
The SWITCH.SENSORS outputs a list of switch states if the robot has any switches. Each
switch is either TRUE if it is turned on, or FALSE if it is turned off. If the robot does not
have any switches, the command outputs an empty list. See also
Reports the value of a robot's temperature sensor.
The TEMP command outputs the temperature in degrees Celsius. If the robot does not have a temperature sensor, TEMP outputs the value -274, which is less than the lowest possible temperature (zero degrees Kelvin or about -273 degrees Celsius).