Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Robotics 101

Andrew Nesbitt
September 19, 2014

Robotics 101

Presented at Hackference 2.0.14

Andrew Nesbitt

September 19, 2014
Tweet

More Decks by Andrew Nesbitt

Other Decks in Technology

Transcript

  1. ROBOTICS 101

    View Slide

  2. ANDREW NESBITT

    View Slide

  3. MY ROBOT STORY

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. BEng Robotics & Automated Systems
    University of Plymouth

    View Slide

  8. View Slide

  9. Advanced Mathematics
    Mechanical Engineering
    Digital Electronics Analogue Electronics
    Computer Science
    Control Theory
    Neural Networking Microprocessor Design
    Playing with Robots
    LEARNING ROBOTICS

    View Slide

  10. Advanced Mathematics
    Advanced Mathematics
    Advanced Mathematics Advanced Mathematics
    Advanced Mathematics
    Advanced Mathematics
    Advanced Mathematics Advanced Mathematics
    Observing Robots behind glass
    LEARNING ROBOTICS

    View Slide

  11. Robotics was
    expensive,
    complicated
    and not fun

    View Slide

  12. APIs
    Open Source Hardware
    Smart phones
    Dynamic Programming Languages
    GitHub
    Mobile Internet 3D Printing
    2014

    View Slide

  13. robot
    /ˈrəʊbɒt/
    a machine capable of carrying out a
    complex series of actions automatically,
    especially one programmable by a
    computer.

    View Slide

  14. FICTIONAL ROBOTS
    ENTERTAINMENT ROBOTS

    View Slide

  15. INDUSTRIAL ROBOTS

    View Slide

  16. DOMESTIC ROBOTS

    View Slide

  17. MEDICAL ROBOTS

    View Slide

  18. HOBBY ROBOTS

    View Slide

  19. EDUCATIONAL ROBOTS

    View Slide

  20. MILITARY ROBOTS

    View Slide

  21. View Slide

  22. It's a UNIX system! I know this!

    View Slide

  23. LEGO

    View Slide

  24. EV3

    View Slide

  25. ROBOT RABBIT FEEDER

    View Slide

  26. !
    var Ev3 = require ("ev3-nodejs-bt");

    var Ev3_base = Ev3.base;


    var XboxController = require('xbox-controller');

    var xbox = new XboxController;


    var robot = new Ev3_base("/dev/tty.EV3-SerialPort");


    var maxAngle = 32768;

    var maxSpeed = 100;


    var speeds = { a: 0, b: 0, c: 0, d: 0 };

    View Slide

  27. !
    robot.connect(function(){

    robot.start_program(function(ev3){

    var setSpeed = function(){

    var output = ev3.getOutputSequence(speeds.a,speeds.b,speeds.c,speeds.d);

    ev3.sp.write(output);

    }


    setInterval(setSpeed, 100)


    xbox.on('left:move', function(position){

    var x = -(position.x / maxAngle)*-maxSpeed

    var y = (position.y / maxAngle)*-maxSpeed


    var left = y-x

    var right = y+x


    speeds.b = left

    speeds.a = right

    })


    xbox.on('a:press', function(){

    speeds.d = 100

    })


    xbox.on('a:release', function(){

    speeds.d = 0

    })

    });

    });


    View Slide

  28. View Slide

  29. View Slide

  30. github.com/andrew/node-ev3-robot

    View Slide

  31. github.com/clebert/ev3

    View Slide

  32. View Slide

  33. ARDUINO

    View Slide

  34. FIRMATA

    View Slide

  35. Cat Laser Toy

    View Slide

  36. Cat Laser Toy
    Rabbit
    |
    v

    View Slide

  37. Demo Time

    View Slide

  38. Demo Time

    View Slide

  39. Demo Time

    View Slide

  40. Demo Time

    View Slide

  41. Demo Time

    View Slide

  42. Demo Time

    View Slide

  43. Demo Time

    View Slide

  44. Demo Time

    View Slide

  45. Demo Time

    View Slide

  46. !
    var five = require("johnny-five"),

    board = new five.Board();


    function randomFromInterval(from,to){

    return Math.floor(Math.random()*(to-from+1)+from); 

    }


    board.on("ready", function() {

    var servoX = new five.Servo(10);

    var servoY = new five.Servo(9);

    var laser = new five.Led(8);


    laser.on()


    setInterval(function(){

    x = randomFromInterval(80, 120)

    y = randomFromInterval(95, 145)

    servoX.move(x)

    servoY.move(y)

    }, 400)

    })

    View Slide

  47. View Slide

  48. hobbytronics.co.uk/sparkfun-inventors-kit-v3
    Sparkfun
    Inventors
    Kit

    View Slide

  49. node-ardx.org

    View Slide

  50. hobbytronics.co.uk/zumo-robot-kit

    View Slide

  51. var five = require("johnny-five"),
    board = new five.Board();
    !
    var Zumo = function(){
    this.leftMotor = new five.Motor({
    pins: { pwm: 10, dir: 8 }
    });
    !
    this.rightMotor = new five.Motor({
    pins: { pwm: 9, dir: 7 }
    });
    !
    this.move = function(x,y){
    var left = y-x
    var right = y+x
    !
    if(left > 0){
    this.leftMotor.reverse(left)
    } else {
    this.leftMotor.forward(-left)
    }
    !
    if(right > 0){
    this.rightMotor.reverse(right)
    } else {
    this.rightMotor.forward(-right)
    }
    }
    }

    View Slide

  52. var XboxController = require('xbox-controller'),
    xbox = new XboxController;
    !
    maxAngle = 32768
    maxSpeed = 255
    !
    board.on("ready", function() {
    var zumo = new Zumo
    !
    var x = 0
    var y = 0
    !
    xbox.on('left:move', function(position){
    x = (position.x / maxAngle)*-maxSpeed
    zumo.move(x,y)
    })
    !
    xbox.on('lefttrigger', function(position){
    y = -position
    zumo.move(x,y)
    })
    !
    xbox.on('righttrigger', function(position){
    y = position
    zumo.move(x,y)
    })
    })

    View Slide

  53. View Slide

  54. AUTONOMOUS
    ROBOTS

    View Slide

  55. CONTROL LOOPS

    View Slide

  56. INPUTS
    !
    PROCESSING
    !
    OUTPUTS

    View Slide

  57. AUDIO, VISION, MOTION,
    TEMPERATURE, POSITION, DISTANCE,
    TOUCH, FORCE, MAGNETIC, LIGHT,
    VIBRATION, MOISTURE, PRESSURE,
    PROXIMITY, CHEMICAL, ELECTRICAL,
    COLOR AND MORE
    INPUT SENSORS

    View Slide

  58. WHEELS, GRIPPERS, ARMS, ROTORS,
    SERVOS, LIGHTS, SOUNDS,VISUALS,
    SWITCHES, RELAYS
    OUTPUTS

    View Slide

  59. ELECTRICAL CIRCUITS,
    MICROCONTROLLERS,
    COMPUTERS,
    SERVER FARMS
    PROCESSING

    View Slide

  60. View Slide

  61. View Slide

  62. npm install cylon

    View Slide

  63. var Cylon = require('cylon');
    !
    Cylon.robot({
    connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/cu.Sphero-GGP-AMP-SPP' },
    device: { name: 'sphero', driver: 'sphero' },
    !
    work: function(my) {
    var color = 0x00FF00,
    bitFilter = 0xFFFF00;
    !
    after((1).seconds(), function() {
    console.log("Setting up Collision Detection...");
    my.sphero.detectCollisions();
    my.sphero.setDataStreaming(['locator', 'accelOne', 'velocity'], { n: 200, m: 1, pcnt: 0,});
    my.sphero.setBackLED(255);
    my.sphero.setRGB(color);
    my.sphero.stop();
    every(5..seconds(), function() {
    my.sphero.roll(128, Math.floor(Math.random() * 360));
    });
    });
    !
    my.sphero.on('data', function(data) {
    app.io.broadcast('draw', {color:color.toString(16), x:data[0], y:data[1]})
    });
    !
    my.sphero.on('collision', function(data) {
    color = color ^ bitFilter;
    my.sphero.setRGB(color);
    my.sphero.roll(128, Math.floor(Math.random() * 360));
    app.io.broadcast('collision', {color:color.toString(16)})
    });
    !
    }
    }).start();

    View Slide

  64. // Input
    my.sphero.on('collision', function(data) {
    // Processing
    color = color ^ bitFilter;
    direction = Math.floor(Math.random() * 360)
    // Output
    my.sphero.roll(128, direction);
    my.sphero.setRGB(color);
    app.io.broadcast('collision', {color:color.toString(16)})
    });
    !
    !
    !
    // Input
    my.sphero.on('data', function(data) {
    !
    // Processing
    if(Math.abs(data[0]) > 1000 || Math.abs(data[1]) > 1000) {
    // Output
    my.sphero.roll(128, Math.abs(direction - 180));
    }
    !
    // Output
    app.io.broadcast('draw', {color:color.toString(16),
    x:data[0], y:data[1]})
    });

    View Slide

  65. var express = require('express.io')
    var app = express().http().io()
    !
    app.get('/', function(req, res) {
    res.sendfile(__dirname + '/client.html')
    })
    !
    app.listen(7076)

    View Slide




  66. <br/>App = {}<br/>App.socket = io.connect()<br/>!<br/>var startX = 950;<br/>var startY = 500;<br/>!<br/>var previousX = 950;<br/>var previousY = 500;<br/>!<br/>App.draw = function(data) {<br/>App.ctx.beginPath()<br/>App.ctx.moveTo(previousX, previousY);<br/>App.ctx.lineWidth = 5;<br/>App.ctx.lineTo(data.x+startX,data.y+startY)<br/>App.ctx.strokeStyle = "#" + data.color<br/>App.ctx.stroke()<br/>previousX = data.x+startX;<br/>previousY = data.y+startY;<br/>}<br/>!<br/>App.socket.on('draw', App.draw)<br/>!<br/>$(function() {<br/>App.ctx = $('canvas')[0].getContext("2d")<br/>})<br/>

    View Slide

  67. View Slide

  68. View Slide

  69. View Slide

  70. View Slide

  71. ARDRONE AUTONOMY

    View Slide

  72. PID CONTROLLER
    KALMAN FILTER
    CAMERA PROJECTION
    MISSION PLANNER

    View Slide

  73. PID CONTROLLER

    View Slide

  74. // Plan mission
    mission.takeoff()
    .zero()
    .hover(500)
    .altitude(3)
    .forward(2)
    .right(2)
    .backward(2)
    .go({x:0, y:0})
    .hover(500)
    .land();
    !
    // Execute mission
    mission.run(function (err, result) {
    if (err) {
    console.trace("Oops: %s", err.message);
    mission.client().stop();
    mission.client().land();
    } else {
    console.log("We are done!");
    process.exit(0);
    }
    });

    View Slide

  75. !
    // Land on ctrl-c
    var exiting = false;
    process.on('SIGINT', function() {
    if (exiting) {
    process.exit(0);
    } else {
    console.log('Landing, Control-C again to force exit');
    exiting = true;
    mission.control().disable();
    mission.client().land(function() {
    process.exit(0);
    });
    }
    });
    !

    View Slide

  76. NoDebots.io

    View Slide

  77. robotsconf.com

    View Slide

  78. No animals were harmed in the
    making of this presentation
    Thanks!

    View Slide

  79. github.com/andrew
    Thanks!

    View Slide

  80. Thanks!
    @teabass

    View Slide