Skip to content

IoT Robotic Arm

David Podroužek edited this page Sep 18, 2018 · 1 revision

Goal of this codelab is to harness the power of robotic arm. To achieve this, we prepared Ruby client which comunicates with Ruby server using MQTT protocol. Server then comunicates with the arm via serial link. Your goal is to move companion cube from point A to the drop zone.

Get started

Ruby

To install ruby on our system, download and install RVM and then type in our command line:

  • rvm install 2.5.1 - this will take a while
  • rvm use 2.5.1
  • open ruby folder in this repository
  • gem install bundler
  • bundle install

And you are good to go!

Server

To run server on your computer, you need to install MQTT broker. We suggest Mosquito. If you skip this test, you will not be able to use the Client library. After install connect the arm to your computer and run ruby server.rb in command line. You should see something like this:

rucicka> Connecting...OK
rucicka> Initializing...OK
serial> <-  
serial> <-  
rucicka> Moving to `park` position
serial> -> <19,170,80,75,40,86>
rucicka> I am ready!

rucicka> Type command (or `help`):

You can try multiple modes available in help command, but we need to type mqtt to run client.

Client

After your server is running, create new file in ruby folder with .rb suffix. We will use example.rb. To use the client, start your file with require_relative "client". Then create new instance of Rucicka::Client class with client = Rucicka::Client.new. Your file should look like this:

require_relative 'client'

client = Rucicka::Client.new

Available commands

Rucicka::Client has these available commands:

  • .park - parks the arm to constant position, is called when creating new instance of Client
  • each of these following methods accepts optional step size
    • .forward - move the arm one step forward
    • .back - move the arm one step backward
    • .left - rotates the arm to the left
    • .right - rotates the arm to the right
    • .up - move the arm one step up
    • .down - move the arm one step down
    • .wrist_left - rotates wrist step * 10 degrees to the left
    • .wrist_right - rotates wrist step * 10 degrees to the right
    • .wrist_down - rotates wrist step * 10 degrees down
    • .wrist_up - rotates wrist step * 10 degrees up
  • .gripper_on - closes the gripper
  • .gripper_off - opens the gripper
  • .manual - enters manual mode, see Manual section for controls
  • .set_moves - enables to set multiple moves and call them all at the same time after the block ends
client.set_moves do
  client.forward(10)
  client.up(5)
  client.left(20)
  client.wrist_up(4)
end

Manual mode

Manual mode maps keyboard input to various methods. Keymap: (key --> method)

  • space --> park
  • arrow up / w --> up
  • arrow down / s --> down
  • arrow left / a --> left
  • arrow right / d --> right
  • + / r --> forward
  • - / f --> back
  • q --> gripper_on
  • e --> gripper_off
  • j --> wrist_left
  • l --> wrist_right
  • i --> wrist_up
  • k --> wrist_down

Any other input stops manual mode

Clone this wiki locally