Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robots for the Kid in All of Us

Similar presentations


Presentation on theme: "Robots for the Kid in All of Us"— Presentation transcript:

1 Robots for the Kid in All of Us
GS.com/Engineering Fall, 2016 Nikhil Nanivadekar Donald Raab

2 Introductions – JavaOne 2016
Add the latest photo

3 Introductions – JavaOne 2016

4 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

5 Robot Videos

6 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

7 EV3 Programmer App EV3 Programmer App distributed by Legos
Visual and graphical programming interface Available at Mindstorms website

8 Lejos Runs standard Java Virtual machine Does not run Lego software
Write code similar to a standard Java project Better motor control, faster processing, open source

9 Robo4J Sits on top of Lejos
Framework focused on asynchronous events/tasks More information at Robo4J website

10 Third Party Libraries Lejos is a Java Virtual Machine
Easy integration with third party libraries Upload jars to EV3 and reference on classpath Run similar to a standard Java project

11 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

12 Dijkstra’s Algorithm Find the least cost path from source to all nodes
Each node has cost for traversal Least cost path can be a longer path Conceived by Edsger W. Dijkstra Source: Wikipedia(Dijkstra’s Algorithm)

13 A* Algorithm Extension to Dijkstra’s Algorithm
Add a heuristic to guide the program towards the goal Heuristic can be anything (distance, time, etc.) Algorithm functions: Dijkstra : f(n) = c(n) c: cost function A* : f(n) = c(n) + h(n) h: heuristic function

14 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

15 Problem Statement Solve the maze
Motion in x direction costs 1x the absolute distance Motion in y direction costs 2x the absolute distance

16 Graph Use RGB data of maze Red: Traversable Blue: Obstacle
Forms an adjacency matrix of x, y co-ordinates Use adjacency matrix, color data to get nodes

17 Graph Store node, color data in a MutableObjectIntMap
public 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);

18 Successors Find successors
public 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(); }

19 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; }

20 Prioritization vertexCostMap: Map of node to cost to visit
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

21 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;

22 Path: Dijkstra’s

23 Path: A* Heuristic = |xendpoint – xpoint2| + |yendpoint – ypoint2|

24 Path: A* Heuristic = |xendpoint – xpoint2| + |yendpoint – xpoint2|

25 Motion Uninterrupted Path comprised of 226 nodes
Robot moves node to node, pausing 225 times How to make robot move smoothly?

26 Motion Uninterrupted Path comprised of 226 nodes
Robot moves node to node, pausing 225 times How to make robot move smoothly? Flatten the path during motion by peeking in the future Check if the next next node has the same heading Same heading: Mark it to be flattened Different heading: Compute the angle the robot needs to turn Hence, achieving motion uninterrupted

27 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

28 JRE vs Compact Profiles
Stripped down version of JRE into subsets Source: Compact Profiles Overview

29 Performance Comparison
Task Compact2 (Time in s) Full JRE (Time in s) EV3 start-up 80 Program execution start-up 13 15 Graph initialization 22 Dijkstra’s algorithm 110 115 A* algorithm 49 54 Performed on a standard Lego EV3 Mindstorms running Lejos beta

30 Empirical Observations
Does it stop mid-execution? Is the performance consistent? What about the jar sizes? What about the memory footprint? Discuss these points live

31 Agenda Robot videos Java vs EV3 Programmer App
Dijkstra’s and A* Algorithm at a glance Dijkstra’s Algorithm on EV3 JRE vs Compact Profiles Demos

32 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.


Download ppt "Robots for the Kid in All of Us"

Similar presentations


Ads by Google