Communications

Infrared (IR) is invisible light with longer wavelengths than visible light, and it is commonly used in TV remote controls to transmit small amounts of data. IR is used in Sphero BOLT, BOLT+, and RVR/RVR+ to transmit data such as relative distance and heading between robots to enable following and evading behavior among multiple robots, as well as to send custom messages. There are four IR emitters and receivers (pairs) for 360° awareness assuming there is a clear line of sight between two or more robots. The effective range is up to about 3 meters.

Broadcast

startIRBroadcast() sets the IR emitters to broadcast on two specified channels, from 0 to 7, so other robots can follow or evade. The broadcaster uses two channels because the first channel emits near IR pulses (< 1 meter), and the second channel emits far IR pulses (1 to 3 meters) so the following and evading robots can detect these messages on their IR receivers with a sense of relative proximity to the broadcaster. You can't use a channel for more than one purpose at time, such as sending messages along with broadcasting, following, or evading. 

For example, use startIRBroadcast(0, 1) to broadcast on channels 0 and 1, so that other robots following or evading on 0 and 1 will recognize this robot. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Stop Broadcasting

stopIRBroadcast() stops the broadcasting behavior. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Follow

startIRFollow() sets the IR receivers to look for broadcasting robots on the same channel pair, from 0 to 7. Upon receiving messages from a broadcasting robot, the follower will adjust its heading and speed to follow the broadcaster. When a follower loses sight of a broadcaster, the follower will spin in place to search for the broadcaster. You can't use a channel for more than one purpose at time, such as sending messages along with broadcasting, following, or evading. 

For example, use startIRFollow(0, 1) to follow another robot that is broadcasting on channels 0 and 1. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Stop Following

stopIRFollow() stops the following behavior. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Evade

startIREvade() sets the IR receivers to look for broadcasting robots on the same channel pair, from 0 to 7. Upon receiving messages from a broadcasting robot, the evader will adjust its heading to roll away from the broadcaster. When an evader loses sight of a broadcaster, the evader will spin in place to search for the broadcaster. The evader may stop if it is in the far range for a period of time so it does not roll too far away from the broadcaster. You can't use a channel for more than one purpose at time, such as sending messages along with broadcasting, following, or evading. 

For example, use startIREvade(0, 1) to evade another robot that is broadcasting on channels 0 and 1. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Stop Evading

stopIREvade() stops the evading behavior. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.

Send Message

sendIRMessage() sends a message on a given IR channel, at a set intensity, from 1 to 64. Intensity is proportional to proximity, where a 1 is the closest, and 64 is the farthest. For example, use sendIRMessage(4, 5) to send message 4 at intensity 5. You will need to use onIRMessage4(channel) event for on a corresponding robot to receive the message.  Also see the getLastIRMessage() sensor to keep track of the last message your robot received. You can't use a channel for more than one purpose at time, such as sending messages along with broadcasting, following, or evading. Supported with Sphero BOLT, BOLT+, and RVR/RVR+.