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 full-size slide

  2. ANDREW NESBITT

    View full-size slide

  3. MY ROBOT STORY

    View full-size slide

  4. BEng Robotics & Automated Systems
    University of Plymouth

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. Robotics was
    expensive,
    complicated
    and not fun

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. FICTIONAL ROBOTS
    ENTERTAINMENT ROBOTS

    View full-size slide

  11. INDUSTRIAL ROBOTS

    View full-size slide

  12. DOMESTIC ROBOTS

    View full-size slide

  13. MEDICAL ROBOTS

    View full-size slide

  14. HOBBY ROBOTS

    View full-size slide

  15. EDUCATIONAL ROBOTS

    View full-size slide

  16. MILITARY ROBOTS

    View full-size slide

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

    View full-size slide

  18. ROBOT RABBIT FEEDER

    View full-size slide

  19. !
    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 full-size slide

  20. !
    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 full-size slide

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

    View full-size slide

  22. github.com/clebert/ev3

    View full-size slide

  23. Cat Laser Toy

    View full-size slide

  24. Cat Laser Toy
    Rabbit
    |
    v

    View full-size slide

  25. !
    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 full-size slide

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

    View full-size slide

  27. node-ardx.org

    View full-size slide

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

    View full-size slide

  29. 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 full-size slide

  30. 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 full-size slide

  31. AUTONOMOUS
    ROBOTS

    View full-size slide

  32. CONTROL LOOPS

    View full-size slide

  33. INPUTS
    !
    PROCESSING
    !
    OUTPUTS

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  37. npm install cylon

    View full-size slide

  38. 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 full-size slide

  39. // 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 full-size slide

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

    View full-size slide




  41. <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 full-size slide

  42. ARDRONE AUTONOMY

    View full-size slide

  43. PID CONTROLLER
    KALMAN FILTER
    CAMERA PROJECTION
    MISSION PLANNER

    View full-size slide

  44. PID CONTROLLER

    View full-size slide

  45. // 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 full-size slide

  46. !
    // 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 full-size slide

  47. robotsconf.com

    View full-size slide

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

    View full-size slide

  49. github.com/andrew
    Thanks!

    View full-size slide

  50. Thanks!
    @teabass

    View full-size slide