IR Team Proximity Detection
From FIRE Wiki
Two NXT robots equipped with IR seeker sensors and Xbee wireless devices will detect an IR ball (beacon) then perform calculations and communicate to decide which robot is closest to the IR ball (beacon). The closest robot will be instructed to drive up to the IR ball.
Topics covered include:
- Use of IR Seeker sensor interfacing and calibration.
- 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.
- To received the most accurate reading try to position the IR Seeker in a low position on the robot, or on the same plane as the ball.
Hardware and Software Required
- HiTechnic NXT IRSeeker V2 sensors - 2
- HiTechnic Infrared Electronic Ball (IR ball) - 1
- Robot A and Robot B should both be equipped with a front-facing IR Seeker sensor.
- Both robots should have the same drive system and wheels.
- The IR ball should be turned on and set to match the frequency of the settings in the code for each robot (we are using 600 Hz here).
- 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.
- Each robot should be initially setup facing the IR ball. Robot B should be started before Robot A.
- The goal of the master (Robot A) code is to use the IR seeker sensor to find the max intensity of the IR ball. The greater the intensity readig, the closer the IR ball is to the robot. Robot A will then wirelessly send a command to Robot B to get the intensity value from Robot B. Robot A will then compare the 2 intensity values (distances) and determine which robot is closest to the IR ball. If Robot A is closest, then Robot A will move forward (no message will be sent to Robot B). If Robot B is closest, then Robot A will send a command to Robot B to move forward.
- The goal of slave (Robot B) code is to use the IR seeker sensor to find the max intensity of the IR ball, and then wait for a command from Robot A to send this intensity value back to Robot A. when the request is received, Robot B will convert the intensity to a string message and send this string to Robot A where it will be decoded. Then Robot B waits to hear from Robot A about which robot is closest. If Robot B is closest, then Robot A will send a message to Robot B to move forward.
Robot A (Master) Source Code
- Download IR Proximity 2 Robots A
Robot B (Slave) Source Code
- Download IR Proximity 2 Robots B
Follow-up Challenge: Closest to IR ball with 3 robots
Challenge: Extend the code described above to find the closest robot (to the IR ball) among a total of 3 robots. Initially, each of the 3 robots will be positioned facing the IR ball at different distances from the IR ball. The master robot will now communicate with the 2 other robots, determine the closest robot and execute the appropriate commands to move the closest robot to the IR ball.
See the video below that demonstrates the 3 robot solution.
Follow-up Challenge Video (3 robots)
More Follow-up Projects and Discussion Questions
- Expand the code so that the closest robot moves forward and then makes contact or "kicks" the ball.
- What happens if the robots are not directly facing the IR ball? Experiment. Can you modify the code so that if 2 robots are the same distance, the robot which is facing the IR ball directly will be instructed to move?
- Modify the code so that the robot which is farthest away moves back away from the ball.
- What happens if Robot B (slave) is started before Robot A (master)? What do you predict? Test.
- Create, test, demonstrate and share your own challenge or application based on this technology.
- What are some real-world applications of this technology?