Skip to content

Commit

Permalink
Added all text content for pages found in old Newbie Guide. Need to e…
Browse files Browse the repository at this point in the history
…dit content to be appropriate for current competition and add images/diagrams
  • Loading branch information
tguyenn committed Jul 15, 2024
1 parent 96d2876 commit 2dcbd4e
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,26 @@ title: Color Sensor
nav_include: true
parent: Sensors and Actuators
nav_order: 1
---
---

# Color Sensor UNEDITED
The TCS34725 ordered from Adafruit will allow you to navigate the Dance Challenge. By sensing the color of the tile you are on, your robot can waltz across the dance floor to victory, racking up those sweet combos!

## How it Works
The RGB sensor uses the RGB color space to represent the color that it sees. In our case, it provides the data in integer values of 0-255, represented in 8 binary bits. We will grab that data using a communication protocol called I2C, which is used in many electrical devices. The specific I2C implementation is found in RASware, but we’ve abstracted the hard logic for you already.

# INSERT DIAGRAM OF WIRED EXAMPLE HERE

## Programming
For this tutorial, we’re only going to be reading the RGB sensor values from the TCS34725. Make sure that your pins are correctly connected or otherwise you won’t receive the data!
Build and flash the program, and watch the output change as you hold the sensor to different colored objects!

# Extensions
Extensions
Now that you’ve completed this tutorial, let’s move to more advanced stuff!
For the checkpoint I’m Sorry, You May Be Color Blind, you need to classify various colors. Try to output a specific message on CLI when you read Red or Blue or other colors.
Try to threshold a level of error for your sensor and think about the following questions.
* Do the values change under different lighting?
* Different distances?
* What about various shades of red? Is red one specific RGB value?
If you have a moving base, try to drive in a certain direction based on color. How about going right on a red tile?
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ title: IR Sensor
nav_include: true
parent: Sensors and Actuators
nav_order: 1
---
---

# IR Sensor (UNEDITED)

A necessary component for any challenge that utilizes walls, analog IR sensors are a staple of Robotathon. This particular sensor is the GP2Y0A21, and detects distances from 10 to 80 cm.

## How it Works
IR distance sensors emit long wavelength (700 nm - 1 mm) light towards a surface. The light bounces off objects it hits, and then enters a proximity sensor. The output is then transformed into a voltage that can be fed into the ESP32 and read.

## Interfacing
There are 3 pins (red, black, white) to the device as seen in the top right picture, associated to Power, Ground, and Output Signal, respectively. For testing the distance sensor, let’s use the analog pin, pin 27, as the signal pin. Hook up the circuit as follows.

## Programming
The following program will allow you to read values from the IR sensor in a loop. After you build and flash the program, you should see the values in the UART change as you move it towards and away from an object.

## Extensions
You received values from the sensor, but do they mean anything? The next step for the IR sensor is translating and thresholding it. Take a look at the above graph. There is a strong linear relationship between your signal value and the inverse of the distance away from the object. It’s your job now to code a function that returns an accurate distance given a voltage input value. After that, your team needs to threshold the data. When do the values become inconsistent (too close or too far)? What do you do with your robot when that happens?
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,28 @@ title: Line Sensor
nav_include: true
parent: Sensors and Actuators
nav_order: 1
---
---

# Line Sensor (UNEDTIED)
A necessary component for any challenge that requires your robot to follow a line. This one is the QTR-8A Reflectance Sensor Array and uses IR transmitters and receivers on it to detect lines.

## How it Works
The line sensor is made up of an array of 8 IR LED/phototransistor pairs, each take an analog reflectance reading by timing how long it takes the output voltage to decay due to the phototransistor..

## Interfacing
Alongside connecting Vcc and ground to the main board (Like for the IR sensor), there are 8 sensors that you can use to collect data by connecting to the analog input pins on the main board. Choose the ones you want to use wisely since the board has limited input pins.

## Programming
The following program will allow you to continuously read a general position value of the sensor across a line. After you build and flash the program, you should see the values in the UART change as you shift the line across the
different sensors.

TIP: always run the calibrate function (i.e. hold a line of the color you’re sensing under all the sensors during set up) to ensure consistent and accurate results.

## Extensions
You received values from the sensor, but do they mean anything?
How does the position value change as you place your line beneath different sensors, and how can you control that?
Is there an easier way to quantify the “change” when the car is veering off the line?
What do you do with your robot when that happens? I.e. adjusting movement
Consistency in data collection is key for calibration


Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,36 @@ title: Sensor Integration
nav_include: true
parent: Sensors and Actuators
nav_order: 1
---
---

# Sensor Integration

Help! How do we put everything together?
Now that you’ve completed several checkpoints and have probably gone through the interfacing tutorials, you and your team are probably wondering how to put all these various parts together. How do we merge RGB sensor data with motor movement? What happens when you encounter a nonexistent wall with your line sensors?
Unfortunately, there are no easy answers to these questions. Your best bet is to experiment with your intuitions. An example is moving along a curved line. A starting series of intuitions could be:

* I want to keep my robot centered on the line.
* My line sensor should probably also be centered on the line.
* If my middle line sensors are thresholding a line, and my side line sensors aren’t, then I am probably centered on the line.
* If not, then I am off the line and should correct slightly by:
* Driving one wheel faster than the other.
* Stopping and rotating the robot until I find the line again.
* Etcetera …

Test each intuition to see if it makes sense! Eventually, your intuitions will build a representative model of the world and how to traverse it. This is important because a great deal of robotics revolves around this concept. Think about autonomous cars. They need to build an internal world, replete with virtual pedestrians, vehicles, stop signs, and more, as well as make decisions based on encountering them.

Building and acting upon your model of the world can be hard. To help, we’ve provided a handy diagram on the right that you can use to structure your program. Within the loop is the important part. We encourage partitioning your code into three states or events. A simple example is provided below.

1. The IR sensors says that there is a wall to your front and left.
1. Update the robot’s memory of the maze with these newfound walls.
1. Since there is a wall to the front and the left, let’s turn right with our motors.

We leave the implementation of the example as an exercise for the reader.
Finally, we would also like to emphasize writing clean and readable code. Clean code helps both your team and the mentors by making it easier to debug.

A convention guide can be found at http://www.cs.umd.edu/~nelson/classes/resources/cstyleguide/.

# Extensions
* How will your robot cope with multiple challenges?
* How will you reset your robot after completing a challenge?
* What if you receive sensor data that you’ve not encountered before?

0 comments on commit 2dcbd4e

Please sign in to comment.