Walking the Grid: Robotics in CS 2

Slides:



Advertisements
Similar presentations
Reactive and Potential Field Planners
Advertisements

Lecture 7: Potential Fields and Model Predictive Control
Cpt S 223 – Advanced Data Structures Graph Algorithms: Introduction
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
Motion Planning for Point Robots CS 659 Kris Hauser.
RoboCell and Cell Setup
Sonar and Localization LMICSE Workshop June , 2005 Alma College.
CSE 380 – Computer Game Programming Pathfinding AI
GRAPHS AND GRAPH TRAVERSALS 9/26/2000 COMP 6/4030 ALGORITHMS.
Data Structure and Algorithms (BCS 1223) GRAPH. Introduction of Graph A graph G consists of two things: 1.A set V of elements called nodes(or points or.
Breadth-First Search David Johnson. Today Look at one version of Breadth-first search on a grid Develop Matlab version of BFS.
Data Structures and Algorithms Data Structures and Algorithms (CS210/ESO207/ESO211) Lecture 12 Application of Stack and Queues Application of Stack and.
Movement. Fixed Movement setLocation (x, y) Makes the crab move to a fixed cell x,y Relative Movement The functions: getX() getY() Fetch the x and y coordinate.
CS 206 Introduction to Computer Science II 03 / 06 / 2009 Instructor: Michael Eckmann.
The Turtle Laboratory Sequence Myles McNally LMICSE Workshop November , 2004 University of Mississippi.
CS 206 Introduction to Computer Science II 10 / 17 / 2008 Instructor: Michael Eckmann.
The Turtle Laboratory Sequence LMICSE Workshop August , 2006 Villanova University.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
The Turtle Laboratory Sequence LMICSE Workshop June , 2005 Alma College.
CS 206 Introduction to Computer Science II 10 / 15 / 2008 Instructor: Michael Eckmann.
Efficient Path Determining Robot RIT Computer Engineering Senior Design Project Jamie Greenberg Jason Torre October 26, 2004 A motorized robot will navigate.
Stacks, Queues, and Deques
Stacks, Queues, and Deques. A stack is a last in, first out (LIFO) data structure –Items are removed from a stack in the reverse order from the way they.
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
Stacks, Queues, and Deques
State-Space Searches. 2 State spaces A state space consists of –A (possibly infinite) set of states The start state represents the initial problem Each.
June 12, 2001 Jeong-Su Han An Autonomous Vehicle for People with Motor Disabilities by G. Bourhis, O.Horn, O.Habert and A. Pruski Paper Review.
SuperCorners. Problem The Corners sample robot has a simple strategy: first, move into a corner of the arena, and second sweep the gun back and forth.
Lab 3 How’d it go?.
Teaching Deliberative Navigation Using the LEGO RCX and Standard LEGO Components Gary R. Mayer, Dr. Jerry Weinberg, Dr. Xudong Yu
Fundamentals of Python: From First Programs Through Data Structures Chapter 14 Linear Collections: Stacks.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
Autonomous Robot Project Lauren Mitchell Ashley Francis.
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
© Jalal Kawash 2010 Introduction Peeking into Computer Science 1.
ICS 145B -- L. Bic1 Project: Main Memory Management Textbook: pages ICS 145B L. Bic.
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
CS1020 Lab 1 Discussion.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
“Planning is bringing the future into the present so that you can do something about it now.” – Alan Lakein Thought for the Day.
Graphs. Made up of vertices and arcs Digraph (directed graph) –All arcs have arrows that give direction –You can only traverse the graph in the direction.
Collection Classes Eric Roberts CS 106B January 14, 2013 (Part 1: Vectors, Grids, Stacks, and Queues)
Graphs – Part II CS 367 – Introduction to Data Structures.
yG7s#t=15 yG7s#t=15.
Graphs David Johnson. Describing the Environment How do you tell a person/robot how to get somewhere? –Tell me how to get to the student services building…
Where’s the title? You gotta search for it!. PotW Solution String s = new Scanner(System.in).next(); int[] prev = new int[s.length() * 2 + 2]; Arrays.fill(prev,
1 Stacks (Continued) and Queues Array Stack Implementation Linked Stack Implementation The java.util.Stack class Queue Abstract Data Type (ADT) Queue ADT.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Path Planning Based on Ant Colony Algorithm and Distributed Local Navigation for Multi-Robot Systems International Conference on Mechatronics and Automation.
Programming for Art: Arrays – 2D ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 16 Fall 2010.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Flood fill algorithm Also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array, When applied.
Queues.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Maze Implementation, Analysis and Design to find Shortest Paths
Data Structures and Algorithms for Information Processing
Path Planning in Discrete Sampled Space
Stacks, Queues, and Deques
Queues.
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Path Planning in Discrete Sampled Space
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Presentation transcript:

Walking the Grid: Robotics in CS 2 LMICSE Workshop June 14 - 17, 2005 Alma College

Presentation Outline Overall Goals Occupancy Grids Project 1: Random Walk (and Back) Rotation sensors and the RotationNavigator Class Project 2: Path Planning using Wavefront Propagation Propagation using a modification of breadth-first search Traveling the path

Overall Goals Create engaging projects that: introduce AI themes in a CS 2: robotic systems graph searching algorithms (without the graph) occupancy grids and path planning use basic user defined data structures like stacks and queues reinforce material learned in CS 1 such as classes and inheritance two dimensional arrays exceptions

Occupancy Grid An occupancy grid is a discrete grid that represents the environment. Each cell in the grid is either occupied (part of an obstacle). empty (part of free space). If any part of an obstacle is in a grid cell, then the cell is considered to be occupied. Grids representing real world environments are often fine grained (cells representing 4” to 6” square area).

Occupancy Grid Example A 14 by 8 grid Black figures are the obstacles Gray areas are the occupied cells

Limitations of Occupancy Grids If it is fine grained, an occupancy grid will use large amounts of memory. a problem on the RCX! If course grained, environmental features may be lost. e.g., narrow passageways. Despite these limitations, occupancy grids are often used in mobile robot path planning solutions.

Project 1: Random Walk (and Back) The robot goes for a random walk on an occupancy grid containing no obstacles. Then retraces its steps back to the starting point. Basic strategy is to use a stack: At each point the robot can move one cell north, east, south, or west (if legal). On the way out, push the directions traveled onto the stack. On the way back, pop the stack and travel in the opposite direction.

Project 1: Overall Architecture

Project 1: The Grid Walker Class The heart of this project is the definition of the GridWalker class. It contains a constructor that specifies the grid size and the starting point of the robot a goto method that takes as a parameter a grid location and causes the robot to move from its current grid position to that location convenience methods north, east, south, and west that move the robot one cell in the respective direction.

Project 1: Grid Walker Implementation Three possibilities Implement the grid walker directly, using timing for distances and turns this is like our CS 1 lab 10: Navigation but timing depends on battery strength so is inexact over time Use one of the two LeJOS navigation classes Timed Navigator: same problem as above Rotation Navigator: this is the ticket! but requires two rotation sensors

The Rotation Sensor Thread an axle through the sensor One revolution of the axle is 16 clicks of the sensor So it can measure a changes in angle of 22.5 degrees Which is why it is also known as an angle sensor A Rotation Sensor

Mounting Rotation Sensors Here is a solution that is a simple modification of the basic Roverbot: Rear View of Roverbot Chassis

The LeJOS Rotation Navigator Class (1) Rotation Navigator implements the Navigator interface Important Navigator methods: public void gotoPoint(float x, float y) Rotates the RCX robot towards the target point and moves the required distance public float getX() Returns the current x coordinate of the RCX. public float getY() Returns the current y coordinate of the RCX public float getAngle() Returns the current angle the RCX robot is facing

The LeJOS Rotation Navigator Class (2) assumes differential drive, with rotation sensors (encoders) for the left and right sides in sensor ports 1 and 3. the constructor: public RotationNavigator(float wheelDia, float AxleWidth, float ratio) the diameter of a wheel the distance from the center of the left wheel to the center of the right wheel the ratio of encoder revolutions to axle revolutions

Project 1: Grid Walker Implementation (1) Define GridWalker to extend RotationNavigator Have instance variables for initial grid position (x and y) current grid position (x and y) the number of columns and rows in the grid the size of a grid cell (assume it is square) The constructor is passed this information, plus the information the RotationNavigator class needs

Project 1: Grid Walker Implementation (2) import josx.robotics.*; public class GridWalker extends RotationNavigator { int currentH, currentV, initialH, initialV; int dimensionH, dimensionV; int cellSize; public GridWalker(int cH, int cV, int dimH, int dimV, int cSize, float wDia, float wBase, float ratio) { super(wDia, wBase, ratio); initialH = currentH = cH; initialV = currentV = cV; dimensionH = dimH; dimensionV = dimV; cellSize = cSize; } The beginning of the class definition and the constructor

Project 1: Grid Walker Implementation (3) In implementing the the goto method: need to check that the new location is legal (i.e., in the grid) if not, throw an exception (optional, but a good opportunity to reinforce the use of programmer defined exceptions) need to convert grid locations to absolute locations RotationNavigator assumes the robot starts at 0,0 with an orientation of 0 degrees GridWalker allows the programmer to specify any cell as the starting location, but still assumes orientation of 0 degrees

Project 1: Grid Walker Implementation (4) public void gotoCell(int h, int v) throws OutOfBoundsException { if (h >= 0 && h < dimensionH && v >= 0 && v < dimensionV) { gotoPoint(gridHToPoint(h), gridVToPoint(v)); currentH = h; currentV = v; } else throw new OutOfBoundsException(h, v); } private float gridVToPoint(int n) { return (n - initialV) * cellSize; private float gridHToPoint(int n) { return (n - initialH) * cellSize; The goto method and helpers

Project 1: Remaining Details Add the north, east, south, and west methods to the GridWalker class Implement a stack of ints (or Objects - Integers) Then in the main class First (random walk) Generate a series of random ints between 0 and 3 Travel in that direction and push on stack Second (travel back) Pop the stack until empty, traveling in the appropriate direction

Project 2: Path Planning using Wavefront Propagation Design a program that will move the robot from a starting point to a goal point using the shortest possible path navigating around obstacles assume the robot can only move north, east, south, or west (Manhattan movement). Use the GridWalker class for movement So main problem is finding the path

Wavefront Propagation (1) Image a wave moving out from the goal cell. When the wave first reaches each of the other cells, it is labeled with the time it took to reach it. The wave moves Manhattan

Wavefront Propagation (2) If there are occupied cells, the wavefront simply flows around them.

Wavefront Propagation (3) The path from any cell to the goal is implicit in the grid labels: Until at the goal, move to an adjacent cell with a “smaller” label There may be many different equal length paths

Wavefront Propagation Implementation (1) The basic approach for propagating the wave is breath-first: Initialize the value of empty locations in the grid to -1, occupied locations to high values Implement a queue of points Initialize the queue with the goal point, and set that point’s value to 0 Then while the queue is not empty Dequeue a point (the current point) For each of its four neighbors If the neighbor value is -1 Set its value to the value of the current point + 1 Enqueue that point

Wavefront Propagation Implementation (2) public void setValues (Queue q, int [][] grid) { q.enqueue(new Point (goalX, goalY)); grid[goalY][goalX] = 0; while ( !q.empty() ) { Point currentP = (Point) q.dequeue(); int x = currentP.x; int y = currentP.y; int newX = x+1; // go east if (newX < grid[y].length && grid[y][newX] == -1) { grid[y][newX] = grid[y][x] + 1; q.enqueue(new Point(newX,y)); } // also need cases for the other three directions The base method for setting the wavefront values

Wavefront Propagation Implementation (3) public void travel () { int curX = startX; int curY = startY; while (curtX != goalX || curY != goalY) { int curValue = grid[curY][curX]; if (curX+1 < grid[0].length && grid[curY][curX+1] == curValue - 1) curX = curX + 1; // move to the east else // cases for the other three directions robot.goto(curY, curX); } Making the robot move to the goal location

Hands-on Activities Implement the GridWalker class and do a random walk Complete Project 1 - Random Walk and Back Complete Project 2 - Wavefront Propagation (well, maybe when you get back home!)