Postby badri86 » Wed Jul 03, 2019 1:30 pm
The range-and-bearing system allows robots to perform localized communication. Localized communication means that a robot, upon receiving data from another robot, also detects the position of the sender with respect to its local point of view. It is important to notice that the range-and-bearing system is not like WiFi. First, because two robots can exchange data only if they are in direct line of sight - if an object is between two robots, the robots can't communicate. Second, because robots that send data can only broadcast it in a limited area - you can't pick who you talk to as you would with an IP address. Third, the robots can exchange only 10 bytes of data.
To set the data to broadcast, use set_data(). This function accepts input in two forms. You can write set_data(idx, data), and this means that you set the idx-th byte to the value of data. data must be a number in the range [0,255]. Alternatively, you can write set_data(data), where data must be a table containing exactly 10 numbers in the range [0,255].
At each time step, a robot receives a variable number of messages from nearby robots. Each message is stored in a table composed of data (the 10-bytes message payload), horizontal_bearing (the angle between the robot local x axis and the position of the message source; the angle is on the robot's xy plane, in radians), vertical_bearing (like the horizontal bearing, but it is the angle between the message source and the robot's xy plane), and range (the distance of the message source in cm).