Class: BirdbrainFinchOutput
Overview
Copyright © 2021 Base2 Incorporated–All Rights Reserved.
Constant Summary
BirdbrainRequest::BIRDBRAIN_TEST
Class Method Summary
collapse
bounds, calculate_angle, calculate_intensity, calculate_left_or_right, calculate_speed, connected?, disconnect, not_connected?, request_status, response, response_body, uri, xyz_response
Class Method Details
.motors(device, left_speed, right_speed) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/birdbrain/birdbrain_finch_output.rb', line 22
def self.motors(device, left_speed, right_speed)
calc_left_speed = bounds(left_speed, -100, 100)
calc_right_speed = bounds(right_speed, -100, 100)
request_status(response_body('hummingbird', 'out', 'wheels', device, calc_left_speed, calc_right_speed))
end
|
.move(device, direction, distance, speed) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/birdbrain/birdbrain_finch_output.rb', line 5
def self.move(device, direction, distance, speed)
calc_direction = 'Forward' if direction == BirdbrainFinch::FORWARD
calc_direction = 'Backward' if direction == BirdbrainFinch::BACKWARD
calc_distance = bounds(distance, -10000, 10000)
calc_speed = bounds(speed, 0, 100)
request_status(response_body('hummingbird', 'out', 'move', device, calc_direction, calc_distance, calc_speed))
end
|
.reset_encoders(device) ⇒ Object
33
34
35
|
# File 'lib/birdbrain/birdbrain_finch_output.rb', line 33
def self.reset_encoders(device)
request_status(response_body('hummingbird', 'out', 'resetEncoders', device))
end
|
.stop(device) ⇒ Object
29
30
31
|
# File 'lib/birdbrain/birdbrain_finch_output.rb', line 29
def self.stop(device)
request_status(response_body('hummingbird', 'out', 'stopFinch', device))
end
|
.turn(device, direction, angle, speed) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/birdbrain/birdbrain_finch_output.rb', line 14
def self.turn(device, direction, angle, speed)
calc_direction = calculate_left_or_right(direction)
calc_angle = bounds(angle, 0, 360)
calc_speed = bounds(speed, 0, 100)
request_status(response_body('hummingbird', 'out', 'turn', device, calc_direction, calc_angle, calc_speed))
end
|