From FIRE Wiki
This multi-robot project demonstrates communication and coordination between 2 NXT robots to accomplish a task. Two NXT robots with light sensors use line-following to navigate around a closed path. The robots use encoders to measure the distance they have traveled. When the robots collide, they transmit their measured distances (exchange data) and calculate and display the total perimeter of the path. This multi-robot project demonstrates how robots can share a task and combine results to improve efficiency and complete a task more quickly.
Topics covered in this project:
- Use of touch sensor and light sensor interfacing and calibration.
- Use of motor encoders and understanding mathematical and mechanical relationship between encoder counts and robot motion.
- Construction and building techniques.
- Transmitting and Receiving Data from an RS-485 Device (NXTBee)
- Using External Libraries
- Formatting strings and converting strings to integers
Note: The concepts outlined in this lesson are geared towards an intermediate user of ROBOTC and C Programming languages. Students should be comfortable with all material covered in the Teaching ROBOTC for MINDSTORMS curriculum before jumping into any Multi-Robot communication lessons.
- Remember when using Multi-Robot communications to always start the robot that is the receiver first. Otherwise, the receiving robot will not be listening when the sending robot broadcasts it's message.
- In this lab it is not necessary to start the robots at exactly the same time. They do not communicate until their touch sensors collide.
Hardware and Software Required
- Touch/Light sensor attachments for both robots Building Instructions (PDF)
- Each of the 2 NXT robots should be equipped with a light sensor and a touch sensor
- Both robots should have the same drive system and wheels.
- An NXTBee radio should be connected to sensor port 4 of each robot. The radios on each robot should be paired so that there is communication.
- The two robots should be placed back-to-back (facing opposite directions) on the path. The path should be closed and should allow the robots to collide head on.
- Both robots are programmed to follow a line until the touch sensor is activated (collision), at which time the robots will stop. At that point, the robot designated as Robot A (master) will send its recorded encoder distance to the robot designated as Robot B (slave). When Robot B (slave) receives the encoder data from Robot A, it will then send its encoder data back to Robot A. After this step, both robots have 2 sets of encoder data. Each robot performs an addition operation on the data and each robot computes and displays the total encoder counts. This total encoder count is related to the total perimeter traversed by both robots. Also, take into consideration the starting and final positions of the robots and the effects of line-following to determine actual lengths.
- There are 2 separate programs for this laboratory. One program is for Robot A (master) which initiates the communication, and the other program is for Robot B (slave). Both robots are physically the same and it doesn’t matter which robot is designated A or B. Both robots use the same algorithm for following the line. The robots can be started sequentially in any order.
Robot A Source Code
- Download - Perimeter Robot A
Robot B Source Code
- Download - Perimeter Robot B
Follow-up Projects and Discussion Questions
- Modify the path configuration and consider various geometric shapes. Experiment. (Note: path shapes must allow robots to collide head-on). Compare data collected by robots to theoretical results.
- Convert encoder counts to actual distance. Display total perimeter (path length) in physical units (inches, cm) and display.
- Replace wheels/tires with wheels of a different diameter on Robot A and/or Robot B robot. How does this impact the encoder readings? How would the code need to change?
- How do the starting positions of the robots and the final positions of the robots affect the total path length?
- Extend this demonstration so that the total path distance is displayed on a 3rd NXT robot screen which might be located a distance from the path-following robots (remote sensing). What is the advantage of this feature?
- Does is matter if the robots are following the right edge of the black line versus the left edge? Make a prediction, then test.
- Does the speed of the robots affect the total distance? Try it. Can one robot be moving faster than the other robot? What are your predictions? Experiment and test.
- Create, test, demonstrate and share your own challenge or application based on this technology.
- What are some real-world applications of this technology?