Robots for the Kid in All of Us GScomEngineering Fall 2016 Nikhil Nanivadekar Donald Raab Introductions JavaOne 2016 Add the latest photo Introductions JavaOne 2016 Agenda Robot videos ID: 769862
Download Presentation The PPT/PDF document "Robots for the Kid in All of Us" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Robots for the Kid in All of Us GS.com/EngineeringFall, 2016Nikhil NanivadekarDonald Raab
Introductions – JavaOne 2016 Add the latest photo
Introductions – JavaOne 2016
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
Robot Videos
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
EV3 Programmer App EV3 Programmer App distributed by LegosVisual and graphical programming interfaceAvailable at Mindstorms website
Lejos Runs standard Java Virtual machineDoes not run Lego softwareWrite code similar to a standard Java projectBetter motor control, faster processing, open source
Robo4J Sits on top of LejosFramework focused on asynchronous events/tasksMore information at Robo4J website
Third Party Libraries Lejos is a Java Virtual MachineEasy integration with third party librariesUpload jars to EV3 and reference on classpathRun similar to a standard Java project
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
Dijkstra’s Algorithm Find the least cost path from source to all nodesEach node has cost for traversalLeast cost path can be a longer pathConceived by Edsger W. DijkstraSource: Wikipedia(Dijkstra’s Algorithm)
A* Algorithm Extension to Dijkstra’s AlgorithmAdd a heuristic to guide the program towards the goalHeuristic can be anything (distance, time, etc.)Algorithm functions:Dijkstra : f(n) = c(n) c: cost functionA* : f(n) = c(n) + h(n) h: heuristic function
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
Problem Statement Solve the mazeMotion in x direction costs 1x the absolute distanceMotion in y direction costs 2x the absolute distance
Graph Use RGB data of mazeRed: TraversableBlue: ObstacleForms an adjacency matrix of x, y co-ordinatesUse adjacency matrix, color data to get nodes
Graph Store node, color data in a MutableObjectIntMappublic class Point{ private final int x ; private final int y ; public Point( int x , int y ) { this . x = x ; this . y = y ; } } MutableObjectIntMap < Point> GRAPH = new ObjectIntHashMap<>();GRAPH.put(new Point(0, 0), 1);
Successors Find successorspublic static SetIterable<Point> getSuccessors(Point point ) { if ( GRAPH .get ( point ) > 1 ) { MutableSet < Point > successors = Sets . mutable .withInitialCapacity ( 4 ); if ( GRAPH .get ( negativeX ) > 1 ) { successors.add (negativeX); } ... return successors; } return Sets. immutable.empty();}
Cost Function public static int getCost(Point point1, Point point2 ) { int xCost = Math . abs ( point1 . getX () – point2 .getX()); int yCost = 2 * Math . abs ( point1 . getY () – point2 . getY ()); return xCost + yCost ;}
Prioritization public static Point getNodeToVisit( Point point, SetIterable < Point > verticesToSearch ) { return verticesToSearch .minBy ( each -> vertexCostMap .get ( each )); } vertexCostMap : Map of node to cost to visit Initialized with all node costs to be Integer . MAX_VALUE Each time node is visited; update with least cost to visit
Path MutableStack<Point> path = Stacks.mutable.empty(); boolean isPathComplete = false ; while (! isPathComplete ) { if ( start .equals ( path.peek ())) { isPathComplete = true ; } else { path.push ( nodeBackpointerMap .get ( path.peek ())); }}return path;
Path: Dijkstra’s
Path: A* Heuristic = |x endpoint – x point2 | + | y endpoint – y point2 |
Path: A* Heuristic = |x endpoint – x point2 | + | y endpoint – x point2 |
Motion Uninterrupted Path comprised of 226 nodesRobot moves node to node, pausing 225 timesHow to make robot move smoothly?
Motion Uninterrupted Path comprised of 226 nodesRobot moves node to node, pausing 225 timesHow to make robot move smoothly?Flatten the path during motion by peeking in the futureCheck if the next next node has the same headingSame heading: Mark it to be flattenedDifferent heading: Compute the angle the robot needs to turnHence, achieving motion uninterrupted
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
JRE vs Compact Profiles Stripped down version of JRE into subsetsSource: Compact Profiles Overview
Performance Comparison Performed on a standard Lego EV3 Mindstorms running Lejos 0.9.0-beta Task Compact2 (Time in s) Full JRE (Time in s) EV3 start-up 80 80 Program execution start-up 13 15 Graph initialization 22 22 Dijkstra’s algorithm 110 115 A* algorithm 49 54
Empirical Observations Does it stop mid-execution?Is the performance consistent?What about the jar sizes?What about the memory footprint?
Agenda Robot videosJava vs EV3 Programmer AppDijkstra’s and A* Algorithm at a glanceDijkstra’s Algorithm on EV3JRE vs Compact ProfilesDemos
Learn more at GS.com/Engineering © 2016 Goldman Sachs. This presentation should not be relied upon or considered investment advice. Goldman Sachs does not warrant or guarantee to anyone the accuracy, completeness or efficacy of this presentation, and recipients should not rely on it except at their own risk. This presentation may not be forwarded or disclosed except with this disclaimer intact.