Class: RoboticArm
Defined Under Namespace
Classes: Base, Component, ComponentMoving, ComponentUpDown, Elbow, Gripper, Led, Shoulder, Wrist
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#elbow ⇒ Object
readonly
Returns the value of attribute elbow.
-
#grip ⇒ Object
readonly
Returns the value of attribute grip.
-
#gripper ⇒ Object
readonly
aliases for :led and :grip.
-
#led ⇒ Object
readonly
Returns the value of attribute led.
-
#light ⇒ Object
readonly
aliases for :led and :grip.
-
#shoulder ⇒ Object
readonly
Returns the value of attribute shoulder.
-
#wrist ⇒ Object
readonly
Returns the value of attribute wrist.
Instance Method Summary collapse
-
#command(switch, val) ⇒ Object
register and invoke the robotic action.
- #down(seconds = 0) ⇒ Object
-
#initialize ⇒ RoboticArm
constructor
A new instance of RoboticArm.
- #inspect ⇒ Object
- #left(seconds = 0) ⇒ Object
-
#off ⇒ Object
turn off all active signals.
- #right(seconds = 0) ⇒ Object
-
#stop ⇒ Object
stop all robotic movement.
- #up(seconds = 0) ⇒ Object
Methods included from Session
#record, #recording, #recording?
Constructor Details
#initialize ⇒ RoboticArm
Returns a new instance of RoboticArm.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/robotic-arm.rb', line 328 def initialize() # Get the device object usb = LIBUSB::Context.new arm = usb.devices(:idVendor => 0x1267, :idProduct => 0x0000).first (puts "Arm not found!"; exit) unless arm # Take control of the device @handle = arm.open @handle.claim_interface(0) @led = Led.new self @wrist = Wrist.new self @elbow = Elbow.new self @shoulder = Shoulder.new self @base = Base.new self @grip = Gripper.new self @register = [OFF,OFF,OFF] @light, @gripper = @led, @grip #aliases end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def base @base end |
#elbow ⇒ Object (readonly)
Returns the value of attribute elbow.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def elbow @elbow end |
#grip ⇒ Object (readonly)
Returns the value of attribute grip.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def grip @grip end |
#gripper ⇒ Object (readonly)
aliases for :led and :grip
185 186 187 |
# File 'lib/robotic-arm.rb', line 185 def gripper @gripper end |
#led ⇒ Object (readonly)
Returns the value of attribute led.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def led @led end |
#light ⇒ Object (readonly)
aliases for :led and :grip
185 186 187 |
# File 'lib/robotic-arm.rb', line 185 def light @light end |
#shoulder ⇒ Object (readonly)
Returns the value of attribute shoulder.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def shoulder @shoulder end |
#wrist ⇒ Object (readonly)
Returns the value of attribute wrist.
184 185 186 |
# File 'lib/robotic-arm.rb', line 184 def wrist @wrist end |
Instance Method Details
#command(switch, val) ⇒ Object
register and invoke the robotic action
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/robotic-arm.rb', line 359 def command(switch, val) @register[switch] += val handle_command if recording? then commands = { '21' => [:light, :on], '2-1' => [:light, :off], '02' => [:gripper, :open], '01' => [:gripper, :close], '0-2' => [:gripper, :stop], '0-1' => [:gripper, :stop], '04' => [:wrist, :up], '08' => [:wrist, :down], '0-4' => [:wrist, :stop], '0-8' => [:wrist, :stop], '016' => [:elbow, :up], '032' => [:elbow, :down], '0-16' => [:elbow, :stop], '0-32' => [:elbow, :stop], '064' => [:shoulder, :up], '0128' => [:shoulder, :down], '0-64' => [:shoulder, :stop], '0-128' => [:shoulder, :stop], '12' => [:base, :left], '11' => [:base, :right], '1-2' => [:base, :stop], '1-1' => [:base, :stop] } classname, methodname = *commands[switch.to_s + val.to_s] record classname, methodname end end |
#down(seconds = 0) ⇒ Object
355 |
# File 'lib/robotic-arm.rb', line 355 def down (seconds=0) @shoulder.down seconds end |
#inspect ⇒ Object
351 |
# File 'lib/robotic-arm.rb', line 351 def inspect() '#<RoboticArm:>' end |
#left(seconds = 0) ⇒ Object
352 |
# File 'lib/robotic-arm.rb', line 352 def left (seconds=0) @base.left seconds end |
#off ⇒ Object
turn off all active signals
388 389 390 391 |
# File 'lib/robotic-arm.rb', line 388 def off() stop @handle.release_interface(0) end |
#right(seconds = 0) ⇒ Object
353 |
# File 'lib/robotic-arm.rb', line 353 def right(seconds=0) @base.right seconds end |
#stop ⇒ Object
stop all robotic movement
395 396 397 398 399 400 401 |
# File 'lib/robotic-arm.rb', line 395 def stop() [wrist, elbow, shoulder, base, grip].each do |motor| motor.stop if motor.moving? end led.off if led.on? nil end |
#up(seconds = 0) ⇒ Object
354 |
# File 'lib/robotic-arm.rb', line 354 def up (seconds=0) @shoulder.up seconds end |