To view current Codelab, open Codelab.md
To install ruby on our system, download and install RVM and then type in our command line:
rvm install 2.6.3
- this will take a whilervm use 2.6.3
- open ruby folder in this repository
gem install bundler
bundle install
And you are good to go!
To run server on your computer, you need to install MQTT broker. We suggest Mosquito.
If you skip this step, 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.
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'
Rucicka::Client
has these available commands:
.park
- parks the arm to constant position, is called when creating new instance ofClient
- 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 wriststep * 10
degrees to the left.wrist_right
- rotates wriststep * 10
degrees to the right.wrist_down
- rotates wriststep * 10
degrees down.wrist_up
- rotates wriststep * 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 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
- Install Arduino IDE
- Open Arduino IDE
- Open
Tools
tab - Set:
Board
toArduino Duemilanove or Diecimila
Processor
toATmega328P
Port
to first available
- make changes - optional
- click on
Upload
architecture @startuml package "Ruby" {; [Server]; [Client]; [ArmLib]; };
package "Arduino" {; [rucicka.ino] as ar; };
[Server] <.. [Client] : MQTT; [ArmLib] <|-- [Client]; [ArmLib] <|-- [Server];
[Server] ..> HW : Serial link; ar <.. HW;
@enduml architecture