Robotics 101

8ddbf811da78bb0daeeb3cacd7cf743f?s=47 Andrew Nesbitt
September 19, 2014

Robotics 101

Presented at Hackference 2.0.14

8ddbf811da78bb0daeeb3cacd7cf743f?s=128

Andrew Nesbitt

September 19, 2014
Tweet

Transcript

  1. ROBOTICS 101

  2. ANDREW NESBITT

  3. MY ROBOT STORY

  4. None
  5. None
  6. None
  7. BEng Robotics & Automated Systems University of Plymouth

  8. None
  9. Advanced Mathematics Mechanical Engineering Digital Electronics Analogue Electronics Computer Science

    Control Theory Neural Networking Microprocessor Design Playing with Robots LEARNING ROBOTICS
  10. Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Observing Robots behind glass LEARNING ROBOTICS
  11. Robotics was expensive, complicated and not fun

  12. APIs Open Source Hardware Smart phones Dynamic Programming Languages GitHub

    Mobile Internet 3D Printing 2014
  13. robot /ˈrəʊbɒt/ a machine capable of carrying out a complex

    series of actions automatically, especially one programmable by a computer.
  14. FICTIONAL ROBOTS ENTERTAINMENT ROBOTS

  15. INDUSTRIAL ROBOTS

  16. DOMESTIC ROBOTS

  17. MEDICAL ROBOTS

  18. HOBBY ROBOTS

  19. EDUCATIONAL ROBOTS

  20. MILITARY ROBOTS

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

  23. LEGO

  24. EV3

  25. ROBOT RABBIT FEEDER

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

  28. None
  29. None
  30. github.com/andrew/node-ev3-robot

  31. github.com/clebert/ev3

  32. None
  33. ARDUINO

  34. FIRMATA

  35. Cat Laser Toy

  36. Cat Laser Toy Rabbit | v

  37. Demo Time

  38. Demo Time

  39. Demo Time

  40. Demo Time

  41. Demo Time

  42. Demo Time

  43. Demo Time

  44. Demo Time

  45. Demo Time

  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)
 }) 

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

  49. node-ardx.org

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

  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) } } }
  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) }) })
  53. None
  54. AUTONOMOUS ROBOTS

  55. CONTROL LOOPS

  56. INPUTS ! PROCESSING ! OUTPUTS

  57. AUDIO, VISION, MOTION, TEMPERATURE, POSITION, DISTANCE, TOUCH, FORCE, MAGNETIC, LIGHT,

    VIBRATION, MOISTURE, PRESSURE, PROXIMITY, CHEMICAL, ELECTRICAL, COLOR AND MORE INPUT SENSORS
  58. WHEELS, GRIPPERS, ARMS, ROTORS, SERVOS, LIGHTS, SOUNDS,VISUALS, SWITCHES, RELAYS OUTPUTS

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

  60. None
  61. None
  62. npm install cylon

  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();
  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]}) });
  65. var express = require('express.io') var app = express().http().io() ! app.get('/',

    function(req, res) { res.sendfile(__dirname + '/client.html') }) ! app.listen(7076)
  66. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="//cdn.techpines.io/jquery.event.drag-2.0.js"></script> <script src="/socket.io/socket.io.js"></script> <script> App = {}

    App.socket = io.connect() ! var startX = 950; var startY = 500; ! var previousX = 950; var previousY = 500; ! App.draw = function(data) { App.ctx.beginPath() App.ctx.moveTo(previousX, previousY); App.ctx.lineWidth = 5; App.ctx.lineTo(data.x+startX,data.y+startY) App.ctx.strokeStyle = "#" + data.color App.ctx.stroke() previousX = data.x+startX; previousY = data.y+startY; } ! App.socket.on('draw', App.draw) ! $(function() { App.ctx = $('canvas')[0].getContext("2d") }) </script> <canvas width="1900px" height="1000px" style="margin: 0 auto;border:1px solid #eee;"></canvas>
  67. None
  68. None
  69. None
  70. None
  71. ARDRONE AUTONOMY

  72. PID CONTROLLER KALMAN FILTER CAMERA PROJECTION MISSION PLANNER

  73. PID CONTROLLER

  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); } });
  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); }); } }); !
  76. NoDebots.io

  77. robotsconf.com

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

    Thanks!
  79. github.com/andrew Thanks!

  80. Thanks! @teabass