Lecture 10 Sensors.

Slides:



Advertisements
Similar presentations
Add and Use a Sensor & Autonomous For FIRST Robotics
Advertisements

Navigating the BOE-BOT
BEGINNER EV3 PROGRAMMING Lesson
Engineering H193 - Team Project Gateway Engineering Education Coalition Lab 3P. 1Spring Quarter IR & Servos Lab 3.
The Turtle Laboratory Sequence Myles McNally LMICSE Workshop November , 2004 University of Mississippi.
The Turtle Laboratory Sequence LMICSE Workshop June , 2005 Alma College.
IR SENSORS AND ENCODERS. LCDs Timothy Friez Class # 2.
Embedded Programming and Robotics Lesson 8 Light Sensors and Temperature/Humidity Light Sensors1.
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
BEGINNER EV3 PROGRAMMING Lesson
Java for Robots How to program an NXT robot with a Java Brain Bert G. Wachsmuth Seton Hall University.
IntelliBrain-Bot An Introduction to Robotics and Java Programming.
Team Spot On! With Zebulon Clark Desiree And Earl.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 2.
ROBOTC for VEX On-Site Professional Development
LabVIEW Basics Review LabVIEW Robotics Fundamentals.
Today’s Agenda 1.Scribbler Program Assignment 1.Project idea due next class 2.Program demonstration due Wednesday, June 3 2.Attendance & lab pair groupings.
Sound, Touch Sensor, and Motors. Wheeled Vehicles Using the Pilot class: –Constructor Pilot(float wheelDiameter, float trackWidth,Motor leftMotor, Motor.
Session 12 Sensors and Timers. 3 Main Types of Robot Projects Command-Based Robot A more complicated project for more complicated robots Iterative Robot.
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Using Sensor Data and Port View.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4/Lab3.
EV3 Software EV3 Robot Workshop
ROBOTC Software EV3 Robot Workshop
BEGINNER FLL PROGRAMMING WORKSHOP BY DROIDS ROBOTICS & EV3LESSONS.
ROBOTC Software EV3 Robot Workshop Lawrence Technological University.
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Topics Covered: Touch Sensor.
MEH108 - Intro. To Engineering Applications KOU Electronics and Communications Engineering.
Introduction to Robots and the Mind - Programming with Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?
Introduction to Robots and the Mind - Sensors - Bert Wachsmuth & Michael Vigorito Seton Hall University.
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
Introduction to Programming in RobotC
By Sanjay and Arvind Seshan
VEX IQ Curriculum Smart Machines Lesson 09 Lesson Materials:
Array Lists and the Color Sensor
BEGINNER EV3 PROGRAMMING Lesson
BEGINNER EV3 PROGRAMMING Lesson
ROBOTC for VEX Online Professional Development
By Sanjay and Arvind Seshan
ROBOTC for VEX Online Professional Development
Touch Sensor.
Electrical Engineer Responsibilities
LEGO Robotics Ultrasonic Sensor
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
IMDL Summer 2007: RoBeDeS by David Ladolcetta.
IR & Servos Lab 3 Spring Quarter.
BEGINNER PROGRAMMING LESSON
Introduction to Robots and the Mind - Methods -
Sensors Training.
Sasha Popov November 16, 2018 iRobot Create.
BEGINNER EV3 PROGRAMMING Lesson
BEGINNER EV3 PROGRAMMING Lesson
Motors and Sensors Large Motor
BEGINNER PROGRAMMING LESSON
Holyoke Codes LEGO ROBOTICS
BEGINNER PROGRAMMING LESSON
EV3 Programming guide to “Following”
SENSORS.
Lego EV3 Mindstorms SW Programming Blocks.
CBC v2 Using the CBC.
Introduction to programming consistent results
BEGINNER PROGRAMMING LESSON
By Sanjay and Arvind Seshan
Coding Edbot Dream with Scratch
Compiled from various Internet sources Presented by Mr. Hatfield
Note Pages 7 – 10.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Lego MINDSTORMS EV3.
BEGINNER PROGRAMMING LESSON
Presentation transcript:

Lecture 10 Sensors

Objectives To learn the modes and interface for the remaining sensors. Touch sensor Gyro sensor Ultrasonic sensor Infrared sensor

Sensor API Setting up any of the sensors is similar to setting up the color sensor. Create an object for the sensor you are using. Create a SampleProvider object. Create an array to store the resulting sample. Call the fetchSample method from the SampleProvider to collect a sample. The differences are The type of the object to be created. The number of modes and their descriptions. The sample size and interpretation for each mode.

Touch Sensor The touch sensor is the simplest sensor – it is essentially a button. It only has one mode called “Touch”. The result of each sample is one floating point number. The value will be 0.0 if the button is not pushed and 1.0 when the button is pushed.

Touch Sensor Demo Here is code to sample the touch sensor 20 times. EV3TouchSensor ts = new EV3TouchSensor(SensorPort.S2); SampleProvider touch = ts.getMode("Touch"); float[] sample = new float[touch.sampleSize()]; for (int i = 0; i < 20; i++){ touch.fetchSample(sample, 0); System.out.printf("%d. %f%n", i, sample[0]); Delay.msDelay(250); }

Gyro Sensor The gyro sensor measures rotation around the axis shown on the top of the sensor. Counter clockwise rotation results in positive angles. Clockwise results in negative angles.

Gyro Sensor The gyro sensor has three modes. Rate – the rate of change of the angle, measured in degrees per second. Angle – the size of the angle Angle and Rate – returns both the angle and the rate (sample size is 2 floating point numbers).

Gyro Sensor The angles are measured for a zero angle that is set when the program initializes. This angle can be reset – making the current angle the zero point. It is a good idea to do this at the beginning of the program. The robot is often bumped or moved right at the beginning of a program. An EV3GyroSensor object has a reset method which is use to do this.

Gyro Sensor Demo The following is a program that assumes the following: Large motors are plugged into ports B and C Motor B is on the left and motor C is on the right. The gyro sensor is plugged into port 3. The program causes the robot to turn right to approximately 90 degrees (-90o). Note the advantages of using the rotation sensor. It is easier with no trial and error. If the robot is bumped or the wheels slip it is still possible to make the correct turn.

Gyro Sensor Demo import lejos.hardware.motor.*; import lejos.hardware.port.MotorPort; import lejos.hardware.port.SensorPort; import lejos.hardware.sensor.EV3GyroSensor; import lejos.robotics.SampleProvider; public class EV3TurnRight { public static void main(String[] args){ EV3LargeRegulatedMotor b = new EV3LargeRegulatedMotor(MotorPort.B); EV3LargeRegulatedMotor c = new EV3LargeRegulatedMotor(MotorPort.C); EV3GyroSensor gs = new EV3GyroSensor(SensorPort.S3); SampleProvider angle = gs.getMode("Angle"); float[] sample = new float[angle.sampleSize()];

Gyro Sensor Demo b.setSpeed(200); c.setSpeed(200); b.forward(); gs.reset(); angle.fetchSample(sample, 0); while(sample[0] > -90.0) b.stop(); gs.close(); b.close(); c.close(); }

Ultrasonic Sensor The ultrasonic sensor uses echolocation to determine its distance to objects. The sensor has two modes. Distance – measure the distance to an object in meters. Listen – listen for other ultrasonic sensors; 1 indicates the presence of an active ultrasonic sensor.

Ultrasonic Sensor Demo The following program uses the ultrasonic sensor plugged into port 4 and the two large motors plugged into ports B and C. The program will use the ultrasonic sensor to spin the robot when an object is NOT within 10 cm of the sensor. Start the robot with an object in front of the sensor – remove the object and watch it spin.

Ultrasonic Sensor Demo import lejos.hardware.motor.*; import lejos.hardware.port.MotorPort; import lejos.hardware.port.SensorPort; import lejos.hardware.sensor.EV3UltrasonicSensor; import lejos.robotics.SampleProvider; import lejos.utility.Delay; public class EV3Spin2 { public static void main(String[] args){ EV3LargeRegulatedMotor b = new EV3LargeRegulatedMotor(MotorPort.B); EV3LargeRegulatedMotor c = new EV3LargeRegulatedMotor(MotorPort.C); EV3UltrasonicSensor us = new EV3UltrasonicSensor(SensorPort.S4); SampleProvider distance = us.getMode("Distance"); float[] meters = new float[distance.sampleSize()];

Ultrasonic Sensor Demo distance.fetchSample(meters, 0); while(meters[0] < 0.1) b.forward(); Delay.msDelay(2000); b.stop(); us.close(); b.close(); c.close(); } Notice that the only thing the while loop does is repeatedly query the ultrasonic sensor for distance measurements.

Infrared Sensor The infrared sensor has two modes. Distance Seek In some ways the infrared sensor in distance mode is similar to the ultrasonic sensor in that it can estimate the distance to an object. The distance estimate is very rough and only works at close range (approximately 10 cm). The return value is in cm rounded to the nearest integer. If no object is detected the distance returned is infinity.

Infrared Beacon In the seek mode the IR sensor detects an infrared beacon. The beacon comes with the home edition. The beacon can send out a constant signal that can be located with the IR sensor. The beacon can also be used like a remote control to send messages that can be received by the IR sensor. The beacon can broadcast on one of 4 channels.

Infrared Sensor Seek Mode The sample size in seek mode is 8. It can detect 4 beacons simultaneously – one broadcasting on each channel. It measures the angle (in degrees) and the distance (in cm) to the beacon. The angles are measured from -25o to 25o with values increasing clockwise in the point-of-view of the sensor. An angle of 0 indicates the beacon is straight ahead. The format for the sample is [angle 1, distance 1, angle 2, distance 2, angle 3, distance 3, angle 4, distance 4] If no beacon is detected the distance is set to infinity.

getCommand Method The IR sensor can also receive commands from a beacon. int getRemoteCommand(int chan) chan is the channel of the beacon (1-4). The return values are as follows: TOP-LEFT BOTTOM-LEFT TOP-RIGHT BOTTOM-RIGHT TOP-LEFT + TOP-RIGHT TOP-LEFT + BOTTOM-RIGHT BOTTOM-LEFT + TOP-RIGHT BOTTOM-LEFT + BOTTOM-RIGHT CENTRE/BEACON BOTTOM-LEFT + TOP-LEFT TOP-RIGHT + BOTTOM-RIGHT

Homework Write a program which will have the robot drive up to a wall and stop when it gets within 5 cm. Modify your program to have the robot turn 90 when it gets within 5 cm of an obstruction. The gyro sensor might be helpful here. Write a program that attempts to solve a maze (made from 2x4 lumber) without touching the walls.