14. ET Robot Contest
• aka ET ロボコン(ET ROBOCON)
• ET means “Embedded Technology”
• To develop the advanced skills of
embedded technology such as modeling,
designing, and developing embedded
systems
• “one-make racing” style (all robots have
same designs)
15. EV3way: Software
System OS Language
TOPPERS/EV3RT TOPPERS RTOS C, C++
MonoBrick Linux C#
leJOS EV3 Linux Java
16. EV3way: Software
• mruby on EV3RT + TECS
• mrby Forum ver.
• yamanekko ver.
System OS Language
TOPPERS/EV3RT TOPPERS RTOS C + mruby
36. What’s RTOS
• OS for Real Time System
• Real time system: to make much of Deadlines
• NOTICE: “Real-Time” has several meanings
• “Real-Time” in RTOS is completely different
from such as “Real-time Web”
37. Time is Resource
• In real time
system, Tasks
should be done
in a given time
(deadline)
• RTOS manage
“Time” as
resources (like
memories)
https://www.flickr.com/photos/arjanrichter/3886579525/
38. Priority of tasks
• Every tasks have their own priority
• Lower-priority tasks never execute
when higher-priority tasks alive
• While higher-priority task is running,
lower-priority tasks are not running
(into READY status)
39. All tasks are mruby
main_task
balance_task
watch_task
HIGH priority
LOW priority
balancer.rb
watch.rb
app_ruby.rb
注)バランス制御に重点を置いた例。
これが正しい方法というわけではない
40. balancer.rb
loop do
forward = 30
color = colorSensor.brightness
if color >= (LIGHT_WHITE + LIGHT_BLACK)/2
turn = 20 ## turn left
else
turn = -20 ## turn right
end
pwm_left, pwm_right, *args =
balancer.calculate_auto(forward, turn, GYRO_OFFSET)
leftMotor.pwm = pwm_left
rightMotor.pwm = pwm_right
EV3RT::Task.sleep
end
74. SPI vs I2C
• SPI and I2C are popular protocols
• Gyro sensor L3GD20 supports both
• SPI is more complex, but faster than
I2C
• Raspberry Pi supports SPI (see
“BCM2835 ARM Peripherals”)
• https://www.raspberrypi.org/wp-content/uploads/
2012/02/BCM2835-ARM-Peripherals.pdf
75. Serial Peripheral Interface (SPI)
• Master and Slave model
• In our case, Raspberry Pi is master
• 4 pins (Input, Output, Clock, Select)
94. Balancing Equation
power = k_1 * omega_i +
k_2 * theta_i +
k_3 * v_i +
k_4 * x_i
a ≒ Power
v ≒ ∫ Power
x ≒ ∬ Power
P = K!! + K✓✓ + Kvv + Kxx
95. Balancing Equation
P = K!! + K✓✓ + Kvv + Kxx
= K!! + K✓
X
! + Kv
X
P + Kx
X X
P
power = k_1 * omega_i +
k_2 * theta_i +
k_3 * v_i +
k_4 * x_i
a ≒ Power
v ≒ ∫ Power
x ≒ ∬ Power
96. Balancing Equation
theta_i += omega_i
v_i += power
x_i += v_i
power = k_1 * theta_i +
k_2 * omega_i +
k_3 * v_i +
k_4 * x_i
P = K!! + K✓✓ + Kvv + Kxx
= K!! + K✓
X
! + Kv
X
P + Kx
X X
P
97. Balancer class
class Balancer
def calculate(omega_i)
@theta_i += omega_i
# …
t = @k_angle * @theta_i
o = @k_omega * omega_i
# …
power = t + o + …
# …
return power, power
end
end
98. main loop
loop do
gyro_value = gyro.measure(Gyro::Y,
MESURE_COUNTS)
pwm_left, pwm_right =
balancer.calculate(gyro_value)
motor_left.pwm = pwm_left
motor_right.pwm = pwm_right
end
103. Thank you & Domo Arigato!
ZZZ...
You can contact us on Twitter: @yuri_at_earth
Special Thanks to: @tenderlove
A. Hirai with ET Robocon Staff@chu-shikoku