KyivJS: control of mobile robots with JavaScript

Beginning: Arduino Inventor's Kit

Arduino inventor kit

ReadBoard Key features

  • Based on Arduino Uno
  • ATmega328 microcontroller
  • 32k Flash Memory
  • 16MHz Clock Speed
  • Input voltage - 7-15V
  • 14 Digital I/O Pins (6 PWM outputs)
  • 6 Analog Inputs
  • USB connection
RedBoard

C++ Blink example


        int ledPin =  13;    // LED connected to digital pin 13
         
        // The setup() method runs once, when the sketch starts
         
        void setup()   {                
          // initialize the digital pin as an output:
          pinMode(ledPin, OUTPUT);     
        }
         
        // the loop() method runs over and over again,
        // as long as the Arduino has power
         
        void loop()                     
        {
          digitalWrite(ledPin, HIGH);   // set the LED on
          delay(1000);                  // wait for a second
          digitalWrite(ledPin, LOW);    // set the LED off
          delay(1000);                  // wait for a second
        }
            

JavaScript Blink example


        var j5 = require("johnny-five");
        var myBoard, myLed;

        myBoard = new j5.Board();

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

          myLed = new j5.Led(13);

          myLed.strobe( 1000 );

          // make myLED available as "led" in REPL

          this.repl.inject({
              led: myLed
          });

          // try "on", "off", "toggle", "strobe", "stop" (stops strobing)
        });
              

Johnny-Five

Johnny-five

"... is an Open Source, IoT and Robotics programming framework"

  • Arduino
  • Beagle Bone
  • Intel Galileo
  • Raspberry Pi
  • many more

Johnny-five interfacing with Arduino

Johnny-five interfacing with Arduino

First try: Motobot

Motobot

Hardware

  • Arduino Uno
  • Motor Shield
  • Ultrasonic distance sensor
  • Servo

Software

  • Johnny-Five
  • Standard Firmata
  • Naive obstacle avoidance algorithm

Coursera

Control of Mobile Robots

Course content

  • Control theory, linear algebra
  • Different behaviors
  • Real robot control
  • QuickBot

Driving robots around

Driving robots around
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Divide and conquer with Behaviors

  • Go-to-goal
  • Avoid-obstacles
  • Follow-wall
  • Track-target

Differential Drive Robots

  • In order to control mobile robots, we need models
  • Differential drive wheeled robots a very common
Differential Drive Robots
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Differential Model

Differential Model
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Unicycle Model

Unicycle Model
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Model 2.0

Model 2.0
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Odometry

  • The state of the robot is (x, y, φ)
  • How do we obtain this state information?
  • Two possibilities:
    • External sensors
    • Internal sensors
      • Orientation: Compass
      • Position: Accelerometers, Gyroscopes
      • Wheel Encoders

Wheel Encoders

  • Wheel encoders give the distance moved by each wheel
  • Assume the wheels are following an arc (short time scale)
Wheel Encoders
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

How it looks?

Wheel disk

Wheel Encoders

How do we know how far each wheel has moved?
Wheel Encoders
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Special thanks

Dmitry Aleksandrov Encoder

Range sensors

Range Sensors
 *Magnus Egerstedt,Control of Mobile Robots,Georgia Institute of Technology

Robot communication control

Sim.I.Am

Alternative simulator

Pysimiam

Communication interface

              
    Command Set:
    ==========================  ===============================================
    $CHECK*\n                   returns 'Hello from QuickBot'
    $PWM?*\n                    returns wheel speeds in PWM: [50, -50]\n
    $PWM=[-100,100]*\n          sets the speed of the robot wheel velocities
    $ENVAL?*\n                  returns the encoder ticks ``(tl, tr)`` tuple
    $ENVEL?*\n                  returns the encoder velocities ``(vl, vr)``
                                tuple
    $IRVAL?*\n                  returns the 5-tuple raw ADC values of the IR
                                sensors, e.s [80.0, 251.0, 234.1, 12.1, 21.3]\n
    $RESET*\n                   resets encoder position to zero
    $END*\n                     disconnects from socket
    ==========================  ===============================================
              
            

Pysimiam with Arduino

Pysimiam wit Arduino

Challenges

  • Testing on real hardware
  • Bugs location
  • Complex course material

Further steps

  • Calibrate hardware
  • Arduino Yun
  • Obstacles avoidance
  • Sim.I.am.js

Resources

Demo

Sensors

Go to goal

Thanks

@sejoker