User Tools

Site Tools


logo:commands:robots

Robotics

Working with robots.

Robot commands talk to all objects on the TELL list. If the TELL list 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.

:ROBOT

Contains the properties of the current robot.

Syntax

GPROP "ROBOT "NAME

Description

The ROBOT variable contains a collection of all properties of a robot. The ROBOTFACTS

command outputs the complete property list for a robot, but the presence of each property can be checked for with the GPROP command.

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 BEEP command should work.
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

ACCEL.SENSORS

Reports the state of a robot's acceleration sensors.

Syntax

ACCEL.SENSORS

Description

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 LIGHT.SENSORS, OBSTACLE.SENSORS, LINE.SENSORS, and SWITCH.SENSORS.

BATTERY

Reports the voltage of a robot's battery.

Syntax

BATTERY

Description

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.

BEEP

Play a short beep on the robotic device.

Syntax

BEEP

Description

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.

LIGHT.SENSORS

Reports the state of a robot's light sensors.

Syntax

LIGHT.SENSORS

Description

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 ACCEL.SENSORS, OBSTACLE.SENSORS, LINE.SENSORS, and SWITCH.SENSORS.

LIGHTS

Turns one or more lights on or off.

Syntax

LIGHTS value-or-list
(LIGHTS)

Description

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 SETPC and 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.

LINE.SENSORS

Reports the state of a robot's line sensors.

Syntax

LINE.SENSORS

Description

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 ACCEL.SENSORS, OBSTACLE.SENSORS, LIGHT.SENSORS, and SWITCH.SENSORS.

MOTOR

Applies power to one or more motors.

Syntax

MOTOR number-or-list power
(MOTOR number-or-list power duration)
MOTOR number-or-list "FALSE

Description

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 ROBOTFACTS.

NOTES

Plays a note on one or more sound channels.

Syntax

NOTES value-or-list duration
(NOTES value-or-list)
(NOTES)

Description

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.

OBSTACLE.SENSORS

Reports the state of a robot's obstacle sensors.

Syntax

OBSTACLE.SENSORS

Description

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 ACCEL.SENSORS, LINE.SENSORS, LIGHT.SENSORS, and SWITCH.SENSORS.

ROBOTFACTS

Reports a property list containing data about the current robot.

Syntax

ROBOTFACTS

Description

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 if PLIST “ROBOT. See the :ROBOT variable for a complete list of possible properties.

SWITCH.SENSORS

Reports the state of a robot's switches.

Syntax

SWITCH.SENSORS

Description

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 ACCEL.SENSORS, LINE.SENSORS, LIGHT.SENSORS, and OBSTACLE.SENSORS.

TEMP

Reports the value of a robot's temperature sensor.

Syntax

TEMP

Description

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).

logo/commands/robots.txt · Last modified: 2018/08/27 03:39 (external edit)