From FIRE Wiki
Jump to: navigation, search


This lab uses basic multi-robot sensing to reinforce basic geometry. In this lab, we will be using two Arduino robots sense a light source from two different angles, and consolidate information to locate the source. We will be using two Xbee Modules to communicate between the robots.

This lab’s purpose is to learn about basic stereo vision techniques, using triangles. One of the robots will sense the baseline of the triangle and one angle (interior or exterior) of the triangle. The other robot will sense another angle to form the triangle. Passing this information wirelessly, one or both robots should then be able to figure out where the light source is in relation to itself.

Hardware and Software Required

Project Files

Teacher Notes

The concepts outlined in this lesson are geared towards a more intermediate to advanced user of ROBOTC and C Programming languages. This lesson will touch on a number of advanced topics that have not been covered in our curriculum before.

  • Sending Messages Over a Serial Connection (XBee)
  • Receiving Data from an RS-485 Device (NXTBee)
  • Receiving Data from a Serial-Based Sensor
  • Multitasking in ROBOTC
  • Working with Internal Character Buffers (Serial Ports/RS-485)
  • Using External Libraries
  • Converting Strings to Integers
  • Parsing Delimited Text
  • Using Trig Functions in ROBOTC

Students should be comfortable with all material covered in the Teaching ROBOTC for MINDSTORMS curriculum before jumping into any MultiRobot communication lessons. This lesson will also require students to be able to construct simple circuits. Students will be required to connect various sensors up to power supplies on the Arduino system using a breadboard. Soldering is required for this lesson, and students should express care when working with the Arduino as incorrect wiring may render your Arduino non-functional.


Setup and Wiring

The first part of experiment is to setup two arduino based robots. Each robot will have these sensors:

  • Sparkfun SerLCD Serial LCD Screen (Optional)
  • Sparkfun XBee Explorer + Xbee Module
  • 1 Standard HS-311 Servo
  • 1 Photoresistor

In addition, one of the two robots will have:

  • VEX Robotics Ultrasonic Rangefinder

The design of our robot can be any stable base, as the robot bases will not move. Mount each photoresistor to a servo such that when the servo is centered, the sensor points along the long axis of the servo. Cover each photoresistor with a short (~0.5 inch) section of straw with electric tape around the straw. On one robot, mount the ultrasonic rangefinder so that it points 90 degrees away from the centered photoresistor.

Solder long wires on to each lead of the two photoresistors.

On your breadboards, connect the ultrasonic sensor (on one robot), servo, and both sides of the photoresistor to non-overlapping locations.

Connect the regulated power (5V) and ground (GND) pins from the Arduino to the two outside rails on your Breadboard. Connect from the outside rails to all of the Black and Red ports on the servos and ultrasonic rangefinder. One of the leads for the photoresistor should connect to 5V.

The next step is to connect the signal wires of each device the Arduino. For our lesson, the wires will look as follows: Ultrasonic Output - dgt7 Ultrasonic Input - dgt6 Servo - dgt9 Other end of photoresistor - alg0

With the servos and sensors are connected, we can connect our serial devices.

The Xbee Explorer/Radio is pretty easy to connect. It only requires 4 wires – 5V, Ground, Serial Out, Serial In. Remember serial devices can be tricky because of the labeling of the port directions – In/Out can mean different things depending on the unit:

  • Arduino Serial 3 RX -> Xbee Explorer Serial Out
  • Arduino Serial 3 TX -> Xbee Explorer Serial In

The Sparkfun SerLCD is even easier to connect. It only requires 3 wires – 5V, Ground, Serial In – because the LCD can only receive data, not send data.

  • Arduino Serial 1 TX -> SerLCD Serial In

Programming – Arduino

Our goal with the Arduino is to have our Arduino scan for the highest light reading using the servo to pan the photoresistor. The information collected from this operation, along with the ultrasonic data should be transmitted using the Xbees, and one or both robots should calculate (and display) the distance to the light source.

Experiment Setup

Triangulation lab.png

NXT-only build

Tri build.jpg

Arduino Sourcecode

Please Note: This code is under development to make it easier to use/understand. The final version of this code may not look like what is shown below.

NXT-only Master Code

Please Note: This code is under development to make it easier to use/understand. The final version of this code may not look like what is shown below.

NXT-only Slave Code

Please Note: This code is under development to make it easier to use/understand. The final version of this code may not look like what is shown below.